1
0
mirror of synced 2026-08-05 22:56:55 +00:00

Working checkout_controller.rb that charges Stripe

* Add billing address setting
This commit is contained in:
Chris Beach
2017-10-19 23:50:21 +01:00
parent 20a38095dd
commit d563cd1ddd
7 changed files with 117 additions and 36 deletions
+12 -8
View File
@@ -1,4 +1,3 @@
module DiscourseDonations
class Stripe
attr_reader :charge, :currency, :description
@@ -9,14 +8,19 @@ module DiscourseDonations
@currency = opts[:currency]
end
def checkoutCharge(amount, token)
@charge = Stripe::Charge.create(
:amount => amount,
:currency => opts[:currency],
:description => @description,
:source => token,
def checkoutCharge(email, token, amount)
customer = ::Stripe::Customer.create(
:email => email,
:source => token
)
@charge
charge = ::Stripe::Charge.create(
:customer => customer.id,
:amount => amount,
:description => @description,
:currency => @currency
)
charge
end
def charge(email, opts)