bizz84 / SwiftyStoreKit

Lightweight In App Purchases Swift framework for iOS 8.0+, tvOS 9.0+ and macOS 10.10+ ⛺
MIT License
6.58k stars 795 forks source link

In the callback of “restorePurchases”, verifying that the purchase always returns "notPurchased" #644

Open nenhall opened 3 years ago

nenhall commented 3 years ago

Bug Report

I also encountered the same problem, and the product type is: nonConsumable; it can be verified during normal purchase, and every time the purchase is verified through restorePurchases, it will return notPurchased; The same operation, verify that there is no problem with autoRenewable;

The following code is not a complete code, it is my approximate operation at the time

SwiftyStoreKit.restorePurchases(atomically: true, applicationUsername: "") { results in
            let successPurchases = results.restoredPurchases
            successPurchases.forEach { purchase in
                SwiftyStoreKit.verifyReceipt(using: AppleReceipt, forceRefresh: forceRefresh) { verifyReceiptResult in
                  switch verifyReceiptResult {
                case .success(let receiptInfo):
                    switch product.type {
                    case .nonConsumable:
                        let verifyPurchase = SwiftyStoreKit.verifyPurchase(productId: product.rawValue, inReceipt: receiptInfo)
                        switch verifyPurchase {
                        case .purchased(let item):
                            appendLog("✅","purchased:", product.rawValue)

                        case .notPurchased:
                            appendLog("⚠️","notPurchased:", product.rawValue)
                        }
                    }
                }
            }
       }
 }

To Reproduce Steps to reproduce the behavior: Step 1 : Call “restorePurchases()” method Step 2 : In the callback of restorePurchases(completion: ...) method, -> Call verifyReceipt(using: ...) method, and return case .success( receiptInfo ), -> Call verifyPurchase(productId: ...) method verifying that the purchase Step 3 : When the product type is nonConsumable, always return "notPurchased"

Additional : In the callback of restorePurchases(completion: ...),print results.restoredPurchases, It is able to see the corresponding commodity purchase record。

Expected behavior Able to restore purchase successfully,Actually it is a successfully purchased product。

Platform Information

forkdog commented 3 years ago

I also encountered this problem

aectannctx commented 2 years ago

Same problem, in-app non-consumable purchase verification always fails. I've checked it on 3 different devices

Platform Information

OS: iOS 15.5 Purchase Type: non-consumable Environment: [sandbox, production] SwiftyStoreKit version: 0.16.1

karalarbaris commented 2 years ago

I have the same problem too

frogg commented 2 years ago

Yes, same problem here as well!

sabiland commented 2 years ago

FYI, because of the issues with SwiftyStoreKit I refactored today one of my apps to StoreKit 2 - with the help of Mercato.

frogg commented 2 years ago

I merged this PR which seems to have fixed it for me: https://github.com/bizz84/SwiftyStoreKit/pull/640