Class: Transbank::Webpay::WebpayPlus::MallDeferredTransaction
- Inherits:
-
Object
- Object
- Transbank::Webpay::WebpayPlus::MallDeferredTransaction
show all
- Extended by:
- Utils::NetHelper
- Defined in:
- lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb
Constant Summary
collapse
- CREATE_TRANSACTION_ENDPOINT =
'rswebpaytransaction/api/webpay/v1.0/transactions'
- COMMIT_TRANSACTION_ENDPOINT =
'rswebpaytransaction/api/webpay/v1.0/transactions'
- TRANSACTION_STATUS_ENDPOINT =
'rswebpaytransaction/api/webpay/v1.0/transactions/:token'
- REFUND_TRANSACTION_ENDPOINT =
'rswebpaytransaction/api/webpay/v1.0/transactions/:token/refunds'
- CAPTURE_TRANSACTION_ENDPOINT =
'rswebpaytransaction/api/webpay/v1.0/transactions/:token/capture'
Class Method Summary
collapse
-
.capture(token:, child_commerce_code:, buy_order:, authorization_code:, capture_amount:, options: nil) ⇒ Object
-
.commit(token:, options: nil) ⇒ Object
-
.create(buy_order:, session_id:, return_url:, details:, options: nil) ⇒ Object
-
.default_integration_params ⇒ Object
-
.refund(token:, buy_order:, child_commerce_code:, amount:, options: nil) ⇒ Object
-
.status(token:, options: nil) ⇒ Object
http_delete, http_get, http_post, http_put, keys_to_camel_case, patpass_comercio_headers, snake_to_camel_case, webpay_headers
Class Method Details
.capture(token:, child_commerce_code:, buy_order:, authorization_code:, capture_amount:, options: nil) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb', line 77
def capture(token:, child_commerce_code:, buy_order:, authorization_code:, capture_amount:, options: nil)
api_key = options&.api_key || default_integration_params[:api_key]
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
integration_type = options&.integration_type || default_integration_params[:integration_type]
base_url = integration_type.nil? ? WebpayPlus::Base::integration_type[:TEST] : WebpayPlus::Base.integration_type_url(integration_type)
url = base_url + CAPTURE_TRANSACTION_ENDPOINT.gsub(':token', token)
= (commerce_code: commerce_code, api_key: api_key)
body = {
commerce_code: child_commerce_code,
buy_order: buy_order,
authorization_code: authorization_code,
capture_amount: capture_amount
}
resp = http_put(uri_string: url, body: body, headers: )
body = JSON.parse(resp.body)
return ::Transbank::Webpay::WebpayPlus::TransactionCaptureResponse.new(body) if resp.kind_of? Net::HTTPSuccess
raise Errors::TransactionCaptureError.new(body['error_message'], resp.code)
end
|
.commit(token:, options: nil) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb', line 31
def commit(token:, options:nil)
api_key = options&.api_key || default_integration_params[:api_key]
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
integration_type = options&.integration_type || default_integration_params[:integration_type]
base_url = integration_type.nil? ? WebpayPlus::Base::integration_type[:TEST] : WebpayPlus::Base.integration_type_url(integration_type)
url = base_url + "#{COMMIT_TRANSACTION_ENDPOINT}/#{token}"
= (commerce_code: commerce_code, api_key: api_key)
resp = http_put(uri_string: url, body: {}, headers: )
json = JSON.parse(resp.body)
return ::Transbank::Webpay::WebpayPlus::MallTransactionCommitResponse.new(json) if resp.kind_of? Net::HTTPSuccess
raise Errors::TransactionCommitError.new(json['error_message'], resp.code)
end
|
.create(buy_order:, session_id:, return_url:, details:, options: nil) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb', line 13
def create(buy_order:, session_id:, return_url:, details:, options: nil)
api_key = options&.api_key || default_integration_params[:api_key]
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
integration_type = options&.integration_type || default_integration_params[:integration_type]
base_url = integration_type.nil? ? WebpayPlus::Base::integration_type[:TEST] : WebpayPlus::Base.integration_type_url(integration_type)
url = base_url + CREATE_TRANSACTION_ENDPOINT
= (commerce_code: commerce_code, api_key: api_key)
body = {buy_order: buy_order,
session_id: session_id,
details: details,
return_url: return_url}
resp = http_post(uri_string: url, body: body, headers: , camel_case_keys: false)
json = JSON.parse(resp.body)
return ::Transbank::Webpay::WebpayPlus::TransactionCreateResponse.new(json) if resp.kind_of? Net::HTTPSuccess
raise Errors::TransactionCreateError.new(json['error_message'], resp.code)
end
|
.default_integration_params ⇒ Object
.refund(token:, buy_order:, child_commerce_code:, amount:, options: nil) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb', line 45
def refund(token:, buy_order:, child_commerce_code:, amount:, options:nil)
api_key = options&.api_key || default_integration_params[:api_key]
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
integration_type = options&.integration_type || default_integration_params[:integration_type]
base_url = integration_type.nil? ? WebpayPlus::Base::integration_type[:TEST] : WebpayPlus::Base.integration_type_url(integration_type)
url = base_url + "#{REFUND_TRANSACTION_ENDPOINT}".gsub(':token', token)
= (commerce_code: commerce_code, api_key: api_key)
body = {
buy_order: buy_order,
commerce_code: child_commerce_code,
amount: amount
}
resp = http_post(uri_string: url, body: body, headers: , camel_case_keys: false)
json = JSON.parse(resp.body)
return ::Transbank::Webpay::WebpayPlus::TransactionRefundResponse.new(json) if resp.kind_of? Net::HTTPSuccess
raise Errors::TransactionRefundError.new(json['error_message'], resp.code)
end
|
.status(token:, options: nil) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb', line 63
def status(token:, options: nil)
api_key = options&.api_key || default_integration_params[:api_key]
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
integration_type = options&.integration_type || default_integration_params[:integration_type]
base_url = integration_type.nil? ? WebpayPlus::Base::integration_type[:TEST] : WebpayPlus::Base.integration_type_url(integration_type)
url = base_url + "#{TRANSACTION_STATUS_ENDPOINT}".gsub(':token', token)
= (commerce_code: commerce_code, api_key: api_key)
resp = http_get(uri_string: url, headers: )
json = JSON.parse(resp.body)
return ::Transbank::Webpay::WebpayPlus::MallTransactionStatusResponse.new(json) if resp.kind_of? Net::HTTPSuccess
raise Errors::TransactionStatusError.new(json['error_message'], resp.code)
end
|