/**
  * Requests the purchase of the specified item with optional automatic confirmation.
  *
  * <p>For subscriptions, use {@link #requestSubscription(Context, String, boolean, String)}
  * instead.
  *
  * @param context
  * @param itemId id of the item to be purchased.
  * @param confirm if true, the transaction will be confirmed automatically. If false, the
  *     transaction will have to be confirmed with a call to {@link #confirmNotifications(Context,
  *     String)}.
  * @param developerPayload a developer-specified string that contains supplemental information
  *     about the order.
  * @see IBillingObserver#onPurchaseIntent(String, PendingIntent)
  */
 public static void requestPurchase(
     Context context, String itemId, boolean confirm, String developerPayload) {
   if (confirm) {
     automaticConfirmations.add(itemId);
   }
   BillingService.requestPurchase(context, itemId, developerPayload);
 }
Ejemplo n.º 2
0
 private void handleCommand(Intent intent, int startId) {
   final Action action = getActionFromIntent(intent);
   if (action == null) {
     return;
   }
   switch (action) {
     case CHECK_BILLING_SUPPORTED:
       checkBillingSupported(startId);
       break;
     case REQUEST_PURCHASE:
       requestPurchase(intent, startId);
       break;
     case GET_PURCHASE_INFORMATION:
       getPurchaseInformation(intent, startId);
       break;
     case CONFIRM_NOTIFICATIONS:
       confirmNotifications(intent, startId);
       break;
     case RESTORE_TRANSACTIONS:
       restoreTransactions(intent, startId);
   }
 }