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/paymentYou 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 -- |
- Admin form_url breakout problem Mike Dewhirst
- RE: Admin form_url breakout problem Matthew Pava
- Re: Admin form_url breakout problem Mike Dewhirst
- RE: Admin form_url breakout problem Matthew Pava
- Re: Admin form_url breakout problem Mike Dewhirst
- RE: Admin form_url breakout problem Matthew Pava
- Re: Admin form_url breakout proble... Mike Dewhirst
- Re: Admin form_url breakout pr... Mike Wyatt
- Re: Admin form_url breakout proble... Mike Dewhirst
- RE: Admin form_url breakout pr... Matthew Pava
- Re: Admin form_url breakout pr... Mike Dewhirst