1
0
mirror of synced 2026-08-06 15:16:56 +00:00

check subscription response

This commit is contained in:
Rimian Perkins
2017-05-23 20:14:28 +10:00
parent 49bcd392d4
commit 904cd4d1d9
2 changed files with 3 additions and 9 deletions
@@ -35,7 +35,7 @@ module DiscourseDonations
charge = payment.subscribe(email, params)
end
if charge['paid'] == true
if (params['amount'].present? && charge['paid'] == true) || charge['status'] == 'active'
output['messages'] << I18n.t('donations.payment.success')
output['rewards'] << { type: :group, name: group_name } if group_name
+2 -8
View File
@@ -24,14 +24,8 @@ module DiscourseDonations
end
def subscribe(email, opts)
customer = ::Stripe::Customer.create(
email: email,
source: opts[:stripeToken]
)
@subscription = ::Stripe::Subscription.create(
customer: customer.id,
plan: opts[:plan]
)
customer = ::Stripe::Customer.create(email: email, source: opts[:stripeToken])
@subscription = ::Stripe::Subscription.create(customer: customer.id, plan: opts[:plan])
@subscription
end