SKPayment.applicationUsername is nil even if we assign a UUID string to it

According to the documentation and WWDC sessions, as long as we create a SKPayment with applicationUsername to be a UUID string. This value should be persistent when the transactions are updated.

However, when we tested it with XCode 14 and iOS 15 device, when we receive the SKPaymentTransaction for the auto renewals. The SKPaymentTransaction.payment.applicationUsername is nil.

Is this expected? Or it's a feature that will come in the future Xcode releases?

In the documentation which you refer to, there is

Important An applicationUsername property that isn’t a UUID isn’t guaranteed to persist between the time when you add the payment transaction to the queue and when the queue updates the transaction.

This also applies to the renewal notification when the transactionObserver is called later on. The discussion also states

Consider assigning a UUID to the applicationUsername property. When this value is a UUID, the App Store server stores it as an appAccountToken. In this scenario, the following happens:

  1. In the App Store Server API, the JWSTransactionDecodedPayload object returns the applicationUsername value in the appAccountToken field.

  2. In App Store Server Notifications, the JWSTransactionDecodedPayload object returns the applicationUsername value in the appAccountToken field.

  3. When you call the verifyReceipt endpoint to verify an App Store receipt, the App Store server returns the applicationUsername value in the app_account_token field of the responseBody.Latest_receipt_info.

If you set the applicationUsername field with a valid UUID string, then call addPayment, the App Store Server saves that UUID with the auto-renewing subscription information and will return that value as a field "in the app_account_token field of the responseBody.Latest_receipt_info." This means that when the renewal occurs, send the appStoreReceipt to the verifyReceipt endpoint with the shared-secret, then review the contents of responseBody.Latest_receipt_info to find the appropriate auto-renewing subscription record with the app_account_token.

As I understand, this works now. If it doesn't this would be a bug report issue.

rich kubota developer technical support CoreOS/Hardware/MFI

Hi Rich, thanks for the quick response.

I did verify that receipt validation returns the applicationName. Just want to double check, when the subscription renews, a SKPaymentTransaction object is also delivered to func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) method. And UUID string is not guaranteed to be returned in the SKPaymentTransaction.payment.applicationUsername field right?

SKPayment.applicationUsername is nil even if we assign a UUID string to it
 
 
Q