consumePurchases static method
Consume a list of purchased product specified with purchaseToken list.
Once purchase is completed, as a part of purchase process you need to deliver a content with granting entitlement as a result of the user's purchase. For one-time consumable product, you need to call consume method of the SDK to indicate that your app has granted entitlement to the user. With consumption of the one-time consumable product, the product can be purchased again.
After consumption, the product will vanish in current purchases but will still exist in purchase history.
purchaseTokens
Tokens as String array created after a purchase. It can be found inside PurchaseInfo object.
Callbacks BaseResponse
and GenericError in case of failure
Implementation
static Future<BaseResponse> consumePurchases(
List<String> purchaseTokens) async {
List<Object?>? response = await _channel
.invokeMethod('consumePurchases', {"purchaseTokens": purchaseTokens});
BaseResponse? result = new BaseResponse(false, null);
if (response != null) {
if (response[0] != null) {
result = new BaseResponse(response[0].toString() == "true", null);
}
if (response[1] != null) {
GenericError error =
GenericError.fromJson(json.decode(response[1]!.toString()));
result = new BaseResponse(false, error);
}
return result;
}
return result;
}