#### Stripe Creditcard
This method uses the Stripe creditcard system. This uses the Stripe
-"Checkout" system, which uses a mix of server-side code and hosted
-javascript, with the actual payment form entirely hosted by Stripe.
+"Checkout" system. This uses hosted payment forms at Stripe.
#### Trustly Banktransfer
# user has multiple tabs open.
return HttpResponseRedirect("/invoices/{0}/{1}/".format(invoice.id, invoice.recipient_secret))
- # Else session exists but is not completed, so send it through back to Stripe
- # again.
+ # Else session exists but is not completed, so fetch the session and send the user
+ # back to Stripe.
+ StripeLog(message="Re-fetching session {0} (id {1}) for another try.".format(co.id, co.sessionid),
+ paymentmethod=method).save()
+ r = api.secret('checkout/sessions/{}'.format(co.sessionid))
+ sessionurl = r.json()['url']
except StripeCheckout.DoesNotExist:
# Create a new checkout session
co = StripeCheckout(createdat=timezone.now(),
return HttpResponse("Unable to create Stripe payment session: {}".format(r.status_code))
j = r.json()
co.sessionid = j['id']
+ sessionurl = j['url']
co.paymentintent = j['payment_intent']
co.save()
- return render(request, 'stripepayment/payment.html', {
- 'invoice': invoice,
- 'stripekey': pm.config('published_key'),
- 'sessionid': co.sessionid,
- })
+ # Redirect to the stripe payment URL
+ return HttpResponseRedirect(sessionurl)
def invoicepayment_results(request, paymentmethod, invoiceid, secret):
+++ /dev/null
-{%extends "navbase.html" %}
-{%block title%}Invoice payment{%endblock%}
-{%block extrahead%}
-<script src="https://js.stripe.com/v3/"></script>
-<script type="text/javascript">
-var stripe = Stripe('{{stripekey}}');
-stripe.redirectToCheckout({
- 'sessionId': '{{sessionid}}'
-}).then(function (result) {
- alert('Redirection to Stripe for payment failed.');
-});
-</script>
-{%endblock%}
-{%block content%}
-<h1>Invoice payment</h1>
-<p>You are being redirected to Stripe to complete the payment.</p>
-
-{%endblock%}