Last active
July 28, 2018 23:23
-
-
Save ponnamkarthik/828f8ff63d48a1f474fc62552010d999 to your computer and use it in GitHub Desktop.
In-app Billing Initalise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BillingClient mBillingClient; | |
mBillingClient = BillingClient.newBuilder(this).setListener(new PurchasesUpdatedListener() { | |
@Override | |
public void onPurchasesUpdated(int responseCode, @Nullable List<Purchase> purchases) { | |
for(Purchase purchase: purchases) { | |
//When every a new purchase is made | |
} | |
} | |
}).build(); | |
mBillingClient.startConnection(new BillingClientStateListener() { | |
@Override | |
public void onBillingSetupFinished(@BillingClient.BillingResponse int billingResponseCode) { | |
if (billingResponseCode == BillingClient.BillingResponse.OK) { | |
// The billing client is ready. You can query purchases here. | |
} | |
} | |
@Override | |
public void onBillingServiceDisconnected() { | |
// Try to restart the connection on the next request to | |
// Google Play by calling the startConnection() method. | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am newbie, I am trying to integrate in-app subscription last two day. I have done with another lib and test it by uploading apk on Alpha testing. My payment was successful but with that lib i am getting 102 error. so i am trying to implement in-app subscription using this lib but not getting idea that how to make request for subscription and how to check that my subscription is activated or not. And if subscription is successfully activated then how to check that user has cancelled subscription or not for second time when user start the app? Please do some help, i would be very appreciative.