Grabbing the OrderId parameter from a sandbox Create Payment Link flow

Hello!

I’m working on an order flow for my application where I allow users to add items to a cart, send them to Square for checkout using the create payment link and then have them return to my site using the redirect parameter.

In production, Square adds 2 parameters to the redirect URL, orderId and transactionId. While in the sandbox environment, it seems like those parameters are not appended to the redirect URL and it’s causing me some issues being able to look up the order in Square.

I also don’t see the order id listed in the sandbox checkout flow anywhere (to my knowledge) making it difficult to link the success screen (my redirect) to the order that just took place in the sandbox.

Am I missing something for how to get the order id in sandbox? I’m trying to avoid a situation where I have different application code running in development vs production environments because the redirect parameters are handled differently.

If this information isn’t available in the sandbox checkout flow - I’m likely forced to do something hacky where I look up the most recent order using the Square API and append the parameters myself while in the sandbox environment.

Appreciate any help on this, thank you!

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Square Order Checkout
Get Developer Credentials
Configure the Order-Ahead Sample Application

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

This is still a bit hacky but I found that when in the sandbox payment flow, you can open the developer console and grab the order id off bootstrap.order.id

I will end up using in the interim. Wanted to share in case it helps anyone else.

At this time the sandbox redirect doesn’t work because it’s an incomplete experience. If you want you can test the redirect in production with a $0 payment link. We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team. :slightly_smiling_face:

I recently developed an application which creates payment links with Square.
I couldn’t see in any documentation that Square would add those query parameters to the end of the URL, so I have a workaround.

  1. Create payment link via API
  2. Update payment link via API with response from previous request which included the created order ID.

Until a payment was placed in production, I didn’t know Square would add them, as the Sandbox never did, and I didn’t find it documented anywhere.
Now I know in production, that Square DOES add those parameters, I’ll remove my workaround from my application.

Square please document this if it isn’t already.

The $0 payment link is a good tip, I’ll use that next time!

I’m reaching out to our Documentation team about this. I know it was documented at one time and I’m truly sorry you ran into this and spent the time to build a workaround. :slightly_smiling_face:

1 Like