Hello mike i hope you are doing well can we make a video call to solve this problem i can be helpfull
On Sat, 7 May 2022 at 01:56, Mike Dewhirst <[email protected]> wrote: > OK - don't worry about this for the time being. The problem is obviously > where I haven't yet looked. So I'm now going to simplify every bit of > code/html/css following the successful acquisition of the Stripe token > to see if it suddenly starts working. > > M > > On 6/05/2022 6:07 pm, Mike Dewhirst wrote: > > I'm obviously at fault but I'm not smart enough to figure it out. Any > > help is appreciated. > > > > The mechanism below exhibits no errors at the Stripe end. Stripe > > returns the necessary payment token. I have tried brutally stripping > > of the "/change/payment" and while it silences the error, the form > > just re-shows itself. > > > > <aside> I see a similar problem in 32-bit iOS Safari which doesn't > > seem to like the svg tick symbol displayed in the Admin change screen > > success message. The only symptom is the tick doesn't appear and the > > user is none the wiser. But it generates an error email Field 'id' > > expected a number but got '55/img/icon-yes.svg' </aside> > > > > > > ValueError at /admin/chemical/chemical/20/change/payment/change/ > > > > Field 'id' expected a number but got '20/change/payment'. > > > > Request Method: GET > > Request URL: > > http://localhost:8088/admin/chemical/chemical/20/change/payment/change/ > > Django Version: 3.2.13 > > Exception Type: ValueError > > Exception Value: > > > > Field 'id' expected a number but got '20/change/payment'. > > > > Exception Location: > > > D:\Users\mike\envs\xxai\lib\site-packages\django\db\models\fields\__init__.py, > > > line 1825, in get_prep_value > > Python Executable: D:\Users\mike\envs\xxai\Scripts\python.exe > > Python Version: 3.8.3 > > > > > > Here is the ChemicalAdmin.change_view(). I filled in the docstring a > > year ago when debugging previously. > > > > def change_view(self, request, object_id, form_url="", > > extra_context=None): > > """ > > self = ChemicalAdmin > > object_id = chemical > > form_url is passed through to self.render_change_form() via > > self.get_preserved_filters(request) and then added to context > > extra_context = dict of apps, models, admin_urls and > > permissions. Ensure > > self.change_form_template = None so next time it doesn't use > > payment.html > > """ > > extra_context = extra_context or {} > > self.change_form_template = None > > chemical = Chemical.objects.get(id=object_id) > > intro = chemical.get_introduction() > > if intro and not chemical.token: > > if intro.category in CHARGE: > > self.change_form_template = "payment.html" > > context = collect_gateway_context(chemical) > > extra_context.update(self.admin_site.each_context(request)) > > extra_context.update(context) > > self.admin_site.admin_view( > > payment_view(request, chemical, > > context=extra_context) > > ) > > return super().change_view(request, object_id, form_url, > > extra_context) > > > > And the url config ... > > > > re_path(r"invoice/(?P<pk>\d+)/$", billing_views.invoice_view, > > name="invoice_view"), > > re_path(r"payment/$", billing_views.payment_view, > > name="payment_view"), > > re_path(r"success/$", billing_views.success_view, > > name="success_view"), > > > > And the payment.html form ... > > > > <form action="payment" method="POST"> > > {% csrf_token %} > > {% if form.errors or form.non_field_errors %} > > {{ form.errors }} > > {{ form.non_field_errors }} > > {% endif %} > > {% for field in form %} > > {% if field.name == "chemical_id" %} > > <input type="hidden" name="chemical_id" > > id="id_chemical_id" value="{{ chemical.id }}" /> > > {% else %} > > {{ field }} > > {% endif %} > > {% endfor %} > > <script > > src="https://checkout.stripe.com/checkout.js" > > class="stripe-button" > > data-key="{{ data_key }}" > > data-amount="{{ data_amount }}" > > data-name="{{ data_name }}" > > data-description="{{ data_description }}" > > data-image="{{ data_image }}" > > data-locale="{{ data_locale }}" > > data-currency="{{ data_currency | lower }}" > > data-zip-code="true" > > data-panel-label="Pay"> > > </script> > > </form> > > > > Thanks > > > > Mike > > > > > > > > > -- > Signed email is an absolute defence against phishing. This email has > been signed with my private key. If you import my public key you can > automatically decrypt my signature and be sure it came from me. Just > ask and I'll send it to you. Your email software can handle signing. > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/e8daba7f-13aa-6f84-80d3-9010ec16389d%40dewhirst.com.au > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAE3Dc2NwGvzg6gJvFcVek5RZr1mCSfb_Crqt6ufk_9Yy5dMZaA%40mail.gmail.com.

