Question

[Flutter] Couldn't find existing purchase for SKU

  • 9 April 2024
  • 2 replies
  • 28 views

Badge

There are two subscription setups:

Identifier: tier1:monthly1, Subscription Id: tier1, Base Plan Id: monthly1

Identifier: tier2:monthly2, Subscription Id: tier2, Base Plan Id: monthly2

When changing the plan from tier1:monthly1 to tier2:monthly2, the following error occurs for a specific user:

PlatformException(4, One or more of the arguments provided are invalid., {code: 4, message: One or more of the arguments provided are invalid., readableErrorCode: PurchaseInvalidError, readable_error_code: PurchaseInvalidError, underlyingErrorMessage: Couldn't find existing purchase for SKU: tier1, userCancelled: false}, null)

In testing locally, this error is not reproducible, and the cause of the error is not apparent. The product_id of the subscription for the user where the error occurs is as follows, with tier1:monthly1 set:

{   "app_id": "",   ...   "product_id": "tier1:monthly1", }

The code for changing the plan is as follows:

final currentEntitleInfo =
(await Purchases.getCustomerInfo()).entitlements.all[_entitlementId];
final result = await Purchases.purchasePackage(
package,
googleProductChangeInfo: currentEntitleInfo?.isActive == true
? GoogleProductChangeInfo(
currentEntitleInfo!.productIdentifier,
)
: null,
);

Can you identify the cause of the error? Any assistance would be appreciated.


This post has been closed for comments

2 replies

Userlevel 3
Badge +5

Hi! Here is our documentation for PurchaseInvalidError. Because this is just occurring for one user, that suggests that it is probably an issue with their payment method. Can you have them check that it is a valid method?

Badge

Thank you for your response!

Does that mean that even if there's an issue with the payment method (for example, an expired credit card), the error "Couldn't find existing purchase for SKU: tier1" could still occur?