Respond to purchases and purchase restorations

A flow can continue after a paywall screen — resume the onboarding, show the new subscribers a thank-you screen, or welcome back those who restore an earlier purchase.

You set outcomes in the action settings, one for each purchase condition. An outcome without actions keeps users on the paywall screen.

  • The Purchase action has the following conditions: When succeeded, When failed, When cancelled by user, and When pending.
  • The Restore purchases action has two conditions: When restore completed and When restore failed.

Before you start

Make sure that:

  • Your app uses Adapty SDK v4.0 or later.
  • The flow has a paywall screen. To build one, follow the Create a basic paywall screen recipe.
  • An element on the paywall screen, such as a button, has a Purchase action.
  • Your app keeps the flow open in its purchase and restoration callbacks .

Add actions for a result

Important

The flow can only respond to In-App Store purchases. It doesn’t receive the result of a Web Payment purchase.

  1. Select the element that has the Purchase or Restore purchases action.
  2. Click the Purchase or Restore purchases action.
  3. For the purchase or restoration result you need, such as When succeeded, click .
  4. From the Action dropdown, select the action to run instead of Do nothing.
Note

A navigation or Close Flow action that follows Purchase or Restore purchases in the same trigger runs right away, before the result. Add it as an outcome action instead.

Tip

When a Purchase action has outcome actions, a double tap doesn’t start a second purchase. The flow ignores more taps on that action until the store returns the result, for up to 60 seconds. Restore purchases works the same way.

To see the outcome actions in your app, make a sandbox purchase.

You can’t make real purchases in the preview in the Adapty mobile app.

If the flow skips the outcome actions in your app, see why the flow skips outcome actions.

Tip

To handle purchase results in your app code instead, for example to open a native screen, use the purchase and restoration callbacks of the Adapty SDK. Each change to that code needs an app release. If your app opens a second flow after a purchase, you can move its screens into the flow that contains the paywall.

Show the next screen after a successful purchase

To continue the onboarding or show a thank-you screen after a successful purchase, pair the When succeeded outcome with a Navigate to Screen action, and select that screen as the destination.

Close the flow after a successful purchase

To end the flow after a successful purchase, add Close Flow for When succeeded instead of a navigation. The flow then closes only when the purchase succeeds, so your app code doesn’t need to close it.

Respond to a failed, canceled, or pending purchase

To show an alert or a screen after a failed, canceled, or pending purchase, add actions for these outcomes of the Purchase action:

  • When failed: An error stopped the purchase. For example, show an alert that asks the user to try again later.
  • When cancelled by user: The user canceled the purchase. For example, show a screen with another offer.
  • When pending: The purchase waits for approval, for example while the bank confirms the payment, or while a parent approves it through Ask to Buy on iOS. The flow doesn’t respond when the bank or the parent approves the purchase, so show a screen that explains the wait.
Tip

To let users try a failed purchase again, keep them on the paywall, for example with an alert for When failed. You can’t add Purchase, Restore purchases, or Request permission to an outcome.

Respond to a purchase restoration

The Restore purchases action has two outcomes: When restore completed and When restore failed.

When restore completed means that the restoration finished without an error, not that the user has access. You can’t verify access levels in a flow. To show content that depends on access, add Close Flow for When restore completed, and verify the access level in the app.