In our system, we give customers a fixed amount of time to complete their transaction after adding a product in cart and proceeding to checkout. If the customer doesn’t make a payment before the timer expires, we cancel the order.
My question is:
How can I prevent customers from making the payment on the Square checkout payment page created by the v2/online-checkout/payment-links API?
I found this API that deletes the payment link (/v2/online-checkout/payment-links/{id}), which prevents the customer from completing the payment. However, the issue is that the Square payment page isn’t redirecting the customer back to my website.
In short: I want to ensure that customers cannot complete the payment on the Square payment page after a fixed amount of time, and then the Square payment page redirects customers back to my website. This is crucial.
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
Checkout API
Payment API: Process Online and In-Person Payments
Delayed Capture of a Card Payment
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.
The Square Checkout API currently does not support a built-in timer functionality to automatically expire a checkout page after a certain amount of time. However, you can implement this functionality on your own server.
You can set a timer on your server for each checkout session. When the timer expires, you can call the DeletePaymentLinks endpoint to delete the payment link. This will prevent the customer from completing the payment on the Square checkout page.
As for redirecting the customer back to your website, you can specify a redirect URL when creating the checkout page using the redirect_url field. After the buyer completes the checkout flow, Square will redirect them to this URL. However, please note that this redirection will happen only after the buyer completes the checkout flow, and not when the checkout page is cancelled or deleted.
If you want to redirect the customer back to your website when the checkout session expires, you would need to implement this on your own website or application. For example, you could implement a timer on your website that corresponds to the checkout session timer on your server. When the timer on your website expires, you could automatically redirect the customer to a different page.
This answer was reviewed by @Bryan-Square.
I already have timer and timeout handling functionality on my website. But if the customer doesn’t get redirected back to my website from the Square payment page, how will that work? The issue is that the customer stays on the Square payment page after deleting the payment link using the delete API.
Hey @kishanv! Unfortunately this isn’t something that the the Checkout API supports currently; there is not a mechanism for redirecting customers upon payment link deletion.
Hi,
Is there any other way to do it?
The requirement is that if a customer tries to complete the payment after a certain fixed time, the payment should fail. The customer should not be charged and should be redirected back to my website.
At this time the redirect for a payment link only works on a successful payment. 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. 