Sha256: efed9425973f5c3426142fb041db9a52168dd8716be2dc9917d5e026e81b6459
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
module Spree class Gateway::Affirm < Gateway preference :api_key, :string preference :secret_key, :string preference :test_mode, :boolean, default: true preference :server, :string, default: 'sandbox.affirm.com' 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.to_s ).first return if _payment.nil? if _payment.pending? _payment.void_transaction! elsif _payment.completed? && _payment.can_credit? provider.refund(_payment.credit_allowed.to_money.cents, charge_ari) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_affirm-0.2.30 | app/models/spree/gateway/affirm.rb |
spree_affirm-0.2.3 | app/models/spree/gateway/affirm.rb |