Skip to content

Instantly share code, notes, and snippets.

@ponnamkarthik
Last active July 28, 2018 23:23
Show Gist options
  • Save ponnamkarthik/828f8ff63d48a1f474fc62552010d999 to your computer and use it in GitHub Desktop.
Save ponnamkarthik/828f8ff63d48a1f474fc62552010d999 to your computer and use it in GitHub Desktop.
In-app Billing Initalise
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.
}
});
@JohhSonic
Copy link

add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment