RevenueCat / purchases-flutter

Flutter plugin for in-app purchases and subscriptions. Supports iOS, macOS and Android.
https://www.revenuecat.com/
MIT License
598 stars 164 forks source link

The second and subsequent purchases did not go well and were not reflected on the dashboard #556

Open Terurinpic opened 1 year ago

Terurinpic commented 1 year ago

‼️ Required data ‼️

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.

There are a lot of things that can contribute to things not working. Having a very basic understanding of your environment will help us understand your issue faster!

Environment

• No issues found!

- [x] Version of `purchases-flutter`
  - 4.5.4
- [x] Testing device version e.g.: iOS 15.5, Android API 30, etc.
  - iOS 16.0.3
- [x] How often the issue occurs- every one of your customers is impacted? Only in dev?
  - Only ios16 or higher
  - Often happens on second purchase
- [x] [Debug logs](https://docs.revenuecat.com/docs/debugging) that reproduce the issue
  - first purchase(working fine)

[Purchases] - WARN: 🍎⚠️ StoreKit 2 purchase took longer than expected (30.57 seconds) [Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple. [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest started [Purchases] - WARN: ⚠️ The appUserID passed to logIn is the same as the one already cached. No action will be taken. [Purchases] - DEBUG: ℹ️ Vending CustomerInfo from cache. [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Started [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request GET subscribers/DXtY6V9dOmTieLJwo1fPBXC0EHD2/offerings [Purchases] - DEBUG: ℹ️ API request started: GET /v1/subscribers/DXtY6V9dOmTieLJwo1fPBXC0EHD2/offerings [Purchases] - DEBUG: ℹ️ API request completed: GET /v1/subscribers/DXtY6V9dOmTieLJwo1fPBXC0EHD2/offerings (200) [Purchases] - DEBUG: ℹ️ Skipping products request for these products because they were already cached: ["dev.gera.fan.premium_ticket.1", "dev.gera.fan.premium_ticket.3", "dev.gera.fan.premium_ticket.30.free.20", "dev.gera.fan.premium_ticket.20.free.12", "dev.gera.fan.premium_ticket.10.free.5", "dev.gera.fan.premium_ticket.50.free.50", "dev.gera.fan.premium_ticket.5.free.2", "gera_dev_099_test"] [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Finished [Purchases] - DEBUG: ℹ️ Serial request done: GET subscribers/DXtY6V9dOmTieLJwo1fPBXC0EHD2/offerings, 0 requests left in the queue [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest finished [Purchases] - DEBUG: ℹ️ Loaded receipt from url file:///private/var/mobile/Containers/Data/Application/D7D69861-EF24-45E9-B889-D4311FA5F728/StoreKit/sandboxReceipt [Purchases] - DEBUG: ℹ️ Skipping products request for these products because they were already cached: ["dev.gera.fan.premium_ticket.1"] [Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: DXtY6V9dOmTieLJwo1fPBXC0EHD2 [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Started [Purchases] - INFO: ℹ️ Receipt parsed successfully [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Posting receipt (note: the contents might not be up-to-date, but it will be refreshed with Apple's servers): { "opaque_value" : "siIZ1WcLpkVQACSIVatZlw==", "original_application_version" : "1.0", "bundle_id" : "fan.gera.dev", "sha1_hash" : "LnbWuFETws5mGv3ThsmyjegSsfA=", "application_version" : "827", "creation_date" : "2022-12-22T03:56:49Z", "in_app_purchases" : [ { "product_id" : "dev.gera.fan.premium_ticket.1", "quantity" : 1, "transaction_id" : "2000000234083525", "is_in_trial_period" : false, "web_order_line_item_id" : 0, "original_purchase_date" : "2022-12-22T03:56:43Z", "original_transaction_id" : "2000000234083525", "product_type" : 1, "purchase_date" : "2022-12-22T03:56:43Z" } ] } [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request POST receipts [Purchases] - DEBUG: ℹ️ API request started: POST /v1/receipts [Purchases] - DEBUG: ℹ️ API request completed: POST /v1/receipts (200) [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Finished [Purchases] - DEBUG: ℹ️ Serial request done: POST receipts, 0 requests left in the queue [Purchases] - DEBUG: ℹ️ Sending updated CustomerInfo to delegate. [Purchases] - INFO: 💰 Finishing transaction '2000000234083525' for product 'dev.gera.fan.premium_ticket.1' [Purchases] - INFO: 😻💰 Purchased product - 'dev.gera.fan.premium_ticket.1'

  - second purchase(**there's problem**)

[Purchases] - WARN: ⚠️ The appUserID passed to logIn is the same as the one already cached. No action will be taken. [Purchases] - DEBUG: ℹ️ Vending CustomerInfo from cache. [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Started [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request GET subscribers/DXtY6V9dOmTieLJwo1fPBXC0EHD2/offerings [Purchases] - DEBUG: ℹ️ API request started: GET /v1/subscribers/DXtY6V9dOmTieLJwo1fPBXC0EHD2/offerings [Purchases] - DEBUG: ℹ️ API request completed: GET /v1/subscribers/DXtY6V9dOmTieLJwo1fPBXC0EHD2/offerings (200) [Purchases] - DEBUG: ℹ️ Skipping products request for these products because they were already cached: ["dev.gera.fan.premium_ticket.10.free.5", "dev.gera.fan.premium_ticket.30.free.20", "dev.gera.fan.premium_ticket.20.free.12", "gera_dev_099_test", "dev.gera.fan.premium_ticket.50.free.50", "dev.gera.fan.premium_ticket.5.free.2", "dev.gera.fan.premium_ticket.1", "dev.gera.fan.premium_ticket.3"] [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Finished [Purchases] - DEBUG: ℹ️ Serial request done: GET subscribers/DXtY6V9dOmTieLJwo1fPBXC0EHD2/offerings, 0 requests left in the queue <SKReceiptRefreshRequest: 0x280852340>: Finished refreshing receipt with error: Error Domain=ASDErrorDomain Code=603 "Request throttled" UserInfo={NSLocalizedDescription=Request throttled, NSLocalizedFailureReason=Unified receipt is valid and current} [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest finished [Purchases] - DEBUG: ℹ️ Loaded receipt from url file:///private/var/mobile/Containers/Data/Application/D7D69861-EF24-45E9-B889-D4311FA5F728/StoreKit/sandboxReceipt [Purchases] - DEBUG: ℹ️ Skipping products request for these products because they were already cached: ["dev.gera.fan.premium_ticket.1"] [Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: DXtY6V9dOmTieLJwo1fPBXC0EHD2 [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Started [Purchases] - INFO: ℹ️ Receipt parsed successfully [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Posting receipt (note: the contents might not be up-to-date, but it will be refreshed with Apple's servers): { "opaque_value" : "siIZ1WcLpkVQACSIVatZlw==", "original_application_version" : "1.0", "bundle_id" : "fan.gera.dev", "sha1_hash" : "LnbWuFETws5mGv3ThsmyjegSsfA=", "application_version" : "827", "creation_date" : "2022-12-22T03:56:49Z", "in_app_purchases" : [ { "product_id" : "dev.gera.fan.premium_ticket.1", "quantity" : 1, "transaction_id" : "2000000234083525", "is_in_trial_period" : false, "web_order_line_item_id" : 0, "original_purchase_date" : "2022-12-22T03:56:43Z", "original_transaction_id" : "2000000234083525", "product_type" : 1, "purchase_date" : "2022-12-22T03:56:43Z" } ] } [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request POST receipts [Purchases] - DEBUG: ℹ️ API request started: POST /v1/receipts [Purchases] - DEBUG: ℹ️ API request completed: POST /v1/receipts (200) [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Finished [Purchases] - DEBUG: ℹ️ Serial request done: POST receipts, 0 requests left in the queue [Purchases] - INFO: 💰 Finishing transaction '2000000234084002' for product 'dev.gera.fan.premium_ticket.1' [Purchases] - INFO: 😻💰 Purchased product - 'dev.gera.fan.premium_ticket.1'


- [x] Steps to reproduce, with a description of expected vs. actual behavior
**Other information** (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

## Describe the bug ##
I want to make the second and subsequent purchases successful.
However, after the second purchase, the following error occurs and the purchase is not reflected on the dashboard.
> <SKReceiptRefreshRequest: 0x28250fb40>: Finished refreshing receipt with error: Error Domain=ASDErrorDomain Code=603 "Request throttled" UserInfo={NSLocalizedDescription=Request throttled, NSLocalizedFailureReason=Unified receipt is valid and current}

## Additional context ##
it's working on Android and iOS15

Thank you.
RCGitBot commented 1 year ago

👀 SDKONCALL-194 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

michaelAtRC commented 1 year ago

Is this happening in sandbox? If so, this is likely happening because the user has many purchases in their receipt, which is common in sandbox. You can try making a new sandbox user. Currently our mobile engineers are working on updating the SDK to handle this sandbox case better, but you likely won't see this happen in production.

If this is in production, please let me know!

aboedo commented 1 year ago

@Terurinpic it seems like this ticket is a duplicate of https://github.com/RevenueCat/purchases-flutter/issues/557, would you mind if we close this one out and continue conversation there?

Terurinpic commented 1 year ago

@michaelAtRC it's happening in sandbox. Create a new account and check it out!

@aboedo This issue cannot purchase the same product. (error dialog is not displayed) But #557 shows an error dialog when purchasing different products. So I think it's another issue.

michaelAtRC commented 1 year ago

Hey @Terurinpic Happy new year!

Quick question, did creating a new sandbox user and purchasing show you the same problem? Or did it resolve this issue?

Terurinpic commented 1 year ago

Hello @michaelAtRC Happy New Year to you too!

I tried it, but i have the same problem.

michaelAtRC commented 1 year ago

Hey @Terurinpic

I have gone ahead and raised this issue to the TRIAGE team. I will keep you updated as I get more information!

aboedo commented 1 year ago

The logs show that the request to refresh the receipt was throttled. That seems to be a new thing in StoreKit, since we only started seeing it like a month or two ago. We recently made updates to try to prevent that, but those updates should be a part of 4.5.4, so perhaps that wasn't enough 😬 cc @NachoSoto

aboedo commented 1 year ago

@Terurinpic question that might be helpful for us when debugging, are these consumables or non-consumables?

Terurinpic commented 1 year ago

@aboedo consumables!

aboedo commented 1 year ago

Thanks for the quick turnaround! We're investigating the issue. It seems likely that it's related to the throttling of the refresh receipt request

aboedo commented 1 year ago

@Terurinpic does this reproduce consistently for you? I see a number of purchases for that user in the purchase history for dev.gera.fan.premium_ticket.1, are you checking the "show sandbox data" checkbox?

Terurinpic commented 1 year ago

@aboedo Reproduce consistently! After launching the app, the first purchase is reflected in the dashboard, but the second purchase is not reflected. I checked "show sandbox data".

aboedo commented 1 year ago

@Terurinpic do they show in the SDK in customerInfo under nonSubscriptionTransactions?

aboedo commented 1 year ago

I can't seem to reproduce 😬 I just tried buying the same consumable multiple times in the same session I can see all purchases in the dashboard in sandbox data

Terurinpic commented 1 year ago

@aboedo It seems that the second purchase is not displayed in nonSubscriptionTransactions.(The first purchase is shown.) Oh no... Is there anything that I can do?

michaelAtRC commented 1 year ago

Hey @Terurinpic could we get appUserIDs that reproduce this and gather logs for it? I tried looking up the appUserID in the logs but it’s already been cycled out.

Terurinpic commented 1 year ago

@michaelAtRC Should I send the my AppUserId to the URL below? the support section of the Dashboard

michaelAtRC commented 1 year ago

Hey @Terurinpic That would be great to create a new support ticket!

Terurinpic commented 1 year ago

@michaelAtRC I sent my AppUserId now!

Terurinpic commented 1 year ago

Hey @michaelAtRC @aboedo The project I'm working on didn't have an app-specific shared secret, so I set it up and now it works! (same https://github.com/RevenueCat/purchases-flutter/issues/557) Thanks for investigating! RC is a great service!