Sha256: ccdd650a5a9c8983c68d152eccf9a9ffb979c379b527be18725fc24376c2893a
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 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}, Shoppe.settings.stripe_api_key) 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'], Shoppe.settings.stripe_api_key) 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, Shoppe.settings.stripe_api_key) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shoppe-stripe-1.1.0 | lib/shoppe/stripe/order_extensions.rb |