Fetching Purchases
When you want to get user's purchase history, you can fetch them via getCurrentPurchases and getAllPurchases methods of the SDK. All of the previous purchases made for consumable, non-consumable and subcription product types made by user will be return as a result. Even if the purchases which are made by user before the implementing the Appmate SDK will also be return.
#
Fetching All PurchasesWith calling getAllPurchases method of the SDK you can get all of the purchases list made by user. The list returned by this method might contain purchases which are already consumed or just purchased but not consumed consumable product's purchases. Also might contain expired/ongoing subscription product's purchases or entitlement granted non-consumable product's purchases. In summary, you get all the purchases made by the user without any filtering.
note
If you did any purchase within our Sandbox Testing process with your test user id, those purchases will be return. You can check the sandbox boolean flag parameter of PurchaseItem object.
#
RequestParameter Name | Type |
---|
#
ResponseParameter Name | Type |
---|---|
purchases | List<PurchaseInfo>? |
error | GenericError? |
- Flutter
PurchasesResponse response = await PurchaseClient.getAllPurchases();if (response.error != null) { print(response.error!.message!);} else { print(response.purchases!);}
#
Fetching Current PurchasesWith calling getCurrentPurchases method of the SDK you can get the list of purchases which comes with specific filtering rules from the user's purchases. These filtering rules are;
- Purchased but not consumed purchases
- Ongoing subscription purchases
note
Purchases which are made before or without Appmate SDK implementation still will be return if they match these filtering rules.
important
When subscription purchase is made via Google Play or AppGallery Sandbox processes, there might be a grace period defined for purchased product. If you cancelled this subscription from Google Play or AppGallery or unsubscribe within related sdk method, purchase will be still returning if there is a grace period defined before. Subscription purchase will be active until the time set for the grace period ends.
#
RequestParameter Name | Type |
---|
#
ResponseParameter Name | Type |
---|---|
purchases | List<PurchaseInfo>? |
error | GenericError? |
- Flutter
PurchasesResponse response = await PurchaseClient.getCurrentPurchases();if (response.error != null) { print(response.error!.message!);} else { print(response.purchases!);}
#
Checking If Product is PurchasedWith calling isProductPurchased method of the SDK you can check whether a product is purchased or not. Once you query a product with productId, a boolean response comes back. True means that the product is purchased.
- Purchased but not consumed purchases
- Non-consumable purchases
- Ongoing subscription purchases
#
RequestParameter Name | Type |
---|---|
productId | String |
#
ResponseParameter Name | Type |
---|---|
success | bool |
error | GenericError? |
- Flutter
BaseResponse response = await PurchaseClient.isProductPurchased("productId");if (response.error != null) { print(response.error!.message!);} else { print(response.success ? "Purchased" : "Not Purchased");}