How can I break out of the Admin to a payment gateway? I've tried form_url='billing:payment_view'  in SubstanceAdmin.change_view() unsuccessfully.

I can semi-break out of the admin and get the beginning of a payment happening with the following ...

SubstanceAdmin.change_form_template = payment.html (which has Stripe js and necessary hidden fields)
or
./templates/admin/substance/substance/change_form.html (identical to payment.html except it calls block.super at the end to render the rest of the admin page)

SubstanceAdmin.change_view() which collects the contextual data required for either template

IngredientsInline.form (inherits  admin.StackedInline.form) for all the hidden fields for each ingredient.

With all that, if an ingredient hasn't been paid for, the billing.Subscription record won't have a Stripe token so the Admin will launch the payment page. On entering credit card detail and pressing the button, Stripe happily takes the money and issues a token. BUT the Admin then barfs with ...


RuntimeError at /admin/substance/substance/1442/change/payment

You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to localhost:8000/admin/substance/substance/1442/change/payment/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.

... If I add a slash in the browser address bar and press Enter the next problem emerges ...


ValueError at /admin/substance/substance/1442/change/payment/change/

invalid literal for int() with base 10: '1442/change/payment'

... which tells me the Admin is hoping for /admin/substance/substance/1442/

I don't know where to go now.

My preference would be to leave the Admin somehow and handle the payment externally with my
billing.payment_view() and billing.success_view() then at the end find a way to give that hoped-for url to the server and expect the substance to come up normally in the admin.

Any advice will be greatly appreciated. Happy to show any code you might want to see.

Many thanks

Mike







--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f8061a7d-27b5-c929-c364-d8870829ad3e%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to