Class: Transbank::Webpay::WebpayPlus::Transaction
- Inherits:
-
Common::BaseTransaction
- Object
- Common::BaseTransaction
- Transbank::Webpay::WebpayPlus::Transaction
- Defined in:
- lib/transbank/sdk/webpay/webpay_plus/transaction.rb
Constant Summary collapse
- 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
Class Method Summary collapse
- .build_for_integration(commerce_code, api_key) ⇒ Object
- .build_for_production(commerce_code, api_key) ⇒ Object
- .new(options) ⇒ Object
Instance Method Summary collapse
- #capture(token, buy_order, authorization_code, amount) ⇒ Object
- #commit(token) ⇒ Object
- #create(buy_order, session_id, amount, return_url) ⇒ Object
-
#initialize(options) ⇒ Transaction
constructor
A new instance of Transaction.
- #refund(token, amount) ⇒ Object
- #status(token) ⇒ Object
Constructor Details
#initialize(options) ⇒ Transaction
Returns a new instance of Transaction.
13 14 15 |
# File 'lib/transbank/sdk/webpay/webpay_plus/transaction.rb', line 13 def initialize() super end |
Class Method Details
.build_for_integration(commerce_code, api_key) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/transbank/sdk/webpay/webpay_plus/transaction.rb', line 21 def self.build_for_integration(commerce_code, api_key) = Options.new( commerce_code, api_key, :integration ) new() end |
.build_for_production(commerce_code, api_key) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/transbank/sdk/webpay/webpay_plus/transaction.rb', line 31 def self.build_for_production(commerce_code, api_key) = Options.new( commerce_code, api_key, :production ) new() end |
.new(options) ⇒ Object
17 18 19 |
# File 'lib/transbank/sdk/webpay/webpay_plus/transaction.rb', line 17 def self.new() super() end |
Instance Method Details
#capture(token, buy_order, authorization_code, amount) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/transbank/sdk/webpay/webpay_plus/transaction.rb', line 84 def capture(token, buy_order, , 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(, Transbank::Common::ApiConstants::AUTHORIZATION_CODE_LENGTH, "authorization_code") request_service = ::Transbank::Shared::RequestService.new( @environment, format(CAPTURE_ENDPOINT, token: token), @commerce_code, @api_key, @timeout ) request_service.put(buy_order: buy_order, authorization_code: , capture_amount: amount) end |
#commit(token) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/transbank/sdk/webpay/webpay_plus/transaction.rb', line 54 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, @timeout ) request_service.put({}) end |
#create(buy_order, session_id, amount, return_url) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/transbank/sdk/webpay/webpay_plus/transaction.rb', line 40 def create(buy_order, session_id, amount, return_url) 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, @timeout ) request_service.post({ buy_order: buy_order, session_id: session_id, amount: amount, return_url: return_url }) end |
#refund(token, amount) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/transbank/sdk/webpay/webpay_plus/transaction.rb', line 74 def refund(token, amount) Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token") request_service = ::Transbank::Shared::RequestService.new( @environment, format(REFUND_ENDPOINT, token: token), @commerce_code, @api_key, @timeout ) request_service.post(amount: amount) end |
#status(token) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/transbank/sdk/webpay/webpay_plus/transaction.rb', line 64 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, @timeout ) request_service.get end |