Sha256: 04b54b2e7d78b0fe699ae0e787a294f13d2890b4d0bfd2db436c025c4ee516e9
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
# frozen_string_literal: true module Workarea decorate Payment::Purchase::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_capture_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_capture_args { transaction: { type: :auth_capture, 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.to_s.to_f 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/purchase/credit_card.decorator |
workarea-authorize_cim-2.1.2 | app/models/workarea/payment/purchase/credit_card.decorator |