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.