Class: Transbank::Patpass::PatpassByWebpay::Transaction
- Inherits:
-
Object
- Object
- Transbank::Patpass::PatpassByWebpay::Transaction
show all
- Extended by:
- Utils::NetHelper
- Defined in:
- lib/transbank/sdk/patpass/patpass_by_webpay/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'
Class Method Summary
collapse
http_delete, http_get, http_post, http_put, keys_to_camel_case, patpass_comercio_headers, snake_to_camel_case, webpay_headers
Class Method Details
.commit(token:, options: nil) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb', line 37
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]
base_url = PatpassByWebpay::Base.integration_types[options&.integration_type] || default_integration_params[:base_url]
url = base_url + COMMIT_TRANSACTION_ENDPOINT + "/#{token}"
= (commerce_code: commerce_code, api_key: api_key)
resp = http_put(uri_string: url, body: nil, headers: )
body = JSON.parse(resp.body)
return ::Transbank::Patpass::PatpassByWebpay::TransactionCommitResponse.new(body) if resp.kind_of? Net::HTTPSuccess
raise Errors::TransactionCommitError.new(body['error_message'], resp.code)
end
|
.create(buy_order:, session_id:, amount:, return_url:, details:, options: nil) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb', line 12
def create(buy_order:, session_id:, amount:, 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? ? PatpassByWebpay::Base::integration_types[:TEST] : PatpassByWebpay::Base.integration_type_url(integration_type)
wpm_detail = wpm_details(details)
body = {
buy_order: buy_order,
session_id: session_id,
amount: amount,
return_url: return_url,
wpm_detail: wpm_detail
}
url = base_url + CREATE_TRANSACTION_ENDPOINT
= (commerce_code: commerce_code, api_key: api_key)
resp = http_post(uri_string: url, body: body, headers: , camel_case_keys: false)
body = JSON.parse(resp.body)
return ::Transbank::Patpass::PatpassByWebpay::TransactionCreateResponse.new(body) if resp.kind_of? Net::HTTPSuccess
raise Errors::TransactionCreateError.new(body['error_message'], resp.code)
end
|
.default_integration_params ⇒ Object
.status(token:, options: nil) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb', line 52
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]
base_url = PatpassByWebpay::Base.integration_types[options&.integration_type] || default_integration_params[:base_url]
url = base_url + "#{TRANSACTION_STATUS_ENDPOINT}/#{token}"
= (commerce_code: commerce_code, api_key: api_key)
resp = http_get(uri_string: url, headers: )
body = JSON.parse(resp.body)
return ::Transbank::Patpass::PatpassByWebpay::TransactionStatusResponse.new(body) if resp.kind_of? Net::HTTPSuccess
raise Errors::TransactionStatusError.new(body['error_message'], resp.code)
end
|