class Transbank::Webpay::Oneclick::MallDeferredTransaction
Constants
- TRANSACTION_CAPTURE_ENDPOINT
Public Class Methods
capture(child_commerce_code:, child_buy_order:, authorization_code:, amount:, options: nil)
click to toggle source
# File lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_transaction.rb, line 10 def capture(child_commerce_code:, child_buy_order:, authorization_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? ? Oneclick::Base::integration_type[:TEST] : Oneclick::Base.integration_type_url(integration_type) url = base_url + TRANSACTION_CAPTURE_ENDPOINT headers = webpay_headers(commerce_code: commerce_code, api_key: api_key) body = { commerce_code: child_commerce_code, buy_order: child_buy_order, authorization_code: authorization_code, capture_amount: amount } resp = http_put(uri_string: url, headers: headers, body: body) body = JSON.parse(resp.body) return ::Transbank::Webpay::Oneclick::MallDeferredTransactionCaptureResponse.new(body) if resp.kind_of? Net::HTTPSuccess raise Oneclick::Errors::MallDeferredTransactionCaptureError.new(body['error_message'], resp.code) end
default_integration_params()
click to toggle source
# File lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_transaction.rb, line 30 def default_integration_params { api_key: Oneclick::Base.api_key, commerce_code: Oneclick::Base.commerce_code, integration_type: Oneclick::Base::integration_type, base_url: Oneclick::Base::current_integration_type_url } end