Sha256: c1328f27f7ee165dc643515e53c7ee729db66b33d1a682876e6749b8fdf62676
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
module Workarea class Payment module Purchase class Afterpay include OperationImplementation include CreditCardOperation include AfterpayPaymentGateway def complete! response = purchase if response.success? && response.body['status'] == 'APPROVED' transaction.response = ActiveMerchant::Billing::Response.new( true, I18n.t( 'workarea.afterpay.purchase', amount: transaction.amount ), response.body ) else transaction.response = ActiveMerchant::Billing::Response.new( false, I18n.t('workarea.afterpay.purchase_failure'), response.body ) end end def cancel! # No op - no cancel functionality available. end private def purchase request_id = SecureRandom.uuid purchase_response = response(request_id) if Workarea::Afterpay::RETRY_ERROR_STATUSES.include? purchase_response.status return response(request_id) end purchase_response end def response(request_id) gateway.purchase(tender.token, request_id) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
workarea-afterpay-2.1.2 | app/models/workarea/payment/purchase/afterpay.rb |
workarea-afterpay-2.1.1 | app/models/workarea/payment/purchase/afterpay.rb |