From 26b249d48d94994cb7658ad686547a29d33b706a Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Thu, 22 Sep 2016 11:44:30 +1000 Subject: [PATCH] Always immediately capture payments. --- registripe/views.py | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/registripe/views.py b/registripe/views.py index bd54a528..d6eca5b6 100644 --- a/registripe/views.py +++ b/registripe/views.py @@ -105,32 +105,26 @@ def process_card(request, form, inv): conference.title, inv.invoice.id ) - try: - charge = actions.charges.create( - amount_to_pay, - customer, - currency=CURRENCY, - description=description, - capture=False, - ) + charge = actions.charges.create( + amount_to_pay, + customer, + currency=CURRENCY, + description=description, + capture=True, + ) - receipt = charge.stripe_charge.receipt_number - if not receipt: - receipt = charge.stripe_charge.id - reference = "Paid with Stripe receipt number: " + receipt + receipt = charge.stripe_charge.receipt_number + if not receipt: + receipt = charge.stripe_charge.id + reference = "Paid with Stripe receipt number: " + receipt - # Create the payment object - models.StripePayment.objects.create( - invoice=inv.invoice, - reference=reference, - amount=charge.amount, - charge=charge, - ) - except StripeError as e: - raise e - finally: - # Do not actually charge the account until we've reconciled locally. - actions.charges.capture(charge) + # Create the payment object + models.StripePayment.objects.create( + invoice=inv.invoice, + reference=reference, + amount=charge.amount, + charge=charge, + ) inv.update_status()