Class: Transbank::Webpay::WebpayPlus::MallTransaction
- Inherits:
-
Common::BaseTransaction
- Object
- Common::BaseTransaction
- Transbank::Webpay::WebpayPlus::MallTransaction
- Defined in:
- lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb
Constant Summary collapse
- DEFAULT_ENVIRONMENT =
:integration
- RESOURCES_URL =
::Transbank::Common::ApiConstants::WEBPAY_ENDPOINT
- CREATE_ENDPOINT =
(RESOURCES_URL + '/transactions/').freeze
- COMMIT_ENDPOINT =
(RESOURCES_URL + '/transactions/%{token}').freeze
- STATUS_ENDPOINT =
(RESOURCES_URL + '/transactions/%{token}').freeze
- REFUND_ENDPOINT =
(RESOURCES_URL + '/transactions/%{token}/refunds').freeze
- CAPTURE_ENDPOINT =
(RESOURCES_URL + '/transactions/%{token}/capture').freeze
- INCREASE_AMOUNT_ENDPOINT =
(RESOURCES_URL + '/transactions/%{token}/amount').freeze
- INCREASE_AUTHORIZATION_DATE_ENDPOINT =
(RESOURCES_URL + '/transactions/%{token}/authorization_date').freeze
- REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT =
(RESOURCES_URL + '/transactions/%{token}/reverse/amount').freeze
- DEFERRED_CAPTURE_HISTORY_ENDPOINT =
(RESOURCES_URL + '/transactions/%{token}/details').freeze
Instance Method Summary collapse
- #capture(child_commerce_code, token, buy_order, authorization_code, capture_amount) ⇒ Object
- #commit(token) ⇒ Object
- #create(buy_order, session_id, return_url, details) ⇒ Object
- #deferred_capture_history(token, child_commerce_code, child_buy_order) ⇒ Object
- #increase_amount(token, child_commerce_code, child_buy_order, authorization_code, amount) ⇒ Object
- #increase_authorization_date(token, child_commerce_code, child_buy_order, authorization_code) ⇒ Object
-
#initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::WEBPAY_PLUS_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT) ⇒ MallTransaction
constructor
A new instance of MallTransaction.
- #refund(token, buy_order, child_commerce_code, amount) ⇒ Object
- #reverse_pre_authorized_amount(token, child_commerce_code, child_buy_order, authorization_code, amount) ⇒ Object
- #status(token) ⇒ Object
Constructor Details
#initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::WEBPAY_PLUS_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT) ⇒ MallTransaction
Returns a new instance of MallTransaction.
17 18 19 |
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb', line 17 def initialize(commerce_code = ::Transbank::Common::IntegrationCommerceCodes::WEBPAY_PLUS_MALL, api_key = ::Transbank::Common::IntegrationApiKeys::WEBPAY, environment = DEFAULT_ENVIRONMENT) super end |
Instance Method Details
#capture(child_commerce_code, token, buy_order, authorization_code, capture_amount) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb', line 67 def capture(child_commerce_code, token, buy_order, , capture_amount) Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code") Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token") Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order") Transbank::Common::Validation.has_text_with_max_length(, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code") request_service = ::Transbank::Shared::RequestService.new( @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key ) request_service.put(commerce_code: child_commerce_code, buy_order: buy_order, authorization_code: , capture_amount: capture_amount) end |
#commit(token) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb', line 35 def commit(token) Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token") request_service = ::Transbank::Shared::RequestService.new( @environment, format(COMMIT_ENDPOINT, token: token), @commerce_code, @api_key ) request_service.put({}) end |
#create(buy_order, session_id, return_url, details) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb', line 21 def create(buy_order, session_id, return_url, details) Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order") Transbank::Common::Validation.has_text_with_max_length(session_id, Transbank::Common::ApiConstants::SESSION_ID_LENGTH, "session_id") Transbank::Common::Validation.has_text_with_max_length(return_url, Transbank::Common::ApiConstants::RETURN_URL_LENGTH, "return_url") request_service = ::Transbank::Shared::RequestService.new( @environment, CREATE_ENDPOINT, @commerce_code, @api_key ) request_service.post({ buy_order: buy_order, session_id: session_id, return_url: return_url, details: details }) end |
#deferred_capture_history(token, child_commerce_code, child_buy_order) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb', line 120 def deferred_capture_history(token, child_commerce_code, child_buy_order) Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code") Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token") Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order") request_service = ::Transbank::Shared::RequestService.new( @environment, format(DEFERRED_CAPTURE_HISTORY_ENDPOINT, token: token), @commerce_code, @api_key ) request_service.post(commerce_code: child_commerce_code, buy_order: child_buy_order) end |
#increase_amount(token, child_commerce_code, child_buy_order, authorization_code, amount) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb', line 81 def increase_amount(token, child_commerce_code, child_buy_order, , amount) Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code") Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token") Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order") Transbank::Common::Validation.has_text_with_max_length(, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code") request_service = ::Transbank::Shared::RequestService.new( @environment, format(INCREASE_AMOUNT_ENDPOINT, token: token), @commerce_code, @api_key ) request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: , amount: amount) end |
#increase_authorization_date(token, child_commerce_code, child_buy_order, authorization_code) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb', line 94 def (token, child_commerce_code, child_buy_order, ) Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code") Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token") Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order") Transbank::Common::Validation.has_text_with_max_length(, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code") request_service = ::Transbank::Shared::RequestService.new( @environment, format(INCREASE_AUTHORIZATION_DATE_ENDPOINT, token: token), @commerce_code, @api_key ) request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: ) end |
#refund(token, buy_order, child_commerce_code, amount) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb', line 55 def refund(token, buy_order, child_commerce_code, amount) Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token") Transbank::Common::Validation.has_text_with_max_length(buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "buy_order") Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code") request_service = ::Transbank::Shared::RequestService.new( @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key ) request_service.post(buy_order: buy_order, commerce_code: child_commerce_code, amount: amount) end |
#reverse_pre_authorized_amount(token, child_commerce_code, child_buy_order, authorization_code, amount) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb', line 107 def (token, child_commerce_code, child_buy_order, , amount) Transbank::Common::Validation.has_text_with_max_length(child_commerce_code, Transbank::Common::ApiConstants::COMMERCE_CODE_LENGTH, "child_commerce_code") Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token") Transbank::Common::Validation.has_text_with_max_length(child_buy_order, Transbank::Common::ApiConstants::BUY_ORDER_LENGTH, "child_buy_order") Transbank::Common::Validation.has_text_with_max_length(, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code") request_service = ::Transbank::Shared::RequestService.new( @environment, format(REVERSE_PRE_AUTHORIZED_AMOUNT_ENDPOINT, token: token), @commerce_code, @api_key ) request_service.put(commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: , amount: amount) end |
#status(token) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/transbank/sdk/webpay/webpay_plus/mall_transaction.rb', line 45 def status(token) Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token") request_service = ::Transbank::Shared::RequestService.new( @environment, format(STATUS_ENDPOINT, token: token), @commerce_code, @api_key ) request_service.get end |