Sha256: e43aa1521163adfcf515d36789b34b1962b17904a182dd64e5de6aa2fbc2a422
Contents?: true
Size: 1008 Bytes
Versions: 2
Compression:
Stored size: 1008 Bytes
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 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shoppe-stripe-1.2.2 | lib/shoppe/stripe/order_extensions.rb |
shoppe-stripe-1.2.1 | lib/shoppe/stripe/order_extensions.rb |