Receipt URL in Payments API createPayment method Issue

I am trying to utilize the payment.receipt_url link that comes from the response on a Payments API createPayment request.

In my backend I immediately take the response I get from the Payments API, get the HTML from the receipt_url link and attempt to send it to the customer’s email. However When I received the email I get the following:

image

I had seen this problem in Sandbox and assumed it was just a Sandbox bug as I think I remember reading something about that being a known bug. You can see the issue at the following example Sandbox receipt_url:
https://squareup.com/receipt/preview/Jg6oJ8iUN56EZuzEdlEpBnrgfIfZY

However now that I have tried it in Production, I am still receiving the error.

I went to my server logs and clicked on the URL myself, and it worked fine! You can see that here:
https://squareup.com/receipt/preview/7pA79xUIKzS551juzpX0cxkHBy9YY

Is it possible I have to implement some sort of wait to allow the Square server to catch up before trying to grab the HTML from the URL? Or is there something else I am missing? I can’t find anything in the documentation about this.

Hm, I wasn’t aware a wait was necessary either. Do you know if this consistently happens in production now that you’ve moved there? Does this error come up every time you try to redirect to the receipt url?

FYI, I realized I needed to change my architecture anyways and it appears this has fixed the problem as it creates an implicit wait.

My original architecture had the user waiting for the email to be sent before getting a response back that their order was submitted which I have learned is BAD.

I made that emailing process asynchronous with a queue and another lambda dedicated to sending email confirmations. I put a small wait on the queue processing the messages and now the receipt comes through nicely each time.

1 Like

Hi ,

I implemented TERMINAL API and also the SquarePayform ( Website ) for a client a while ago . I recently made a change to also capture the returned receipt_url string and save it into a table so we can email later…

I seem to be getting a similar behaviour as the returned json string sometimes doesn’t contain the receipt_url , but when I go and query the payment id later it’s there .

Should I also be looking at implementing some form of wait ?

Regards,
Sam

I didn’t think a wait was necessary however if you do a retry is the URL in the next call? If so you could either do a wait or implement a retry method. :slightly_smiling_face: