Question

iOS SDK - in-app purchase completion not called

  • 11 January 2023
  • 3 replies
  • 51 views

Badge

Hi Guys,

I am having an annoying issue in-app purchase payment with RevenueCat.

Purchase modal is properly displayed and I can always proceed with payment (). Problem is : about 4 times out of 10, the following callback is not called.

Purchases.shared.purchase(package: package) { [weak self] transaction, info, error, other in

Which means we cannot retrieve the transaction info or properly inform the user.

I am pretty confident the purchase worked, as the system displays a purchase confirmation an alert (see attached screenshot).

The following logs also suggest that both purchase and receipt were properly handled :

2023-01-11 19:08:23.124231+0100 XXX[4003:1210683] [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest started
2023-01-11 19:08:23.232600+0100 XXX[4003:1206279] [Purchases] - DEBUG: ℹ️ applicationDidBecomeActive
2023-01-11 19:08:23.675919+0100 XXX[4003:1206279] <SKReceiptRefreshRequest: 0x28161e3e0>: Finished refreshing receipt with error: Error Domain=ASDErrorDomain Code=603 "Request throttled" UserInfo={NSLocalizedFailureReason=Unified receipt is valid and current, NSLocalizedDescription=Request throttled, AMSServerErrorCode=0}
2023-01-11 19:08:23.676101+0100 XXX[4003:1206279] [Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest finished
2023-01-11 19:08:23.676785+0100 XXX[4003:1206279] [Purchases] - DEBUG: ℹ️ Loaded receipt from url file:///private/var/mobile/Containers/Data/Application/ZZZ/StoreKit/sandboxReceipt
2023-01-11 19:08:23.676934+0100 XXX[4003:1206279] [Purchases] - DEBUG: ℹ️ Skipping products request for these products because they were already cached: ["YYY"]
2023-01-11 19:08:23.677362+0100 XXX[4003:1206279] [Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: sjbxHhdsP8hGMmlp38dzjlGJlfg2
2023-01-11 19:08:23.678806+0100 XXX[4003:1210652] [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Started
2023-01-11 19:08:23.678962+0100 XXX[4003:1210652] [Purchases] - INFO: ℹ️ Parsing receipt
2023-01-11 19:08:23.681816+0100 XXX[4003:1210652] [Purchases] - INFO: ℹ️ Receipt parsed successfully
2023-01-11 19:08:23.682373+0100 XXX[4003:1210652] [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" : "GixbfjDCNh4lAsINHu6GHQ==",
"original_application_version" : "1.0",
"bundle_id" : "XXX",
"sha1_hash" : "zqAAieTWtQd3ZJZBjcgo8+LVfu8=",
"application_version" : "2",
"creation_date" : "2023-01-11T18:08:20Z",
"in_app_purchases" : [
{
"product_id" : "YYY",
"quantity" : 1,
"transaction_id" : "2000000247660644",
"is_in_trial_period" : false,
"web_order_line_item_id" : 0,
"original_purchase_date" : "2023-01-11T18:08:19Z",
"original_transaction_id" : "2000000247660644",
"product_type" : 1,
"purchase_date" : "2023-01-11T18:08:19Z"
}
]
}
2023-01-11 19:08:23.682487+0100 XXX[4003:1210652] [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request POST receipts
2023-01-11 19:08:23.684376+0100 XXX[4003:1210652] [Purchases] - DEBUG: ℹ️ API request started: POST /v1/receipts
2023-01-11 19:08:24.387933+0100 XXX[4003:1210652] [Purchases] - DEBUG: ℹ️ API request completed: POST /v1/receipts (200)
2023-01-11 19:08:24.402668+0100 XXX[4003:1210652] [Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Finished
2023-01-11 19:08:24.402900+0100 XXX[4003:1210652] [Purchases] - DEBUG: ℹ️ Serial request done: POST receipts, 0 requests left in the queue
2023-01-11 19:08:24.407313+0100 XXX[4003:1206279] [Purchases] - DEBUG: ℹ️ Sending updated CustomerInfo to delegate.
2023-01-11 19:08:24.407502+0100 XXX[4003:1206279] [Purchases] - INFO: 💰 Finishing transaction '2000000247660644' for product 'YYY'
2023-01-11 19:08:24.889837+0100 XXX[4003:1210652] [Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x0000000283244600) removedTransaction: YYY 2000000247660644 1

I am using iOS 16.2, revenue cat version is 4.16.0 and usesStoreKit2IfAvailable is set to false.

I can reproduce the issue about about 4 times out of 10 on both Testflight and Xcode built version on my iPhone 13.

My app has been rejected about 5 times by Apple reviewers because of this. First I could not reproduce the bug the reviewer was reporting. I am suspecting this issue happens only with iOS 16.2 (I recently updated my device to try to reproduce).

I am also considering opening a ticket on Github for this.

Any help on this would be greatly appreciated, a work-around if exists would also make my day as I lost many many hours trying to solve this.

Thanks,


3 replies

Userlevel 1
Badge +4

Hey There,

 

Hopefully I can help you out here!

 

Two quick things:

  1. Does testing with a new sandbox user help? Maybe the user has a ton of sandbox purchases that are slowing things down by making the history for this users receipt very long?
  2. Does StoreKitTest give you the same behavior? That mocks out Apple's entire StoreKit framework, so it helps to isolate issues in your app or RevenueCat. If your app works find using StoreKitTest then it indicates the issue may be on apple's end
Badge

Hi Michael,

Thanks for looking at our issue.

I was stuck for a while so I had to ship a new version of the app with StoreKit directly (instead of RevenueCat). I could not reproduce the issue after that.

The delay after the system alert “You’re all set.” went down dramatically (I guess because no receipt is uploaded).

I could be linked with the amount of Purchase for my user, however I still don’t get why it happened 6 times our of 10 with RevenueCat, and why the callback is not called at all.

Userlevel 1
Badge +4

Hey Yannis,

 

If your app seems to be working fine using StoreKitTest then it indicates the issue here may be on apple's end. 

 

This seems to be linked with the amount of purchases on that user, causing the receipt to be abnormally large and messing up the request. 

 

If you are still experiencing this issue, can you please open a support ticket with us so we can look more into it!

Reply