|
|
|
@ -147,17 +147,6 @@ class StripeBackend(BackendBase):
|
|
|
|
|
subscr.backend_data['subscription_id'] = sub_id
|
|
|
|
|
subscr.save()
|
|
|
|
|
|
|
|
|
|
payment = subscr.create_payment()
|
|
|
|
|
payment.status = 'confirmed'
|
|
|
|
|
payment.paid_amount = payment.amount
|
|
|
|
|
payment.backend_extid = None
|
|
|
|
|
#payment.save()
|
|
|
|
|
|
|
|
|
|
payment.user.vpnuser.add_paid_time(payment.time)
|
|
|
|
|
payment.user.vpnuser.on_payment_confirmed(payment)
|
|
|
|
|
payment.user.vpnuser.save()
|
|
|
|
|
payment.save()
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
from payments.models import Payment
|
|
|
|
|
payment = Payment.objects.filter(backend_extid=session['id']).get()
|
|
|
|
@ -199,8 +188,8 @@ class StripeBackend(BackendBase):
|
|
|
|
|
if not subscr:
|
|
|
|
|
# the subscription does not exist
|
|
|
|
|
# checkout.confirmed event will create it and handle the initial payment
|
|
|
|
|
return True
|
|
|
|
|
# raise Exception("Unknown subscription for invoice %r" % invoice['id'])
|
|
|
|
|
# return True
|
|
|
|
|
raise Exception("Unknown subscription for invoice %r" % invoice['id'])
|
|
|
|
|
|
|
|
|
|
# Prevent making duplicate Payments if event is received twice
|
|
|
|
|
pc = Payment.objects.filter(backend_extid=invoice['id']).count()
|
|
|
|
@ -216,7 +205,7 @@ class StripeBackend(BackendBase):
|
|
|
|
|
payment.backend_sub_id = invoice['subscription']
|
|
|
|
|
else:
|
|
|
|
|
payment.backend_sub_id = invoice['subscription']['id']
|
|
|
|
|
payment.backend_data = {'event_id': event['id']}
|
|
|
|
|
payment.backend_data = {'event_id': event['id'], 'sub_id': payment.backend_sub_id}
|
|
|
|
|
payment.save()
|
|
|
|
|
|
|
|
|
|
payment.user.vpnuser.add_paid_time(payment.time)
|
|
|
|
|