consumePurchase static method
Consume the purchased product specified with purchaseToken.
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.
purchaseToken
Token created after a purchase. It can be found inside PurchaseInfo object.
Callbacks boolean
and GenericError in case of failure.
Implementation
static Future<BaseResponse> consumePurchase(String purchaseToken) async {
List<Object?>? response = await _channel
.invokeMethod('consumePurchase', {"purchaseToken": purchaseToken});
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;
}