Cancelling a sign in when buying an IAP returns incorrect error

Originator:kerr.miller
Number:rdar://42772397 Date Originated:
Status:Closed Resolved:NO
Product: Product Version:
Classification: Reproducible:
 
Area:
StoreKit

Summary:
When you attempt to buy an in app purchase from an app and you are currently logged out of iTunes on your device, you first get prompted to log in (e.g. you get an alert with the title 'Sign In' and two options 'Use Existing Apple ID' and 'Cancel'). If you select 'Cancel', your SKPaymentTransactionObserver will receive a transaction with an error with code "0" (`SKError.unknown`) -- full error is: `Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}`. Because the user actually selected "Cancel" in the prompt, I believe the error code should be "2" (`SKError.paymentCancelled`).

Steps to Reproduce:
1. Sign out of iTunes on device
2. Attempt to purchase an IAP
3. When you see the 'Sign In' alert, tap Cancel
4. Done

Expected Results:
- The error returned by StoreKit to the observer should correspond to a 'payment cancelled' error.

Actual Results:
- The error returned by StoreKit to the observer is an 'unknown' error.

Version/Build:
- iOS 11.4.1, Xcode 9.4.1

Comments

Apple replied with:


Engineering has provided the following information regarding this issue:

When user click “buy” button of in-app purchase, the storekit will try to verify the user’s account -> popup Apple ID login dialog( if user currently logged out of iTunes/App Store) -> this is a prerequisite for purchasing. so the app will get SKError.Unknown with the last error description: cannnot connect to iTunes Store. and this error is returned from other module outside of StoreKit.framework. To StoreKit it is a unknown prerequisite error.(preconditions are not met)

But after user successully login Apple ID, user will see a popup/overlay payment sheet( see attached screen), SKError.paymentCancelled will be triggered when user try to cancel this payment sheet UI.


By kerr.miller at Sept. 26, 2018, 1:47 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!