Solved

Test Restore Purchases in sandbox


Badge +2

Hi!

I’m trying to test restoring Purchases in sandbox mode. My app does not identify users, and, by not having a login screen, every one of them has an anonymous App User ID.

I purchased a consumable item inside the app, and, as this grants a “benefactor” entitlement, tried to restore the entitlement after uninstalling the app. This did not work.

How can I ensure that an anonymous user can restore entitlements that are granted via consumable products?

 

Thanks !

Renato

icon

Best answer by Haley Pace 4 August 2023, 00:10

View original

12 replies

Userlevel 1
Badge +3

you are using consumables with entitlements, which we recommend against

 

If this is true, then why does the SDK auto-consume products on sync?

Badge +2

Hi, thanks for replying so quickly. I’m sorry I was unable to get back to you sooner. So, considering your feedback, what is the recommended way to implement anonymous tips?

Userlevel 4
Badge +8

Hi, updating here with the answer:

 

The issue here is that you are using consumables with entitlements, which we recommend against. You should either tie the entitlements to a non-consumable or an auto-renewable subscription. You will not see consumables restore as they do not show up on the receipt after its transaction is finished, just like non-renewing subscriptions, so if you uninstall or try on a different device, the receipt will be considered a brand new one for a brand new user, with nothing on it (unless there are subscriptions or non-consumables on it).

 

To resolve this, you should use non-consumable or subscription products. If you want to keep your existing consumable products, you would need to use an accounts system and only allowing purchases for logged in users.

Hello, this is also happening to me. If you do find an answer please let me know!

 

  • No login mechanism in app, using anonymous app ids
  • Testing on sandbox account with properly set sandbox user
  • Purchases ask me to confirm my sandbox user Apple ID and work, I'm using consumables.
  • uninstalling then reinstalling the app, then hitting restore or syncPurchases doesn’t restore entitlements.


 

Userlevel 4
Badge +8

Hi, would you be able to open a support ticket here so I can investigate this issue internally with engineering: https://app.revenuecat.com/settings/support

 

It will be helpful to have details such as the app user ids you are testing with, debug logs from TestFlight, etc. but I know that there is some sensitive information there so it’d be best to open a ticket. 

Badge +2

Hi, thank you for this information! What’s good is that there are no errors here. I believe this may just be due to the sandbox environment. Can you try testing restoring purchases in TestFlight? 

Yes, I’ve just tried to restore in TestFlight after an initial purchase and app reinstall, but I get the same behaviour. I suppose I’m doing something wrong...

Userlevel 4
Badge +8

Hi, thank you for this information! What’s good is that there are no errors here. I believe this may just be due to the sandbox environment. Can you try testing restoring purchases in TestFlight? 

Badge +2

Hi Haley, thanks for your help!

I’ve tried creating a brand new sandbox user and repeating the process (installing the app, making a consumable purchase, uninstalling the app, installing it again, and finally trying to restore my entitlement)
This still didn’t work. 

My app doesn’t have subscription products so I wasn't able to test that, however, I have tried to restore while in debug loglevel. here is my output:

I’ve added my sandbox user in Settings > App Store > Sandbox Account.

 

I hope this helps.

 

2023-07-24 12:15:36.355618+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: ℹ️ API request completed: GET /v1/subscribers/$RCAnonymousID:0bf9ad2a5d0a48d6af04afbadccc4807 (201)

2023-07-24 12:15:36.367896+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: ℹ️ Sending latest CustomerInfo to delegate.

2023-07-24 12:15:36.367974+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: 😻 CustomerInfo updated from network.

2023-07-24 12:15:36.368002+0000 EventFinderTerceira[65220:7087184] [Purchases] - DEBUG: ℹ️ Detected active subscriptions changed. Clearing trial or intro eligibility cache.

2023-07-24 12:15:36.368907+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: 😻 CustomerInfo updated from network.

2023-07-24 12:15:36.368948+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: ℹ️ GetCustomerInfoOperation: Finished

2023-07-24 12:15:36.369043+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: ℹ️ Serial request done: GET subscribers/$RCAnonymousID%3A0bf9ad2a5d0a48d6af04afbadccc4807, 0 requests left in the queue

2023-07-24 12:15:36.369084+0000 EventFinderTerceira[65220:7087634] [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Started

2023-07-24 12:15:36.369153+0000 EventFinderTerceira[65220:7087634] [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request GET subscribers/$RCAnonymousID%3A0bf9ad2a5d0a48d6af04afbadccc4807/offerings

2023-07-24 12:15:36.369857+0000 EventFinderTerceira[65220:7087634] [Purchases] - DEBUG: ℹ️ API request started: GET /v1/subscribers/$RCAnonymousID:0bf9ad2a5d0a48d6af04afbadccc4807/offerings

2023-07-24 12:15:36.581784+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: ℹ️ API request completed: GET /v1/subscribers/$RCAnonymousID:0bf9ad2a5d0a48d6af04afbadccc4807/offerings (200)

2023-07-24 12:15:36.586350+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: ℹ️ No existing products cached, starting store products request for: ["2022_01_02", "2022_01_03", "2022_01_04", "2022_01_01"]

2023-07-24 12:15:36.586568+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: ℹ️ Found an existing request for products: ["2022_01_02", "2022_01_04", "2022_01_03", "2022_01_01"], appending to completion

2023-07-24 12:15:36.586644+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Finished

2023-07-24 12:15:36.587105+0000 EventFinderTerceira[65220:7087569] [Purchases] - DEBUG: ℹ️ Serial request done: GET subscribers/$RCAnonymousID%3A0bf9ad2a5d0a48d6af04afbadccc4807/offerings, 0 requests left in the queue

Custom: Found an error with The operation couldn’t be completed. Universal link URL could not be parsed by Dynamic Links.

2023-07-24 12:15:36.646409+0000 EventFinderTerceira[65220:7087629] [Purchases] - DEBUG: 😻 Store products request received response

2023-07-24 12:15:36.647220+0000 EventFinderTerceira[65220:7087629] [Purchases] - DEBUG: ℹ️ Store products request finished

2023-07-24 12:15:49.899130+0000 EventFinderTerceira[65220:7087184] [Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: $RCAnonymousID:0bf9ad2a5d0a48d6af04afbadccc4807

2023-07-24 12:15:49.899826+0000 EventFinderTerceira[65220:7087184] [Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple.

2023-07-24 12:15:49.899972+0000 EventFinderTerceira[65220:7087634] [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest started

2023-07-24 12:15:50.842051+0000 EventFinderTerceira[65220:7087184] [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest finished

2023-07-24 12:15:50.845944+0000 EventFinderTerceira[65220:7087184] [Purchases] - DEBUG: ℹ️ Loaded receipt from url file:///private/var/mobile/Containers/Data/Application/6C0481DD-8BF0-4693-85A9-7CDCFAF6AB34/StoreKit/sandboxReceipt

2023-07-24 12:15:50.846248+0000 EventFinderTerceira[65220:7087803] [Purchases] - INFO: ℹ️ Parsing receipt

2023-07-24 12:15:50.850529+0000 EventFinderTerceira[65220:7087803] [Purchases] - INFO: ℹ️ Receipt parsed successfully

2023-07-24 12:15:50.851463+0000 EventFinderTerceira[65220:7087803] [Purchases] - INFO: ℹ️ Parsing receipt

2023-07-24 12:15:50.853190+0000 EventFinderTerceira[65220:7087803] [Purchases] - INFO: ℹ️ Receipt parsed successfully

2023-07-24 12:15:50.859193+0000 EventFinderTerceira[65220:7087804] [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Started

2023-07-24 12:15:50.859335+0000 EventFinderTerceira[65220:7087804] [Purchases] - INFO: ℹ️ Parsing receipt

2023-07-24 12:15:50.860606+0000 EventFinderTerceira[65220:7087804] [Purchases] - INFO: ℹ️ Receipt parsed successfully

2023-07-24 12:15:50.861490+0000 EventFinderTerceira[65220:7087804] [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" : "us\/O2gaW1NMbN6Lu+2I8tw==",

  "original_application_version" : "1.0",

  "bundle_id" : "projectTest.EventFinderTerceira",

  "sha1_hash" : "\/CZKyW9lXBbodBDu\/iM7sz4NR7Q=",

  "application_version" : "12",

  "creation_date" : "2023-07-24T12:15:50Z",

  "in_app_purchases" : [

 

  ]

}

2023-07-24 12:15:50.861584+0000 EventFinderTerceira[65220:7087804] [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request POST receipts

2023-07-24 12:15:50.864907+0000 EventFinderTerceira[65220:7087804] [Purchases] - DEBUG: ℹ️ API request started: POST /v1/receipts

2023-07-24 12:15:51.820502+0000 EventFinderTerceira[65220:7087803] [Purchases] - DEBUG: ℹ️ API request completed: POST /v1/receipts (200)

2023-07-24 12:15:51.825808+0000 EventFinderTerceira[65220:7087803] [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Finished

2023-07-24 12:15:51.826656+0000 EventFinderTerceira[65220:7087803] [Purchases] - DEBUG: ℹ️ Serial request done: POST receipts, 0 requests left in the queue

2023-07-24 12:15:51.830464+0000 EventFinderTerceira[65220:7087184] [Purchases] - DEBUG: ℹ️ Sending updated CustomerInfo to delegate.

2023-07-24 12:15:51.830762+0000 EventFinderTerceira[65220:7087184] [Purchases] - DEBUG: ℹ️ Detected active subscriptions changed. Clearing trial or intro eligibility cache.

2023-07-24 12:16:05.958694+0000 EventFinderTerceira[65220:7087184] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

2023-07-24 12:16:21.952604+0000 EventFinderTerceira[65220:7087634] [tcp] tcp_input [C1.1.1:3] flags=[R] seq=1663446357, ack=0, win=0 state=LAST_ACK rcv_nxt=1663446357, snd_una=3675651385

2023-07-24 12:16:21.955496+0000 EventFinderTerceira[65220:7087634] [tcp] tcp_input [C1.1.1:3] flags=[R] seq=1663446357, ack=0, win=0 state=CLOSED rcv_nxt=1663446357, snd_una=3675651385

2023-07-24 12:16:21.959671+0000 EventFinderTerceira[65220:7087634] [tcp] tcp_input [C1.1.1:3] flags=[R] seq=1663446357, ack=0, win=0 state=CLOSED rcv_nxt=1663446357, snd_una=3675651385

Userlevel 4
Badge +8

I’ve tried to restore purchases after uninstalling my app (where I had purchased a consumable tip with a sandbox user).  After reinstalling the app and trying to restore purchases I didn't get my entitlement back. (all consumable products are tips, and every tip grants the user a “Benefactor” entitlement)

Are you making sure to be logged in with the same Apple sandbox tester when you restore purchases? If so and it still isn’t working, there are a couple of things:

  • Have you tried creating a brand new sandbox user and Apple sandbox tester and seeing if this reproduces? This will help determine if it is all users, or just the one you were using.
  • Additionally, have you tested if restoring purchases works for subscription products? This will help determine if this is just an issue with your consumables.
  • Can you enable debug logs and send these for when you try restoring purchases? See here for how to enable them. This will let us see if there are any errors being returned.

 

Again, my app does not provide a login screen. All users are anonymous and, as such, it is my understanding that Revenue Cat provide an anonymous user ID that is capable of having purchases restored to it. Is that correct? 

This is correct. The way it works is that purchases are restored from the underlying store account, so as long as you are logged in with the same Apple sandbox tester account you should be seeing these purchases. 

Badge +2

Again, my app does not provide a login screen. All users are anonymous and, as such, it is my understanding that Revenue Cat provide an anonymous user ID that is capable of having purchases restored to it. Is that correct? 

Badge +2

Hi Haley, thanks for your answer.

I’ve tried to restore purchases after uninstalling my app (where I had purchased a consumable tip with a sandbox user). 
After reinstalling the app and trying to restore purchases I didn't get my entitlement back. (all consumable products are tips, and every tip grants the user a “Benefactor” entitlement)

Userlevel 4
Badge +8

If you call `restoreTransactions`, all previous purchases (non-consumable, consumable, and subscription) will be synced and displayed in our dashboard. You’ll want to make sure to be logged in to the same Apple sandbox tester account as well when restoring purchases. Additionally, when you are testing in sandbox mode, you'll want to toggle the sandbox switch on our dashboard. This will make sure you can see data from a sandbox account if you are testing.

Reply