On Thursday, March 23, 2017 at 10:20:29 AM UTC-4, Scott Hunter wrote:
>
> That's what I would have thought, but if I have the following in my view:
>
> <form action="{{=URL(c='pay',f='charge',args=request.args)}}" method=
> "POST">
>   <script
>     src="https://checkout.stripe.com/checkout.js"; class="stripe-button"
>     data-email="{{=auth.user.email}}"
>     data-key="{{=pk}}"
>     data-amount="{{=amount}}"
>     data-name="UKI TMS"
>     data-description="{{=description}}"
>     data-image="
> https://stripe.com/img/documentation/checkout/marketplace.png";
>     data-panel-label="{{=label}}"
>     data-locale="auto">
>   </script>
> </form>
>
> and the following in my `pay` controller:
>
> def charge():
>     return DIV("%r"%request,_class="well")
>
>
>
> the displayed value of `request._post_vars` is None.  Same thing if I 
> don't specify `args` in the action URL, or leave the action URL empty (and 
> display `request.env` from the appropriate controller).
>

That's not the way to check for posted variables. request._post_vars is 
populated lazily the first time request.post_vars (or request.vars) is 
accessed. You should simply check directly for 
request.post_vars.stripeToken (which is the only field that will be posted 
to the controller).
 

> Poking around the DOM, I see that there is *another* form inside of mine, 
> and this is the form which contains the "submit" button (along with all of 
> the input fields).
>

Notice in your code you are loading a Stripe Javascript script. Once 
loaded, that script generates the form you are seeing in the DOM. That form 
is what the user fills out, and it is submitted directly to Stripe, not to 
your web2py server. Stripe then returns the "stripeToken" to the browser, 
adds it to a hidden field within your form, and submits that form to the 
web2py controller.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to