Looking for ideas from devs or anyone Re: Pos API callback

Hi All,

Looking for ideas here.

Our web app allows ordering of a voucher. To allow for easy square integration, I used the POS api/ POS app on the mobile device.

here is the step by step flow:

  1. Our mobile web app takes a user to a form they fill out.

  2. Once the form is filled, they tap a button that takes them to the pos app on their mobile device and passes all relevant data.

  3. The square transaction runs, is successful, and saves to the list of square transactions

  4. The POS app sends the callback url, which redirects the user back to our mobile web app and includes all the params related to the transaction.

  5. The web app parses this data and makes some api calls to aws to upload certain data to our dynamodb and send automated emails. When I get success responses from aws, I redirect the user back home in the mobile web app.

95% of the time, it works as I just described above.

First question- is this the correct way to be handling this scenario?

Second question and the problem:

In about 5% of cases, the square transaction is successful but the aws transactions never run. I’m not sure what is happening on the user side as I nor any of the testers have been able to reproduce this issue.

I am thinking one of the following:

  1. User is somehow interrupting the redirect back to the web app
  2. Since the callback opens in a new tab almost every time, there might be an issue with how devices handle tabs and tab management.
  3. Something else is happening to cause the square transaction to be logged as a success and the card to be charged, but the redirect to the app to fail.

Would appreciate any ideas

Thank you in advance

For the instances that the transaction is successful but the AWS transaction never runs is there a transaction_id in the callback? It is possible that a transaction_id isn’t present when the payment is being processed and won’t be in the response. In the case when one isn’t present you’ll need to use the Transactions API ListTransactions and parse the results for the matching client_id to get the transaction. :slightly_smiling_face:

Hi Bryan,

There are rare occasions where I’ve seen a lack of a transaction_id, but I still handle those situations in the code. There doesn’t necessarily need to be a transaction_id for the api calls to be made to aws.

Okay, is you application successfully getting the callback from Square in 100% of these failed processes? If so then your app should trigger the other operations. Also you mentioned that it opens a new tab each time. What browser are you using? Is it Safari or Chrome? If it’s Safari you may want to test changing the default browser to Chrome to see if you have the same results. :slightly_smiling_face:

I’m not sure. My guess is the application is not getting the browser open in the callback. I have several hundred users so OS, device, etc are all different with no way to check. The user base is also not very tech-savvy which complicates things further.

My biggest suspicion is that the browser never gets the callback, because even if some portion of the callback params was missing, there are other api calls that happen, and 0 of them execute afer the square transaction.

I don’t believe square is failing to send a callback.

Yeah, really hard to debug this one. Could you add logging for when the app switches and browser never gets the callback? :slightly_smiling_face: