Developer Console

Implement Pending Purchases

A pending purchase occurs when a user of a child profile in Amazon Kids requests an in-app purchase (IAP) inside an app or game. After a child requests an in-app purchase, a notification is sent to the parent. The parent can then approve or decline the purchase through the Parent Dashboard. While waiting for approval, the purchase will be in a pending state. If the parent approves the request, your app can deliver the IAP. For details on how the pending purchase flow works, see Pending purchase.

The pending purchase state is supported by consumable and entitlement in-app purchases. Subscriptions IAPs don't support the pending state.

To enable Pending Purchases, your app must call the PurchasingService.enablePendingPurchases() method at any point before initiating a purchase. When a customer initiates a pending IAP, the resulting PurchaseResponse object has a RequestStatus of PENDING. The following code shows an example on how to set up a pending IAP.

In your activity class:

public class MainActivity extends Activity {

    @Override
     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        PurchasingService.registerListener(...);
        // The call to enablePendingPurchases is required for your app to receive a PENDING RequestStatus
        PurchasingService.enablePendingPurchases();
    }
    
    @Override
    public void onResume() {
        super.onResume();
        PurchasingService.getPurchaseUpdates(...);
    }

    void requestInAppPurchase() {
        PurchasingService.purchase(...)
    }
}

In your implementation of PurchasingListener:

class MyListener implements PurchasingListener {
      public void onPurchaseResponse(final PurchaseResponse response) {
         if (response.getRequestStatus() == PurchaseResponse.RequestStatus.PENDING) {
             // You can break here and do nothing, or show a modal indicating a request is pending.
             // The Appstore also shows a modal to the user indicating the request is pending before
             // returning the response to your app.
         }
     }
     
     // ... 
}

On Fire devices, customers get a notification from the system when a purchase is approved. Therefore, make sure to monitor the purchase request status. You must either use Real-Time Notifications (RTN) or regularly call getPurchaseUpdates() to be notified of the purchase status and fulfill the purchase. For details on how to implement getPurchaseUpdates(), see Implement getPurchaseUpdates method.

If the purchase is approved, the RequestStatus is updated to SUCCESSFUL and your app follows its regular logic for successful transactions. If the purchase is in a state where it's not approved, such as if the parent declines the purchase or lets the purchase request expire, your app doesn't need to take any further action. When not approved, there will be no notification from RTN and no new transaction when you call getPurchaseUpdates().

To see a sample app that implements pending purchases for consumables, go to the following path in the SDK: Appstore_SDK_<version>/examples/SampleIAPConsumablesApp.

To see a sample app that implements pending purchases for entitlements, go to the following path in the SDK: Appstore_SDK_<version>/examples/SampleIAPEntitlementsApp.


Last updated: May 22, 2024