The following (with a static amount value) works fine. How do I have the same with a $_POSTed value?
Edit: Content-Type should be application/json
but makes no difference.
The following (with a static amount value) works fine. How do I have the same with a $_POSTed value?
Edit: Content-Type should be application/json
but makes no difference.
Hi Ben,
I believe you would replace your 100 with:
"{{$_POST.amount_money.amount}}"
including the double quotes shown.
–Ken
Ken, thanks for the prompt reply.
When I insert your suggestion I get:
{"errors":[{"category":"INVALID_REQUEST_ERROR","code":"EXPECTED_INTEGER","detail":"Expected an integer value.","field":"amount_money.amount"}]}
Without the quotes I get:
{"code":0,"file":"\/var\/www\/vhosts\/hollandtrade.com.au\/httpdocs\/squareup\/dmxConnectLib\/lib\/App.php","line":65,"message":"Error parsing the JSON in define","trace":"#0 \/var\/www\/vhosts\/hollandtrade.com.au\/httpdocs\/squareup\/dmxConnect\/api\/sqpayment\/charge.php(8): lib\\App->define(NULL)\n#1 {main}"}
Also tried after changing the value to a number with the same results:
So the first error makes sense since it wants a number. I had a similar use case so perhaps the api I was sending to is more forgiving.
The second error is what forced me to use the double quotes in mine …that’s Wappler complaining. I never had to search for the right combo because a string worked for me.
Maybe experiment with escaping characters?
Thanks for your input. It’s driving me crazy. I’ll have a go at hat you have suggested.
I know the feeling…I’m like a dog on a bone with this stuff. But In this case, I wouldn’t spend too much more time until somebody in the know chimes in.
This should work but without the quotes.
Alternatively you could try:
{{$_POST.amount_money.amount.toNumber()}}
You are in luck Brian. If you lived within a 20 min radius I would come over to give you a great big hug.
{{$_POST.amount_money.amount.toNumber()}}
works like a charm.
The sad part is that I now feel so stupid for having battled this for hours while the nswer is so simple.
As we say in UK, sometimes you can’t see the wood for the trees. I find when i get dug into a hole like that, i need to walk away, relax a while and come back with a fresh pair of eyes.
Delighted I could help
Feeling the love Ben
As a newbie with Wappler, this confuses me. The POST json (or form) object is coming in as a number, Ben set the POST variable to be a number, yet he then has to convert toNumber()…It’s one of those things that I often ignore to try because, well, it’s already a number! I’m learning it is required more often than not though, so very helpful to see the solution here.