dooboolab-community / react-native-iap

In App Purchase module for React Native!
https://react-native-iap.dooboolab.com
MIT License
2.73k stars 629 forks source link

IOS: Downgrade subscription #2742

Open Mihai-github opened 1 month ago

Mihai-github commented 1 month ago

Description

Trying to downgrade a subscription is not working, but upgrading works fine.

Expected Behavior

Be able to upgrade and downgrade subscriptions.

Screenshots

image

image

Environment:

To Reproduce Steps to reproduce the behavior:

Both subscriptions are in the same group, and have the same subscription duration of 1 month but they have different prices

  1. Initially buy a subscription with a higher price.
  2. Downgrade to the lower price subscription

While downgrading and passing to the requestSubscription promise the SKU for the cheaper subscription an error occurred which also triggered the purchaseErrorListener.

This is the error from the purcahseErrorListener:

{
    "responseCode": "0",
    "code": "E_UNKNOWN",
    "debugMessage": "An unknown error occurred",
    "message": "An unknown error occurred",
    "productId": "_______"
}

[Optional] Additional Context

While debugging and inspecting my SANDBOX account, I noticed an interesting discrepancy: although the code caught an error during the subscription downgrade process, my account displays the subscription as active, despite the failure.

NoatToan commented 1 month ago

I encounter same issue. :(

Before everything works fine.

NoatToan commented 1 month ago

From my side. I can do the purchase.

Only error get the error "Error: An unknown error occurred" from requestSubscription when I try to downgrade

"react-native": "0.72.4", "react-native-iap": "^12.13.1",

mharrison-nzme commented 1 month ago

From my side. I can do the purchase.

Only error get the error "Error: An unknown error occurred" from requestSubscription when I try to downgrade

"react-native": "0.72.4", "react-native-iap": "^12.13.1",

React Native: 0.67.4 React-native-iap: 12.13.1 on StoreKit 2

Experiencing the same unknown error. [Error: Purchased failed for sku:*Product ID Here*: Unable to Complete Request]

In my case, trying to downgrade from an Annual duration sub to a monthly duration - within the same subscription group. Upgrading the same products works fine.

This was working on our previous setup using react-native-iap@10.1.3 on StoreKit 1

NoatToan commented 1 month ago

Do anyone think this is the issue from Apple's sandbox env :D

SabahatRathore commented 3 weeks ago

{"error": [Error: Purchased failed for sku:: Unable to Complete Request], "success": false} i am facing same error. Do you find any solution .@mharrison-nzme

ivannzme commented 3 weeks ago

tried the below versions of the library:

React Native: 0.67.4

For the above, I am getting the same error message: [Error: Purchased failed for name_of_the_product: Unable to Complete Request]

Only getting this with iOS, android seems to be working as expected.

SabahatRathore commented 2 weeks ago

@ivannzme this does not work.i tried all these mentioned version . "react-native": "0.72.1", I am getting product in ios but when i request for subscription it through this error {"error": [Error: Purchased failed for sku:fc_month_179: Unable to Complete Request], "success": false}

hyochan commented 2 weeks ago

I have very limited time to contribute to this repo, so I consulted ChatGPT for assistance. Below are the details provided by ChatGPT, addressing both StoreKit1 and StoreKit2 scenarios as I am unsure which version you are using.

Common Issues and Solutions:

  1. Invalid Product ID:

    • Ensure the sku (product identifier) is correctly defined and matches the one set up in App Store Connect.
    • Verify that the products are correctly fetched and available before attempting to purchase.
  2. Sandbox Environment Issues:

    • Make sure the device is logged into a Sandbox account and not a regular Apple ID.
    • Clear any cached data or reset the device's Sandbox environment by logging out and back into the Sandbox account.
  3. Configuration Mismatches:

    • Verify that the configuration in App Store Connect matches the configuration in your StoreKit file in Xcode.
    • Ensure that all promotional offers and discount identifiers are correctly set up in App Store Connect.
  4. Subscription Handling:

    • Check that the app correctly handles the various states of a purchase (e.g., success, user cancelled, deferred).
    • Ensure that the transaction is finished appropriately to avoid leaving transactions in an incomplete state.

StoreKit1 Code Insights:

StoreKit2 Code Insights:

Additional Debugging Steps:

  1. Enable Detailed Logging:

    • Add detailed logging to track each step of the purchase process to identify where it might be failing.
      debugMessage("Logging detailed steps for purchase process...")
  2. Test Different Scenarios:

    • Test with different products and scenarios (e.g., without discounts, with various quantities) to isolate the issue.
  3. Check for Known Issues:

    • Look for any known issues with the specific versions of StoreKit and the react-native-iap library on their respective GitHub issues pages.

Summary:

By carefully reviewing the code for potential issues, ensuring configurations are correct, and adding detailed logging, you can better understand and resolve the errors related to in-app purchases. If these steps do not resolve the issue, consider sharing detailed logs and the specific error messages received during the purchase process for further assistance.


I hope this helps!

mharrison-nzme commented 1 week ago

From my side. I can do the purchase. Only error get the error "Error: An unknown error occurred" from requestSubscription when I try to downgrade "react-native": "0.72.4", "react-native-iap": "^12.13.1",

React Native: 0.67.4 React-native-iap: 12.13.1 on StoreKit 2

Experiencing the same unknown error. [Error: Purchased failed for sku:*Product ID Here*: Unable to Complete Request]

In my case, trying to downgrade from an Annual duration sub to a monthly duration - within the same subscription group. Upgrading the same products works fine.

This was working on our previous setup using react-native-iap@10.1.3 on StoreKit 1

It seems this issue has now been resolved for me, I did not make any code changes. Tested 3x downgrade scenarios yesterday and all completed successfully. Starting to wonder if it was Apple sandbox subscriptions service that had the issue.

SabahatRathore commented 1 week ago

From my side. I can do the purchase. Only error get the error "Error: An unknown error occurred" from requestSubscription when I try to downgrade "react-native": "0.72.4", "react-native-iap": "^12.13.1",

React Native: 0.67.4 React-native-iap: 12.13.1 on StoreKit 2 Experiencing the same unknown error. [Error: Purchased failed for sku:*Product ID Here*: Unable to Complete Request] In my case, trying to downgrade from an Annual duration sub to a monthly duration - within the same subscription group. Upgrading the same products works fine. This was working on our previous setup using react-native-iap@10.1.3 on StoreKit 1

It seems this issue has now been resolved for me, I did not make any code changes. Tested 3x downgrade scenarios yesterday and all completed successfully. Starting to wonder if it was Apple sandbox subscriptions service that had the issue.

its worked thanks