[web2py] Re: web2py using "foreign" form

2017-03-23 Thread Scott Hunter
There is no `request.post_vars`, and thus no 
`request.post_vars.stripeToken`, when the controller the form was submitted 
to executes.

I cannot see any such hidden field in the DOM, but there not being one 
would explain why it isn't getting back to me.

Further poking around, I found a section (not displayed) of class 
stripeErrorMessage, the contents of which says 

Sorry, there was a problem loading Checkout.

If this persists, please try a different browser.
  
But I'm thinking that is there to be displayed IF there is a problem, as 
the form comes up fine and responds to the credit card number appropriately 
(except for giving me back the token).

On Thursday, March 23, 2017 at 6:08:59 PM UTC-4, Anthony wrote:
>
> 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:
>>
>> > "POST">
>>   > 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">
>>   
>> 
>>
>> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: web2py using "foreign" form

2017-03-23 Thread Anthony
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:
>
>  "POST">
>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">
>   
> 
>
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: web2py using "foreign" form

2017-03-23 Thread Scott Hunter
That's what I would have thought, but if I have the following in my view:


  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">
  


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).

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).

Even more confused now,
Scott

On Thursday, March 23, 2017 at 9:28:50 AM UTC-4, Anthony wrote:
>
> If the form is submitted via a POST request, everything will be in 
> request.post_vars (request.post_vars is not specific to web2py-generated 
> forms -- it is simply where posted data are made available).
>
> Anthony
>
> On Thursday, March 23, 2017 at 4:52:56 AM UTC-4, Scott Hunter wrote:
>>
>> Suppose I have a form whose contents are generated by a script, and I do 
>> not know what those contents are; in particular, I may not know what the 
>> fields are within that form, but I certainly have no control over them.  I 
>> can specify the controller that I want that form to submit to (via the 
>> `action` attribute).  Is there a way, within that controller, I can get the 
>> content of that submission (what would show up in `request.post_vars` for a 
>> web2py-generated form)?  Does it help if I know the names of these fields?
>>
>> - Scott
>>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: web2py using "foreign" form

2017-03-23 Thread Anthony
If the form is submitted via a POST request, everything will be in 
request.post_vars (request.post_vars is not specific to web2py-generated 
forms -- it is simply where posted data are made available).

Anthony

On Thursday, March 23, 2017 at 4:52:56 AM UTC-4, Scott Hunter wrote:
>
> Suppose I have a form whose contents are generated by a script, and I do 
> not know what those contents are; in particular, I may not know what the 
> fields are within that form, but I certainly have no control over them.  I 
> can specify the controller that I want that form to submit to (via the 
> `action` attribute).  Is there a way, within that controller, I can get the 
> content of that submission (what would show up in `request.post_vars` for a 
> web2py-generated form)?  Does it help if I know the names of these fields?
>
> - Scott
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.