Java Code Examples for com.android.vending.billing.IInAppBillingService#getBuyIntent()
The following examples show how to use
com.android.vending.billing.IInAppBillingService#getBuyIntent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoogleBillingHelper.java From OPFIab with Apache License 2.0 | 11 votes |
/** * Wraps {@link IInAppBillingService#getBuyIntent(int, String, String, String, String)} * * @param sku SKU of a product to purchase. * @param itemType Type of an item to purchase. * * @return Bundle containing purchase intent. Can be null. */ @Nullable Bundle getBuyIntent(@NonNull final String sku, @NonNull final ItemType itemType) { OPFLog.logMethod(sku, itemType); final IInAppBillingService service = getService(); if (service == null) { return null; } try { final String type = itemType.toString(); final Bundle result = service.getBuyIntent(API, packageName, sku, type, ""); final Response response = GoogleUtils.getResponse(result); OPFLog.d("Response: %s. Result: %s", response, OPFUtils.toString(result)); return result; } catch (RemoteException exception) { OPFLog.d("getBuyIntent request failed.", exception); } return null; }
Example 2
Source File: PurchaseFlowLauncher.java From android-easy-checkout with Apache License 2.0 | 6 votes |
private Bundle getBuyIntent(IInAppBillingService service, List<String> oldItemIds, String itemId, String developerPayload) throws BillingException { try { // Purchase an item if (oldItemIds == null || oldItemIds.isEmpty()) { return service.getBuyIntent( mApiVersion, mPackageName, itemId, mItemType, developerPayload); } // Upgrade/downgrade of subscriptions must be done on api version 5 // See https://developer.android.com/google/play/billing/billing_reference.html#upgrade-getBuyIntentToReplaceSkus return service.getBuyIntentToReplaceSkus( BillingApi.VERSION_5.getValue(), mPackageName, oldItemIds, itemId, mItemType, developerPayload); } catch (RemoteException e) { throw new BillingException(Constants.ERROR_REMOTE_EXCEPTION, e.getMessage()); } }