This is the page that is producing the errors. The one with the hard-coded nonce.
So you want it to redirect? Can you put breakpoints in and step through all the steps for creating a payment.
- Ensure
tokenize()
works and your getting thenonce
- Make sure that your front end is correctly passing the generated values to your server
- Your server should validate that it has all the correct values and call
CreatePayment
and await the response from Square - On payments success then send results to your front end with payment complete message
I took away the redirect and it says payment successful. That’s all it says. If I could do it all via the script on the first page, that would be awesome. It redirects so it can take the person’s information and update the database. Can it all be done on one page, so the redirect only updates the database?
Yes, it can all be done on one page but the call to CreatePayment
has to be on your server side.
Did you look at the examples that I posted? Are any of them even close to what Square needs to process the payment?
This is my server side code to create a payment. What is missing? Besides the card_nonce hard-coded value. Still not sure how I can create one or where I create one.
<cfset params = {
“card_nonce” = “CBASEFO1lvpcxGS_FzAJQNrOuuwgAQ”,
“amount_money” = {
“amount” = 100,
“currency” = “USD”
},
“idempotency_key” = CreateUUID(),
“delay_capture” = false,
“location_id”: “L1HB3S2965R0W”
}>
<cfif IsJson(response)>
Again, a bunch of code is missing because it won’t copy and paste correctly here.
Thank you.
Please never share an access token. All other values are safe to share.
That is the code that you run after tokenize
. You’ll pass the generated nonce
as the source_id
. The result of that server side request will be a payment or a declined payment. You can then redirect the customer if needed.
Even if it’s a sandbox token? And … I can’t find an example anywhere of where to put the server side code. Are you saying that the server side code runs after a successful payment message? I don’t think I can put that code within javascript.
Yes, even if it’s sandbox.
Right, you can’t do that in javascript. You have to send the generated nonce you your server code that’s not in javascript. That code has to call CreatePayment
.
Hhhhmmmm… I’m not able to find any examples of this online anywhere. We might have to use a different approach, where there’s some specific documentation for the language.
There isn’t a backend ColdFusion example but our documentation has all the frontend javascript in it.
Maybe we should setup a meeting to go over this. Are you available tomorrow to go over this?
Yes! What time? I’m in Minnesota. CST. A zoom meeting?
Does 11:30am CST work? If so I’ll message you a link for the meeting.
Yes!!! Thank you! Are we having a zoom or chrome remote desktop?
Just sent the link to the Google Meets meeting tomorrow.
Just got the email - thank you! Will I be able to share my screen with you?
Where did you send the link? I’m not the Square account holder.
Yes, we will be able to screen share. I sent it to the email that you created this Forum account.
Hi, Bryan. No luck in getting CF to work. I’m going to check with the host to see if they could support PHP on the same site as the rest of the application. If this host can support both languages, then I think we might be okay. Now … where can I find a copy of a complete example of the process in PHP? I’d like to start with that and see if I can get that to run/work on the site.
Thank you for all your help!
Okay, sounds good. Here’s the link to the PHP example.