RevenueCat / purchases-ios

In-app purchases and subscriptions made easy. Support for iOS, watchOS, tvOS, macOS, and visionOS.
https://www.revenuecat.com/
MIT License
2.29k stars 307 forks source link

Issue with receipt. Receipt is not valid #2251

Closed jesus-mg-ios closed 1 year ago

jesus-mg-ios commented 1 year ago

Describe the bug A clear and concise description of what the bug is. The more detail you can provide the faster our team will be able to triage and resolve the issue. Do not remove any of the steps from the template below. If a step is not applicable to your issue, please leave that step empty.

  1. Environment
    1. Platform: iOS & MacOS
    2. SDK version: 4.16.0
    3. StoreKit 2 (disabled with useStoreKit2IfEnabled(false)) (Y/N): default
    4. OS version: MacOS 12.x, 13.x, iOS 15.x, 16.x
    5. Xcode version: 14.1.0
    6. How widespread is the issue. Percentage of devices affected.
  2. Debug logs that reproduce the issue
  3. Steps to reproduce, with a description of expected vs. actual behavior
  4. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

Additional context The Apple stuff experimented this error each time that starts to reviewing.

This error was experimented also on: https://github.com/RevenueCat/purchases-ios/issues/2074#issuecomment-1330389918,

2022-11-29 10:30:55.031363+0100 app[15527:1106073] [Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: app_product 2000000139898222 2000000042575785 1
2022-11-29 10:30:55.032634+0100 app[15527:1106073] [Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple.
2022-11-29 10:30:55.032724+0100 app[15527:1106073] [Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: app_product 2000000139941350 2000000042575785 1
2022-11-29 10:30:55.033742+0100 app[15527:1106073] [Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple.
2022-11-29 10:30:55.033817+0100 app[15527:1106073] [Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: app_product 2000000139998667 2000000042575785 1
2022-11-29 10:30:55.034896+0100 app[15527:1106073] [Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple.
2022-11-29 10:30:55.035001+0100 app[15527:1106073] [Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: app_product 2000000140025065 2000000042575785 1
2022-11-29 10:30:55.036151+0100 app[15527:1106073] [Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple.
2022-11-29 10:30:55.036248+0100 app[15527:1106073] [Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: app_product 2000000140060987 2000000042575785 1
2022-11-29 10:30:55.037464+0100 app[15527:1106073] [Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple.

--------
DEBUG: ℹ️ PaymentTransactionObserver (0x00000002815b2cc0) removedTransaction: app_product 2000000204486462 2000000042575785 1
2022-11-29 17:58:42.671777+0100 app[20021:1250441] [Purchases] - DEBUG: ℹ️ PaymentTransactionObserver (0x00000002815b2cc0) removedTransaction: app_product 2000000204486461 2000000042575785 1
2022-11-29 17:58:42.677649+0100 app[20021:1250441] [Purchases] - DEBUG: ℹ️ PaymentTransactionObserver (0x00000002815b2cc0) removedTransaction: mi app_product 2000000204486463 2000000042575785 1
2022-11-29 17:58:42.679432+0100 app[20021:1250441] [Purchases] - DEBUG: ℹ️ PaymentTransactionObserver (0x00000002815b2cc0) removedTransaction: app_product 2000000204486449 2000000042575785 1
2022-11-29 17:58:43.297245+0100 app[20021:1250441] [Purchases] - DEBUG: ℹ️ PaymentTransactionObserver (0x00000002815b2cc0) removedTransaction: app_product 2000000204486464 2000000042575785 1
ERROR: 😿‼️ The receipt is not valid. The purchased product was missing in the receipt. This is typically due to a bug in StoreKit.

This error is happening on MacOs and iOS on TestFlight:

ERROR: 😿‼️ The receipt is not valid. The purchased product was missing in the receipt. This is typically due to a bug in StoreKit.

And the reviewer rejects the binary each time that starts to make a purchase and the purchase cannot be done because of it.

msavaria commented 1 year ago

Any ETA on when we can expect a fix? I have the issue as well and it's obviously a show stopper for my release.

Here's the error logs that I got:

error   20:16:02.385941-0400    Turbo   ERROR: 😿‼️ The receipt is not valid. The purchased product was missing in the receipt. This is typically due to a bug in StoreKit.
error   20:16:02.465739-0400    Turbo   ERROR: 😿‼️ The receipt is not valid. The purchased product was missing in the receipt. This is typically due to a bug in StoreKit.
error   20:16:02.466415-0400    Turbo   ERROR: 💰 Product purchase for 'my_product_name' failed with error: Error Domain=RevenueCat.ErrorCode Code=8 "The receipt is not valid. The purchased product was missing in the receipt. This is typically due to a bug in StoreKit." UserInfo={readable_error_code=INVALID_RECEIPT, source_file=RevenueCat/HTTPClient.swift:551, source_function=parseUnsuccessfulResponse(), NSUnderlyingError=0x10eb9b510 {Error Domain=RevenueCat.BackendErrorCode Code=7712 "The purchased product was missing in the receipt. This is typically due to a bug in StoreKit." UserInfo={rc_backend_error_code=7712, NSLocalizedDescription=The purchased product was missing in the receipt. This is typically due to a bug in StoreKit.}}, NSLocalizedDescription=The receipt is not valid. The purchased product was missing in the receipt. This is typically due to a bug in StoreKit., rc_response_status_code=422, rc_backend_error_code=7712}

And here's what I noticed:

  1. It happens most of the times when the subscription has expired and I try to re-subscribe
  2. Doesn't seem to have issue when the subscription auto-renews
  3. Error seems to happen way more often after I upgraded the purchases-ios to 4.24.0 and disabled the usesStoreKit2IfAvailable flag, as recommended. Anecdotal, but before I was on version 4.17.8 with usesStoreKit2IfAvailable set to true and I only had the issue once. After upgrading the package, it now basically happens every time I try to resubscribe.
  4. Killing the app before trying to resubscribe seems to help mitigate the issue, but it is not an acceptable solution to tell my users.
kleon1024 commented 1 year ago

@kleon1024 what’s the full error that you’re getting? @NachoSoto image

hansemannn commented 1 year ago

I can confirm that is seems to happen even outside our test accounts as initially expected. This should be the no. 1 issue to work on.

NachoSoto commented 1 year ago

@msavaria thanks a lot for the additional detail. The team is currently looking into this.

It happens most of the times when the subscription has expired and I try to re-subscribe

I was unable to reproduce this. Is this in sandbox + on device? You let the subscription expire, then tried to subscribe again?

Here's the error logs that I got:

Any chance you can send us the complete debug (or .verbose if you can set that logLevel) logs, starting from SDK initialization? 🙏🏻

msavaria commented 1 year ago

I was unable to reproduce this. Is this in sandbox + on device? You let the subscription expire, then tried to subscribe again?

Yes NachoSoto, Sandbox env and on device. If it makes a difference, I got the error on a couple of different builds, Testflight build as well as a deploy to device from Xcode.

Your second point is also correct: I let the subscription expire by opting out of auto-renew (it is done automatically after 12 renewals). Here's a screenshot from my RC dashboard if that helps: image

Subscription expires every hour and automatically renews 12 times until automatically opting out. At that point, when I try to manually resubscribe, I get the Receipt is not valid error.

Any chance you can send us the complete debug (or .verbose if you can set that logLevel) logs, starting from SDK initialization? 🙏🏻

Of course, I'll work on getting you those verbose logs.

msavaria commented 1 year ago

@NachoSoto So... I've been trying to get a repro for the past two days but now it works every time 🥲 Nothing really changed on my end except enabling verbose logs.

I'll follow up when/if I get the error again.

NachoSoto commented 1 year ago

@msavaria we recently fixed a sort of related issue in the backend, so I'm not surprised that you can't reproduce anymore :)

We're also doing more work to ensure that "receipt is not valid" errors provide more context, since there's actually many reasons why that error can occur (many of which are misconfigurations).

I'll close this issue for now, but please let us know if you encounter this again and we'll be happy to help.

Moatamed8 commented 1 year ago

i think i have same issue how can i solve it ?

NachoSoto commented 1 year ago

@Moatamed8 can you e-mail support@revenuecat.com with your app information + logs so we can look into it?

Thanks!

github-actions[bot] commented 1 year ago

This issue has been automatically locked due to no recent activity after it was closed. Please open a new issue for related reports.