Sha256: e7a249c7e277fc5b568b2f89efc3b2f8dcca6f2ca15ea82416c768b500587b6a
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
module Spree class Gateway::Affirm < Gateway preference :api_key, :string preference :secret_key, :string preference :server, :string, default: 'www.affirm.com' preference :product_key, :string def provider_class ActiveMerchant::Billing::Affirm end def payment_source_class Spree::AffirmCheckout end def source_required? true end def method_type 'affirm' end def actions %w{capture void credit} end def supports?(source) source.is_a? payment_source_class end def self.version Gem::Specification.find_by_name('spree_affirm').version.to_s end def cancel(charge_ari) _payment = Spree::Payment.valid.where( response_code: charge_ari, source_type: "#{payment_source_class}" ).first return if _payment.nil? if _payment.pending? _payment.void_transaction! elsif _payment.completed? and _payment.can_credit? # create adjustment _payment.order.adjustments.create label: "Refund - Canceled Order", amount: -_payment.credit_allowed.to_f _payment.order.update! _payment.credit! end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spree_affirm-0.2.22 | app/models/spree/gateway/affirm.rb |
spree_affirm-0.2.21 | app/models/spree/gateway/affirm.rb |
spree_affirm-0.2.20 | app/models/spree/gateway/affirm.rb |