Google Play Billing Library

Asked

Viewed 41 times

0

In the library Google Play Billing, could anyone inform me what the part is for handlePurchase(purchase)? 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 actually the purchase has already taken place and I could do anything (notify, open a warning window, consult purchase and etc.)?

What does that part mean?

1 answer

0

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.