Sha256: 9a47ac23641d7396248093ca20f05f1b2be5a0398555b217dfc495f874a99a48
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 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 } } } 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_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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
workarea-authorize_cim-2.1.1 | app/models/workarea/payment/authorize/credit_card.decorator |