lib/active_merchant/billing/gateways/nexio.rb in nexio_activemerchant-0.2.0 vs lib/active_merchant/billing/gateways/nexio.rb in nexio_activemerchant-0.2.1

- old
+ new

@@ -40,10 +40,11 @@ post = build_payload(options) post[:processingOptions] ||= {} post[:processingOptions][:verboseResponse] = true if test? post[:processingOptions][:customerRedirectUrl] = options[:three_d_callback_url] if options.key?(:three_d_callback_url) post[:processingOptions][:check3ds] = options[:three_d_secure] + post[:processingOptions][:paymentType] = options[:payment_type] if options.key?(:payment_type) add_invoice(post, money, options) add_payment(post, payment, options) add_order_data(post, options) commit('process', post) end @@ -109,10 +110,15 @@ def set_secret commit('secret', { merchantId: options[:merchant_id].to_s }).params['secret'] end + def get_transaction(id) + parse(ssl_get(action_url("/transaction/v3/paymentId/#{id}"), base_headers)) + rescue ResponseError => e + end + private def add_invoice(post, money, options) post[:data][:amount] = amount(money).to_f add_currency(post, options) @@ -232,12 +238,11 @@ rescue StandardError {} end def commit(action, parameters) - payload = parse(ssl_post(commit_action_url(action, parameters), post_data(action, parameters), - Authorization: "Basic #{options[:auth_token]}")) + payload = parse(ssl_post(commit_action_url(action, parameters), post_data(action, parameters), base_headers)) Response.new( response_status(action, payload), nil, payload, @@ -279,10 +284,14 @@ when 'webhook' then '/webhook/v3/config' when 'secret' then '/webhook/v3/secret' else "/pay/v3/#{action}" end + action_url(path) + end + + def action_url(path) "#{test? ? test_url : live_url}#{path}" end def build_avs_result(data) return if data.blank? @@ -296,9 +305,13 @@ CVVResult.new(data.fetch('gatewayMessage', {}).fetch('cvvresponse', nil)) end def build_payload(options) { data: { customer: {} } }.merge!(options.fetch(:payload, {})) + end + + def base_headers(custom = {}) + { Authorization: "Basic #{options[:auth_token]}" } end end end end