bizz84 / bizz84/SwiftyStoreKit
Questions about the return value and processing order of the VerifyPurchase function
- Dominant language
- Swift
- Stars
- 6.7k
- Forks
- 801
- PR merge metrics
- No merged PRs in 30d
Description
I tried a function like this:
```
func verifyPurchase(productId:String,sharedSecret:String) ->String {
var returnValue = "none"
let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: sharedSecret)
SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
switch result {
case .success(let receipt):
let purchaseResult = SwiftyStoreKit.verifyPurchase(productId: productId, inReceipt: receipt)
switch purchaseResult {
case .purchased:
print(productId+"_purchased")
returnValue = "purchased"
case .notPurchased:
print(productId+"_notPurchased")
returnValue = "notPurchased"
}
case .error:
print(productId+"_error")
returnValue = "error"
}
}
return returnValue
}
print(verifyPurchase(productId:xxxxx,sharedSecret:xxxxx) )
```
However, the function always returns "none" even if the purchase is successful.
What is the order in which the VerifyPurchase function is processed?
How can this function return the correct value?
Contributor guide
Assessment
This issue has not been assessed yet.