Sha256: da90309040e8bf15443b7cd93394375e0140bb9c60b7b932556bde7fb21073b3
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
module Shoppe module Stripe module OrderExtensions def accept_stripe_token(token) if token =~ /\Atok/ customer = ::Stripe::Customer.create(:description => "Customer for order #{number}", :card => token) self.properties['stripe_customer_token'] = customer.id self.save elsif token =~ /\Acus/ && self.properties[:stripe_customer_token] != token self.properties['stripe_customer_token'] = token self.save elsif self.properties['stripe_customer_token'] && self.properties['stripe_customer_token'] =~ /\Acus/ true else false end end private def stripe_customer @stripe_customer ||= ::Stripe::Customer.retrieve(self.properties['stripe_customer_token']) end def stripe_card @stripe_card ||= stripe_customer.cards.last end def stripe_charge return false unless self.paid? && self.payment_method == 'Stripe' @stripe_charge ||= ::Stripe::Charge.retrieve(self.payment_reference) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shoppe-stripe-1.0.2 | lib/shoppe/stripe/order_extensions.rb |
shoppe-stripe-1.0.1 | lib/shoppe/stripe/order_extensions.rb |
shoppe-stripe-1.0.0 | lib/shoppe/stripe/order_extensions.rb |