Missing local receipt after purchase using StoreKit 2 APIs

After completing a purchase using the StoreKit 2 APIs and receiving a successful and verified Product.PurchaseResult, the local receipt is still empty. Ideally I would not need this anymore, but our server-side implementation currently requires the encoded receipt data so for my current use-case I need to access it still.

My purchase flow looks like so:

let purchaseResult = try await product.purchase(options: purchaseOptions)

switch purchaseResult {
case .success(let verification):
    let transaction = try checkVerified(verification)
    ...
    guard let receiptPath = Bundle.main.appStoreReceiptURL?.path else {
            throw Error.missingReceipt
    }

    let receiptData = NSData(contentsOfFile: receiptPath) // Receipt data is nil here
    let receiptString = receiptData?.base64EncodedString(options: .endLineWithLineFeed) ?? ""
    ...
    // Handle server logic
    ...
    await transaction.finish()
case ...
...
}

My understanding was receipt data should still be generated when using StoreKit 2 APIs - is there a way to guarantee it is populated after successfully completing a purchase and during transaction handling?

I should add that this appears to be happening on both developer and TestFlight builds - so the Sandbox environment.

Any update on this? Having the same problem. Also empty receipt on production after successful purchase.

Ended up using SKReceiptRefreshRequest after purchase. https://developer.apple.com/documentation/storekit/skreceiptrefreshrequest

Missing local receipt after purchase using StoreKit 2 APIs
 
 
Q