billingResponseCode: Int) { if (billingResponseCode == BillingClient.BillingResponse.OK) { // The billing client is ready. You can query purchases here. } } override fun onBillingServiceDisconnected() { // Try to restart the connection on the next request to // Google Play by calling the startConnection() method. } })
build() { if (mContext == null) { throw new IllegalArgumentException("Please provide a valid Context."); } if (mListener == null) { throw new IllegalArgumentException( "Please provide a valid listener for" + " purchases updates."); } return new BillingClientImpl(mContext, mListener); }
yet connected to billing service or was already disconnected from it. */ int DISCONNECTED = 0; /** This client is currently in process of connecting to billing service. */ int CONNECTING = 1; /** This client is currently connected to billing service. */ int CONNECTED = 2; /** This client was already closed and shouldn't be used again. */ int CLOSED = 3; }
PurchaseHistoryResponseListener listener) { if (!isReady()) { listener.onPurchaseHistoryResponse( BillingResponse.SERVICE_DISCONNECTED, /* purchasesList */ null); return; } executeAsync( new Runnable() { @Override public void run() { final PurchasesResult result = queryPurchasesInternal(skuType, /* queryHistory */ true); // Post the result to main thread postToUiThread( new Runnable() { @Override public void run() { listener.onPurchaseHistoryResponse( result.getResponseCode(), result.getPurchasesList()); } }); } }); }
PurchaseHistoryResponseListener listener) { if (!isReady()) { listener.onPurchaseHistoryResponse( BillingResponse.SERVICE_DISCONNECTED, /* purchasesList */ null); return; } executeAsync( new Runnable() { @Override public void run() { final PurchasesResult result = queryPurchasesInternal(skuType, /* queryHistory */ true); // Post the result to main thread postToUiThread( new Runnable() { @Override public void run() { listener.onPurchaseHistoryResponse( result.getResponseCode(), result.getPurchasesList()); } }); } }); }
int SERVICE_DISCONNECTED = -1; /** Success */ int OK = 0; /** User pressed back or canceled a dialog */ int USER_CANCELED = 1; /** Network connection is down */ int SERVICE_UNAVAILABLE = 2; /** Billing API version is not supported for the type requested */ int BILLING_UNAVAILABLE = 3; /** Requested product is not available for purchase */ int ITEM_UNAVAILABLE = 4; int DEVELOPER_ERROR = 5; /** Fatal error during the API action */ int ERROR = 6; /** Failure to purchase since item is already owned */ int ITEM_ALREADY_OWNED = 7; /** Failure to consume since item is not owned */ int ITEM_NOT_OWNED = 8; }
Boolean fun startConnection(listener: BillingClientStateListener) fun launchBillingFlow(activity: Activity, params: BillingFlowParams): Int fun queryPurchases(): Purchase.PurchasesResult fun endConnection() fun queryPurchaseHistoryAsync(skuId: String): Single<PurchasesUpdatedResponse> }