Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle pending purchases from Google Play

Most of our purchases keep getting canceled after 3 days 30 minutes exactly, which I presume is the result of pending purchase state. However, there is so little documentation about how to handle pending purchases exactly. And, for some reason, even though I am a tester myself, I cannot test it because there is no "Slow card" option on purchase methods. Also, we do not have a backend server to well, back us up.

This is the explanation I've found from the official documentation:

void handlePurchase(Purchase purchase) {
    if (purchase.getPurchaseState() == PurchaseState.PURCHASED) {
        // Acknowledge purchase and grant the item to the user
    } else if (purchase.getPurchaseState() == PurchaseState.PENDING) {
        // Here you can confirm to the user that they've started the pending
        // purchase, and to complete it, they should follow instructions that
        // are given to them. You can also choose to remind the user in the
        // future to complete the purchase if you detect that it is still
        // pending.
    }
}

Look at the explanation on the PENDING state. What does "To complete the purchase, they should follow instructions that are given to them" mean? What are these instructions exactly? Do we need to redirect the user to Google Play or what? It is not specific about what to do and is bugging me out because purchases are getting cancelled for no reason, or for this reason. How does one complete a pending purchase? There is nothing about it, or I cannot find it, hence I ended up here.

I hope you can help me figure this out. Thanks.

like image 880
Furkan Yurdakul Avatar asked Oct 08 '19 13:10

Furkan Yurdakul


People also ask

How do I contact Google Play customer service?

Online Assistance and Customer Care. To view your Google Play balance, visit https://play.google.com/store/account. To speak to customer care, call us at 1-855-466-4438.

Will Google refund in app purchases?

Google may help you get a refund for an in-app purchase, but you must submit a refund request through this Google form. Make sure that you're signed in to your Google account, visit the link, and fill out the form. You'll need to select which in-app purchase you'd like a refund for and select a reason for your request.


1 Answers

I agree the documentation is poor, especially since the one time you want to know exactly what's happening is when you're handling other people's money!

It looks like a 'slow card' transaction is actually a 'pending purchase', something Google have been rolling out in 2019. Here's the probable flow...

  • In your app the user taps 'Buy now'
  • They see the Google checkout overlay
  • They choose "Pay at Freddina's Grocery, Accra" (a local store that's signed up to deal with Google pending purchases)
  • Google checkout displays a code to show to Freddina
  • User pays Freddina in cash and Freddina processes the payment using that code
  • 10 mins or so later, the purchase update will land in your app

As for handling unpredictably timed update events, we have an app with a handlePurchaseUpdated method listening out from the moment the app starts, and makes changes based on the Purchase object that comes with it. Here's an example flow:

  • We listen for purchase updates as soon as the app starts up
  • User makes a slow purchase
  • We get a purchase update
  • The passed Purchase object has purchase state PENDING
  • We tell the user that we'll notify them when the purchase is complete
  • At some point in the future (e.g. next day after an app restart) the purchase update comes in
  • If the purchase state is now PURCHASED we finalise the purchase and tell the user

Note: Ours is a ReactNative app, not native java, but the flow should be the same.

It's complicated to implement because you have to pick your time to make your purchase changes and display the purchase result at a time that makes sense, not necessarily when the purchase update arrives 5 secs after startup (or any other weird time). And it gets more complicated if there are errors during your grant-entitlement or acknowledgement steps, urgh.

Also, you might not be seeing the 'slow card' tester option because you didn't allow it?

like image 176
chichilatte Avatar answered Sep 19 '22 08:09

chichilatte