Just want a confirmation

Greetings, all. I am in need of a quick question that I tried to get support via the main site chat on a Friday (bad idea) to get a project done today, but I haven’t found a straight answer. (The canned response I got didn’t even reference a FAQ.) I have a client who has annual dues that lead to registration into an event. All of the information attaches to a user record that is already part of the web site’s database, and all I need square to do is 1) take a credit card payment, 2) tell my site/page that it took the payment 3) give the site some sort of reference to tie it to the payment (does not have to be the token, if anything I’ll encrypt that much for db storage). I went to the site and grabbed the Web Payment code, which referenced a process of accepting the card input and handing back a token. Something tells me that the token itself isn’t the end of the process (that it must be processed on the back end), but I find myself disconnected from where to acquire that code for PHP. What I hope to accomplish is that my transaction log will trigger the callback link I have programmed into my account (which is what marks the account in the site database as paid), but if I instead need to trigger that callback in the JS via some other means, it isn’t explained very well.

Can anybody give me a hand with this? I’m not against a wall today, as the release for this is the end of the week, but I’d love to figure out what I’m missing here and get it done over the next 24-36 hours for the sake of my sanity and to learn (more like refresh) what I have missed over the past two or so years of using Square off-and-on that has changed.

Thanks in advance for your help.

So after reading through some of the helpful forum posts here, let me clarify where I’m at:

  • I can initialize the JS object
  • The card entry DOM appears just fine
  • I can get the Payment Successful message with a token

What I don’t get is the callback to fire, nor entry in the transaction log on the Square site.

When I started walking through the videos, which reference a git package, it has 2 try functions: one that captures the payment, and another that completes some sort of invoice or order transaction, neither of which make mention of the callback link that can be configured in the Square profile. I also keep seeing it mentioned, in passing, that this callback only fires in “Connect v2” and every piece of code I’ve ran into is marked “/v1?”

So after more digging, I noticed that my script never calls createPayment, so perhaps that’s why I am never getting the callback to fire. Still haven’t figured out if it will work, but that’s where I’m at now…

That’s correct, you’ll need to have your server side code call CreatePayment with the generated token. You’ll pass that in as the source_id. :slightly_smiling_face:

1 Like

…And where is that Documented, so I can make sure my JS reads back properly?

Here is the documentation on server side code. Also we have language specific examples that you can use. :slightly_smiling_face:

I finally just gave up & we went with another route altogether.

Okay, was there something unclear with our documentation? :slightly_smiling_face:

Yes. For starters, I am familiar with the Square of about 3 years ago. That support code appears to no longer exist, so I went into the Developer section and started looking through the APIs. From there, operations like createPayment show that they are hosted on Square itself (or the sandbox on Square itself), not my server, which given that it is a client’s server that is ill-equipped to support a whole payment server on its own, would have been really convenient to use with the rest of the Web Payment SDK, but it isn’t, or at least there is no Documentation making that plain.

On top of that, I’m not here to reinvent the wheel. All I need is to process a payment. The direction we went was to build Buttons / Links via the Square Dashboard. The hope was to pass an arbitrary reference number, or some sort of identifier, to the button hosted on Square, so that when the payment processed, we could tie that to the page full of user data that was entered for it. Unfortunately there isn’t any documentation talking about how to do that, either, as the button creates custom field classes that are randomly generated upon creation of the page.

Not only that, but even this solution does not give me what I originally wanted: the call back. All I wanted was a confirmation that {arbitrary reference number} paid upon completion. That’s it. Hey, Square? I’m sending you this {arn}. Draw me a page, take a payment, then hit this call back link to let my database update that {arn} paid. That’s it. Don’t “write up an order.” Don’t “create an invoice.” Don’t “keep track of the customer information.” Don’t “store the credit cards for later use.” These are annual dues. Rarely do people stick to the same card for everything, and auto-renewing a card like that is nonsense.

Then there is the matter of support. Chat was useless. I talked to 5 different reps who bounced me all over, when I specifically started at the start that I had a “developer” question. I eventually got a frustrating answer 24 hours later, which led me here. It hasn’t been much better. I’ve dug around into other people’s woes & got 3 replies to my own post deep before finally getting a reply reaching the same conclusion as I did. Nearly another day passed before I got a link to the same thing I was looking at two days prior.

Was the documentation not specific enough? Not if it was going to answer my question, which still hasn’t been answered. But hey, I’m only against a deadline that got sprung on me a week late. No worries. :roll_eyes:

That’s a shame. Square’s API is one of the best/easiest to work with. We utilize multiple payment provider APIs and they’re all a pain in the !@# except for Square. Their documentation and API explorer are very well done, too.

Dude… it really is pretty easy. You said you can render the payment DOM portions just fine so I’ll assume that’s all working fine.

Next when your UI button for “submit payment” gets clicked, it should be firing off a call to your web server (let’s say some kind of ajax call or whatever - I’m assuming this isnt a node process). For me, it calls a PHP file that handles all UI => Server requests. Inside that PHP file you need to make your REST API call (in PHP I use libcurl to execute this) to Square (the /v2/payments path), supplying all the relevant tokens, source_id, payment details, etc in the POST body. This is where you can add some kind of arbitrary identifier in the “note” field – but TBH this isn’t an asynchronous process, so I don’t see why you need to send anything with the createPayment call unless you really need to dig up that request data later, manually for some reason.

Anyway, the API call will execute and will immediately tell you if the payment was good or not, at which point you build your response text for your UI (who is still waiting on this pending ajax return).

The alternative here is that you create an invoice (manually or via api) for a particular user and use a webhook configuration where Square will push a notice to a URL of your choice when orders/invoices are paid or updated. This is the situation where you’d want to send some kind of unique identifier that you can then tie back.

Curious what wasn’t working for you. I’ve had no problems whatsoever using Square’s API - and this is my first foray into e-commerce.

Good luck

IKR!? I mean, I took all the online courses, went to webinars, and cranked out a great app for a pop-up taco stand in 2020 Q1, just before C-19 killed it at the project leader became a recluse. I went back and reviewed the code and was completely disappointed that it was no longer supported, everything had changed, and I was back to Square One (pun intended).

I ended up using a very heartbreaking workaround, and got the client most of what they needed. Unfortunately I’m going to have to keep my thumb on the pulse of the Dashboard and perhaps even export the transaction register daily to keep up, unless by some miracle that trips the callback routine I set up. I don’t understand why Square made this such a deep guarded secret. I asked the chat again yesterday, and they were supremely clueless about what I was asking for and seemed unwilling or unable to help. Well, these are annual dues that it now collects via the website, so maybe I’ll have better luck next year.

Yeah, nothing was more frustrating than being right up to the finish line and not finding the resources to finish that off. I think that had I just set up my own “createPayment” that used PHP to call the cURL to Square’s API that it would have worked, but since support was so sparse and time was short, I was forced to cut bait. When I have a larger window, I’ll try setting something up with my own Square account and see if what I’m thinking (and also what you are suggesting) does the trick. I’ll bookmark this thread & post how that goes. Thanks!

1 Like

@javadewd The Square Chat Success team isn’t properly trained on our developer tools. There are only three places you should be reaching out to ask developer questions. They’re listed on or Developer Documentation. They are:

The Contact Support link will take you to a form that goes directly into our queue so you get the right answer the first time.

As for your setup your half way there. You’ve got the SDK running and you’ve got the token. Now all that’s needed is the server side code to process the payment. What language are you using for your server side code? :slightly_smiling_face:

PHP, but again, the client’s server is not equipped to install Git. I ended up going a completely different route. We tested it using Online Checkout buttons. It still won’t trip a callback, which sucks, because the client will have to monitor the orders on their end, instead of letting the site’s database mark them auto-magically as paid (like I’ve been asking from jump here!), but these are annual dues, so… Better luck next year…???

Online Checkout buttons trigger webhooks. You can listen to payments or orders webhooks to automatically mark them as paid. :slightly_smiling_face:

I’m looking at the Webhooks & API logs from the Developer Dashboard, and we’ve already had a few folks go on and pay their dues, but there is nothing there in the logs. No data whatsoever.

Do you have a payment_id that didn’t trigger an event? :slightly_smiling_face:

We’e had five completed orders so far and zero API & Log events…

Do you have the Square generated IDs so we can take a look? Or what’s your application ID? :slightly_smiling_face: