How do I get a callback url after a payment is made from a web view on a mobile app?

In my Flutter app, I’m integrating Square Payments for our subscription model. When users initiate a payment, they’re directed to a Square web view where they can complete the transaction. Afterward, Square sends a message indicating success or failure. However, since we’re operating within a web view, there’s no direct provision for a callback URL from Square to redirect users back to our app’s dashboard upon successful payment.

: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

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.

In your scenario, you might want to consider using the In-App Payments SDK provided by Square. This SDK allows you to create a seamless payment experience within your application, without the need to redirect users to a web view. The In-App Payments SDK provides a customizable card entry form and digital wallet entry buttons for Google Pay and Apple Pay. It generates a secure payment token that you can use to charge the payment using the Square Payments API on your backend server.

However, if you need to stick with the web view approach, you might need to implement a custom solution to handle the redirection back to your app. This could involve listening for the success or failure message from Square within your web view, and then programmatically navigating the user back to your app’s dashboard. Please note that this approach would require custom coding and is not directly supported by Square’s SDKs or APIs.

This answer was reviewed by @Bryan-Square.