question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onPurchasesUpdated not called for pending purchase success

See original GitHub issue

I have updated my application to use v2.1.0 (from an earlier 2.0.1 release) of the android play billing library and I am no longer receiving purchase updates on completion of a pending purchase.

I construct my billing client setting the listener to the current class, that implements PurchasesUpdatedListener:

billingClient = BillingClient.newBuilder( getActivity() )
        .setListener( this )
        .enablePendingPurchases()
        .build();

I then launch a purchase and use the “slow test card approves after a few minutes”

BillingFlowParams.Builder purchaseParamsBuilder = BillingFlowParams.newBuilder()
        .setSkuDetails( product );

billingClient.launchBillingFlow( getActivity(), purchaseParamsBuilder.build() );

My listener gets called after this indicating the purchase is pending:

@Override
public void onPurchasesUpdated( BillingResult billingResult, List<Purchase> purchases )
{
    int responseCode = billingResult.getResponseCode();
    if (responseCode == BillingClient.BillingResponseCode.OK)
    {
        // I get to here with a Purchase.PurchaseState.PENDING 
    }
}

However this listener does NOT get called when the purchase completes. I leave the application open and I see the notification from the play store saying the purchase was successful in the notification bar.

If I query the purchases manually after this notification I can get the updated purchase however this doesn’t seem like a valid approach for handling the purchase.

Does anyone know what I am doing wrong or has this process changed?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
CycleSkipcommented, Dec 21, 2019

We have found the issue and made a fix for it. ETA 01/13/2020 to roll out to all devices.

2reactions
marchboldcommented, Dec 19, 2019

No solution as yet! Glad I’m not the only one.

I’ve created an issue as requested here

Read more comments on GitHub >

github_iconTop Results From Across the Web

onPurchasesUpdated not called for pending purchase success
onPurchasesUpdated should be called when the pending transaction completes (either successfully or cancelled).
Read more >
Integrate the Google Play Billing Library into your app
To verify a purchase, first check that the purchase state is PURCHASED . If the purchase is PENDING , then you should process...
Read more >
Implement the Google Play Billing Interface | In-App Purchasing
Pass a PurchasesUpdatedListener object to the setListener() method. The enablePendingPurchases() method is only available as a no-op method . It ...
Read more >
Advanced in-app billing: handling alternative purchase flows
If the purchase was successful, call the getPurchases() method to retrieve a list of owned items that are still not consumed.
Read more >
Google Play in-app purchases and subscriptions ... - Qonversion
One of them is preventing hacking your app and faking successful purchase. ... a purchase, first check that the purchase state is PURCHASED,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found