Sha256: 680d019007a9f7b9b8ac550252c034c6ba840a69d0e505426b64177d90de8d88
Contents?: true
Size: 1017 Bytes
Versions: 1
Compression:
Stored size: 1017 Bytes
Contents
module KktShoppe module Stripe module OrderExtensions def accept_stripe_token(token) if token =~ /\Atok/ customer = ::Stripe::Customer.create({:description => "Customer for order #{number}", :card => token}, KktShoppe.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'], KktShoppe.settings.stripe_api_key) end def stripe_card @stripe_card ||= stripe_customer.cards.last end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kkt_shoppe-stripe-2.0.0 | lib/kkt_shoppe/stripe/order_extensions.rb |