Google Play Billing Library

0

In library Google Play Billing, could someone tell me what the handlePurchase(purchase) part is for? What exactly does she do?

@Override void onPurchasesUpdated(@BillingResponse int responseCode,
    List<Purchase> purchases) {
if (responseCode == BillingResponse.OK
        && purchases != null) {
    for (Purchase purchase : purchases) {
        handlePurchase(purchase);
    }
} else if (responseCode == BillingResponse.USER_CANCELED) {
    // Handle an error caused by a user canceling the purchase flow.
} else {
    // Handle any other error codes.
} }

It is a mandatory function for the purchase process or, in fact, the purchase has already occurred and I could do anything (notify, open a warning window, consult purchase and etc.)?

What does this part mean?

    
asked by anonymous 25.06.2018 / 21:11

1 answer

0

Since the onPurchasesUpdated method arrived at the handlePurchase() method call means that the purchase has already been made and processed successfully in the Play Store (hence responseCode == BillingResponse.OK && purchases != null ).

So, as you yourself imagined, the handlePurchase() method is just a method to do post purchase processing, from there you can display an alert, save the data in a local DB, send the purchase data to a backend etc. .

    
26.06.2018 / 00:59