-
Notifications
You must be signed in to change notification settings - Fork 17
3. Initiate a purchase or subscribe flow
Iman khoshabi edited this page May 27, 2021
·
1 revision
Initiate a purchase or subscribe flow using the below code:
/// To launch a purchase flow
PurchaseInfo purchaseInfo = await FlutterPoolakey.purchase('your product id (SKU)', payload: '');
/// To launch a subscribe flow
PurchaseInfo purchaseInfo = await FlutterPoolakey.subscribe('your product id (SKU)', payload: '');
productId
is your product's identifier (also known as SKU).
payload
is an optional parameter that you can send, bazaar saves it in the PurchaseInfo
.
You can access it through your back-end API.
If any error happened (like when the user cancels the flow) it throws a [PlatformException] with a stacktrace. You must handle the error with your logic.
If it succeeded, it returns the PurchaseInfo
of the purchased product.