bizz84 / bizz84/SwiftyStoreKit

verifyPurchase always returns "not Purchased"

Open
#594 3 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Swift
Stars
6.7k
Forks
801
PR merge metrics
No merged PRs in 30d

Description

## Bug Report
I'm using code like the following in viewDidLoad at startup, but from a week or two week ago it always returns "notPurchased".

```
func verifyPurchase(productId:String) {
let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: xxxxxx)
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("purchased")
case .notPurchased:
print("notPurchased")
case .error:
print("error")
}
}
}
```

**To Reproduce**
Whenever I call `verifyPurchase(productId: "zzzzzz")` in ViewDidLoad, "not Purchased" is printed.
This seems to happen for all consumable, non-consumable, auto-renewable subscription, and non-renewing subscriptions.

**Expected behavior**
In my case, verifyPurchase with viewDidLoad always prints "notPurchased", but the purchase is successful.

When I press the buy button, it asks "You've already purchased this.Would you like to get it again for free".
![unnamed](https://user-images.githubusercontent.com/62616423/98437724-f69f2c80-2127-11eb-9567-5a03290b3311.jpg)

## Platform Information
- OS: [iOS 14.1]
- Purchase Type: [consumable, non-consumable, auto-renewable subscription, non-renewing subscription]
- Environment: [sandbox,TestFlight]
- SwiftyStoreKit version: [latest version of cocoapods]

## Additional context
Even if I use the code that worked normally until a few weeks ago or the app on TestFlight as it is, verifyPurchase also fails. I suspect that this issue is caused by the influence of the iOS version and so on.

If anyone has a similar problem and finds a solution, please let me know.

Contributor guide

Open the contributing guide

Research direction

Start at the reported verifyPurchase(productId:inReceipt:) entry point and trace the receipt returned by verifyReceipt(using:). Reproduce on iOS 14.1 in sandbox or TestFlight with the listed purchase types, then compare the receipt contents with the verification result. Done means the cause of purchased items being reported as notPurchased is identified and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile, payments
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.