Hi, I'm stuck with an issue, I need to send applicationUsername to my Server so i can validate the receipt for auto renewable Subscriptions for Store kit 2 in app purchases. For this purpose I"m using a third party SwiftyStoreKit this function has a parameter to send applicationUsername to the receipt along the product ID.
I used to send the parameters but i'm not getting this in new Receipt format, after decoding the receipt on the server i found no applicationUsername in the receipt.
If anyone can help me with this please answer this, I'm new here in community.
Here is the function which i'm using to send the product id and applicationUsername
print("purchase productID = \(purchase)")
NetworkActivityIndicatorManager.networkOperationStarted()
SwiftFTUtils.showHUDAdded(to: vc.view, withText: "", animated: true)
SwiftyStoreKit.purchaseProduct(purchase, atomically: atomically,applicationUsername: userId) { result in
NetworkActivityIndicatorManager.networkOperationFinished()
SwiftFTUtils.hideHUDAdded(to: vc.view, animated: true)
print("purchase result = \(result)")
if case .success(let purchase) = result {
self.validateServerPurchase(purchase: purchase, vc: vc)
NotificationCenter.default.post(name: NSNotification.Name("RELOAD_DASHBOARD"), object: nil)
AppDelegateShared().setupDrawer(0)
}
if let alert = vc.alertForPurchaseResult(result) {
vc.showAlert(alert)
}
}
}
Hello!
- There's no need to verify receipt in StoreKit 2 (there's no receipt to verify as such). Transactions are cryptographically signed and verifying the signature verifies the transaction.
https://developer.apple.com/documentation/storekit/transaction :
StoreKit automatically validates the transaction information, returning it wrapped in a
VerificationResult. If you get a transaction throughVerificationResult.verified(_:), the information passed validation.
- Instead of
applicationUsername, useappAccountToken.
appAccountToken
A UUID that associates the transaction with a user on your own service.