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?