In an Android app, I'm working on, we have a problem regarding payments.
When the user wants to place an order, we do an API request that will return a payment URL and a payment ID. The URL is the webpage we will open for the payment, the ID is used to retrieve the status of the payment from our API. When we request the status of the payment from our API, it will return either "success", "cancelled", or "pending". When the payment has completed or when the user clicks the cancel link inside the payment webpage, the user will be redirected to a URL that is handled by the app. If the user is redirected, we will proceed to either order confirmation page (when payment was successful) or back to the checkout page (when payment was cancelled by clicking the cancel link in the webpage). Payment webpage is opened using a Chrome Custom Tab.
The problem occurs when the user closes the browser before finishing or cancelling the payment and then returns to our app. When the user comes back to our app without being redirected by the browser, the app will do a status request to check whether we should proceed to the order confirmation page. When the browser is closed, one of the following scenarios can occur:
- User has paid but closed the browser before redirection happened. The status request will return "success", and we can proceed to order confirmation screen.
- User has not paid, clicked cancel button in the payment webpage, but closed the browser before redirection happened. The status request will return "cancelled" and we can send the user back to the checkout screen.
- User has paid, but payment is still being processed. User closes browser and returns to the app. The status request will return "pending"
- User does not want to pay and just closed the browser because he wants to go back to the checkout page to change something in the form, the status request will return "pending" because the API doesn't know the user closed the browser
Scenario 1 and 2 are perfectly fine, but 3 and 4 cause problems. When the status request returns "pending", the app doesn't know if it's scenario 3 or 4. The app will show a dialogue on top of the checkout screen that says "payment pending". The problem is, when this happens the app doesn't know if 1) the payment is still processing and will succeed sometime in the future or 2) will never succeed because the user never paid. If the user closes this dialogue, it is still possible that the payment succeeds and the user will not know. We had many complaints of users who closed this dialogue and then tried to order again, resulting in an accidental double order.
We tried some workaround by making the dialogue non-closable for at least 30 seconds to give the payment some time to process, but that will bring a very bad UX for users who just closed the dialogue to return to checkout screen (scenario 4).
Is there any Android feature we're missing that could solve the issue? Is there any other solution? We would like to see approaches to other apps.