Question

Redirect after successful purchase

  • 10 November 2023
  • 1 reply
  • 49 views

Badge

I would like to redirect the user in the App upon a successful purchase.

```

const purchaseResult = await Purchases.purchaseStoreProduct({

product: productToBuy

});

```

How/where would I call this redirect?


1 reply

Userlevel 4
Badge +6

Hey @paul-098e37 !

 

You will want to tap into the customerInfo object to verify a successful purchase. The purchase(package:) completion block will contain an updated CustomerInfo object if successful, along with some details about the transaction. If the error object is present, then the purchase failed. See our guide on Error Handling for the specific error types. The userCancelled boolean is a helper for handling user cancellation errors. There will still be an error object if the user cancels, but you can optionally check the boolean instead of unwrapping the error completely.

 

Let me know if that helps! 

Reply