Sha256: 000e1ab3dc3ac1badd8b7aa06fad609dc1b47d1c981baee0b75adb1aa77b3bcc
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
module Moneytree class PaymentGateway < ApplicationRecord belongs_to :account, polymorphic: true enum psp: Moneytree::PSPS serialize :psp_credentials # encrypts :psp_credentials # FIXME: enable https://github.com/ankane/lockbox delegate :oauth_link, :scope_correct?, :charge, :refund, to: :payment_provider # has_many :orders # has_many :transactions # has_many :customers # has_many :cards def oauth_callback(params) update! psp_credentials: payment_provider.get_access_token(params) end def psp_connected? psp.present? && psp_credentials.present? end def needs_oauth? !psp_connected? || !scope_correct? end def scope_correct? psp_credentials[:scope] == payment_provider.scope end private def payment_provider @payment_provider ||= case psp when 'stripe' # TODO: see if we only need to pass credentials Moneytree::PaymentProvider::Stripe.new(self) # when 'square' # Moneytree::PaymentProvider::Square.new(self) else raise 'BOOM' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
moneytree-rails-0.1.5 | app/models/moneytree/payment_gateway.rb |
moneytree-rails-0.1.4 | app/models/moneytree/payment_gateway.rb |