Sha256: bac2e86117c44c8ca80904dc81825327a1338a6f99e69e137753e243b347df95
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
# frozen_string_literal: true module Workarea decorate Payment::Authorize::CreditCard, with: :cim do def complete! return unless Workarea::Payment::StoreCreditCard.new(tender, options).save! transaction.response = handle_active_merchant_errors do gateway.create_customer_profile_transaction(auth_args) end end def cancel! return unless transaction.success? transaction.cancellation = handle_active_merchant_errors do gateway.create_customer_profile_transaction(void_args) end end private def auth_args { transaction: { type: :auth_only, customer_profile_id: customer_profile_id, customer_payment_profile_id: customer_payment_profile_id, amount: auth_amount, order: { invoice_number: tender.payment.id.first(20) # auth net has max length 20 for this field } }, extra_options: { x_customer_ip: customer_ip_address } } end def void_args { transaction: { type: :void, customer_profile_id: customer_profile_id, customer_payment_profile_id: customer_payment_profile_id, trans_id: transaction.response.authorization } } end def customer_ip_address tender.ip_address end def customer_profile_id tender.gateway_profile_id end def customer_payment_profile_id tender.token end # cim requeires dollar amount (not cents) # eg $4.25 def auth_amount tender.amount.cents / 100.00 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
workarea-authorize_cim-2.1.3 | app/models/workarea/payment/authorize/credit_card.decorator |
workarea-authorize_cim-2.1.2 | app/models/workarea/payment/authorize/credit_card.decorator |