Class: Bodega::PaymentMethod::Stripe
- Defined in:
- lib/bodega/payment_method/stripe.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#checkout_url(success_url, cancel_url, params = {}) ⇒ Object
Redirect to /cart/complete?stripe=tokenToVerifyPayment.
- #complete!(options = {}) ⇒ Object
- #shipping? ⇒ Boolean
Methods inherited from Base
Methods included from Optional
Constructor Details
This class inherits a constructor from Bodega::PaymentMethod::Base
Instance Method Details
#checkout_url(success_url, cancel_url, params = {}) ⇒ Object
Redirect to /cart/complete?stripe=tokenToVerifyPayment
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bodega/payment_method/stripe.rb', line 10 def checkout_url(success_url, cancel_url, params = {}) if params[:stripe] uri = Addressable::URI.heuristic_parse(success_url) uri.query_hash[:stripe] = params[:stripe] else uri = Addressable::URI.heuristic_parse(cancel_url) uri.query_hash[:stripe] = 'yes' end uri.to_s end |
#complete!(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bodega/payment_method/stripe.rb', line 21 def complete!( = {}) ::Stripe.api_key = Bodega.config.stripe.secret_key charge = ::Stripe::Charge.create( amount: order.total_cents, currency: 'usd', card: [:stripe], description: order.summary ) charge.id end |
#shipping? ⇒ Boolean
32 33 34 |
# File 'lib/bodega/payment_method/stripe.rb', line 32 def shipping? false end |