class Transbank::Webpay::Oneclick::MallTransaction
Constants
- AUTHORIZE_TRANSACTION_ENDPOINT
- TRANSACTION_REFUND_ENDPOINT
- TRANSACTION_STATUS_ENDPOINT
Public Class Methods
default_integration_params()
click to toggle source
# File lib/transbank/sdk/oneclick/mall/mall_transaction.rb, line 85 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
refund(buy_order:, child_commerce_code:, child_buy_order:, amount:, options: nil)
click to toggle source
# File lib/transbank/sdk/oneclick/mall/mall_transaction.rb, line 65 def refund(buy_order:, child_commerce_code:, child_buy_order:, 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_REFUND_ENDPOINT.gsub(':buy_order', buy_order) headers = webpay_headers(commerce_code: commerce_code, api_key: api_key) body = { detail_buy_order: child_buy_order, commerce_code: child_commerce_code, amount: amount } resp = http_post(uri_string: url, body: body, headers: headers, camel_case_keys: false) body = JSON.parse(resp.body) return ::Transbank::Webpay::Oneclick::MallTransactionRefundResponse.new(body) if resp.kind_of? Net::HTTPSuccess raise Oneclick::Errors::MallTransactionRefundError.new(body['error_message'], resp.code) end
status(buy_order:, options: nil)
click to toggle source
# File lib/transbank/sdk/oneclick/mall/mall_transaction.rb, line 51 def status(buy_order:, 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_STATUS_ENDPOINT.gsub(':buy_order', buy_order) headers = webpay_headers(commerce_code: commerce_code, api_key: api_key) resp = http_get(uri_string: url, headers: headers) body = JSON.parse(resp.body) return ::Transbank::Webpay::Oneclick::MallTransactionStatusResponse.new(body) if resp.kind_of? Net::HTTPSuccess raise Oneclick::Errors::MallTransactionStatusError.new(body['error_message'], resp.code) end