How to test the redirect URL in the createPaymentLink

I started developing a week ago with the checkout api, and I didn’t realize that the createCheckout method was deprecated recently - especially since the sample code that the Square developer website that is supposed to help new users still uses this method. However, when I was testing with createCheckout, I got everything working correctly. I was getting a response, and the URL in the response let me go to a sandbox payment page, and actually test the payment. Most importantly, once the payment was completed, it would redirect to my redirectURL specified in the checkout request, and I could develop that page with the GET data that came from the checkout page. The checkout link generated by the createCheckout endpoint looked like this

https://connect.squareupsandbox.com/v2/checkout?c={generated checkout ID}&l={location id}

And after the payment was processed, it would redirect back to my website with this URL

https://www.mydomain.com/subscribe-confirmation.php?checkoutId={generated checkout id}&transactionId={transaction id}

And on my confirmation page, I could take the {transaction id} from the GET URL, and I could use the retrieveOrder method to get the order information and then process that data on my site in whatever way I wanted. And it all worked just fine.

But the createCheckout endpoint is deprecated, and I’m being instructed to start using the createPaymentLink endpoint. I have modified all of my code for the checkout api to use the createPaymentLink endpoint, and I have it all working. I get a response, including an order id and a URL. But the links from the createPaymentLink endpoint look like this now

https://sandbox.square.link/u/{payment link id}

And when I try to go to that link to test the payment and redirection back to my site, it instead redirects me to a link that looks like this

https://connect.squareupsandbox.com/v2/online-checkout/sandbox-testing-panel/{merchant id}/{unknown generated id}

Instead of showing me the actual checkout page that a customer would see, it says “Checkout API Sandbox Testing Panel” at the top. It shows the same order id and URL that comes in the createPaymentLink response and says “You’ve completed a CreatePaymentLink request and received the following in the response”. There are only 2 options on that page, “Next” and “Preview Link”. If I click the “Preview Link” button, it opens a new page showing me what the customer would see if it were live, but all of the payment info is grayed out and I can’t actually test the payment. Most importantly, since I can’t test the payment, I can’t test the redirect back to my site, and I have no idea what will actually happen when the user is sent back to my site. I assume that they’ll go to my redirectURL, but how am I supposed to know what will be sent through either GET or POST data? And if I don’t know what will be sent, how am I supposed to know which order was actually processed and is redirecting back to me so I can develop the confirmation page?

Also, if I click the “next” button on that page, it says “Test Payment Acceptance” at the top, and I have a “Test Payment” and a “Preview Link” button. The “Preview Link” button does the exact same thing it did on the previous page. If I click the “Test Payment” button, it pretends that the user entered payment info and submitted the payment successfully, and then goes to a “Checkout Complete” page that shows all of this

Checkout Complete
Your test payment was successful. This has triggered the following actions.
Order Confirmation|Customer redirected to: https://www.domain.com/subscribe-confirmation.php
Order state|OPEN
Tender.id|Added to Order
Webhooks Triggered|order.updated, payment.updated
Square Receipt|Sent to email on file.
Customer Directory|Customer created in the seller’s customer directory.
Seller Dashboard|The Order is shown in Order Manager in Square Dashboard. The Payment is shown in Transactions.
The tender.id added to the order is also the ID of the Payment object created. You can use the Payments API to access payment details.
This transaction is now complete.

That’s all great, but the link shown for “customer redirected to…” just goes to the “subscribe-confirmation.php” page on my domain. If I click on the link, it opens a new page and goes to the correct link, but with no GET or POST info included. So again, how am I supposed to develop a confirmation page with no information returned from the Square checkout page? How do I actually test a createPaymentLink checkout page while in Sandbox so I can see what gets sent back to the redirectURL page so I can actually develop a page that processes the order on my site and does the necessary email / database operations that I need it to?

1 Like

At this time this is the expected sandbox behavior with the payment links. 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.

When a payment is completed and the customer is redirected Square will append the following to your URL:

https://www.redirect_url.com/?transactionId=tpEkkmWCsgZFGz9hcj88qeyreXEZY&orderId=tpEkkmWCsgZFGz9hcj88qeyreXEZY

:slightly_smiling_face:

Thank you Bryan, this helps a lot.

Definitely forward a note to the developers that without that information above, it would be impossible to develop the page at the redirect url while still in sandbox mode.

I’ll definitely pass this along. :slightly_smiling_face:

Bryan, I’m developing the payment confirmation page that the redirectUrl will send the user to after a successful payment. You said that they would be redirected to the redirectUrl with the transactionId and oderId included like this

https://www.redirect_url.com/?transactionId=tpEkkmWCsgZFGz9hcj88qeyreXEZY&orderId=tpEkkmWCsgZFGz9hcj88qeyreXEZY

Since there’s no way for the sandbox to create a real redirect back to my site, I’m developing on just the assumption of receiving the link you gave me above.

When I actually go to the payment link that is generated by the sandbox, I see the orderId on that page (right now that’s the only way I can actually get an orderId to even try to develop with). I’ve been able to develop and test the confirmation page which creates a request for the order details using the orderId I’m assuming I’ll get in the URL. That’s all working fine so far, but the sandbox payment links don’t ever show a transaction id, so where would I get that information when I’m doing my developing in sandbox mode?

And what data is actually included in a transaction object that I might want or need? I’m using quick_pay in my create payment link because I just want the user to go to Square’s site to pay a specific amount, and I’m passing a single dollar value and a single item title, and then I want them redirected back to me confirming that they’ve paid. Is there anything in the transaction object that I would use? It looks like there is a transactions API, but all of the endpoints (including retrieve transaction) are deprecated. So why does the new createPaymentLink endpoint return a transactionId at all?

The Transactions API is deprecated. We don’t recommend developing an integration that uses that API cause it will be retired in the future. You should use the Orders API and the Payments API.

With the payment links if the customer is redirected to the redirect_url you can be sure that the payment was successful. All payments that fail with the payment links the customer won’t be redirected. Instead they will be prompted to re-enter their card information. Once redirected you can use the order_id to RetrieveOrder. In the response will be the payment_id. You’ll use that ID to call GetPayment for the payment details. :slightly_smiling_face:

1 Like

Dear Square -

Is there any update on this? I just spent a bunch of time trying to convert to the new method, and I tripped over the same issue: The Sandbox mode no longer takes you to a payment page, but to this interstitial debugging sequence. And, at the end, the system takes you back to your app WITHOUT the order, ref, or transaction IDs.

This is making it impossible to develop, debug or test against the new system effectively.

I notice that this topic is 8 months old, and yet it still seems to be a problem? Is there any timeline on getting the sandbox test pages to actually add the correct parameters to the redirect URL as documented?

Hi @GlenBarney, no updates here at this time — you’ll still need to use a Production link to append query parameters to the redirect URL.

Thanks Josh! I appreciate the quick reply! Please do let development know about my “vote” for this feature in whatever way might be appropriate!

Thanks,
Glen

Using the Checkout API, and setting a redirect URL I only get these vars in the reponse…

  • checkoutId
  • referenceId
  • transactionId

It used to send an orderId but that doesnt seem to be showing any more. Has something changed?

Is this with our CreatePaymentLink? Or is this with the deprecated CreateCheckout? :slightly_smiling_face: