Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to restore purchase on macOS 11.2, return "Nothing to Restore" #620

Open
nenhall opened this issue Feb 1, 2021 · 1 comment
Open

Comments

@nenhall
Copy link

nenhall commented Feb 1, 2021

Bug Report

Call Restore Purchase on macOS 11.2, return "Nothing to Restore", and then receive a callback to restore purchase in the completion function. Actually, you have already purchased. The sample code and terminal print information are as follows:

func applicationDidFinishLaunching(_ aNotification: Notification) {
    SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
        print("completeTransactions:", purchases)
        for purchase in purchases {
            switch purchase.transaction.transactionState {
                case .purchased, .restored:
                    if purchase.needsFinishTransaction {
                        // Deliver content from server, then:
                        SwiftyStoreKit.finishTransaction(purchase.transaction)
                    }
                case .failed, .purchasing, .deferred:
                    break // do nothing
            }
        }
    }
    
    SwiftyStoreKit.restorePurchases(atomically: true) { results in
        if results.restoreFailedPurchases.count > 0 {
            print("Restore Failed: \(results.restoreFailedPurchases)")
        }
        else if results.restoredPurchases.count > 0 {
            print("Restore Success: \(results.restoredPurchases)")
        }
        else {
            print("Nothing to Restore")
        }
    }
}

Terminal Response:

Nothing to Restore
Finishing transaction for payment "com.app.lifetime" with state: restored
completeTransactions: [SwiftyStoreKit.Purchase(productId: "com.app.lifetime", quantity: 1, transaction: productId: com.app.lifetime, transactionId: 1000000772090167, state: restored, date: Optional(2021-02-01 07:31:12 +0000), originalTransaction: Optional(productId: com.app.lifetime, transactionId: 1000000769635443, state: purchased, date: Optional(2021-01-26 02:57:38 +0000)), needsFinishTransaction: false)]

To Reproduce

Expected behavior
A clear and concise description of what you expected to happen.

Platform Information

  • OS: macOS 11.1
  • Purchase Type: [non-consumable, auto-renewable subscription]
  • Environment: [sandbox, production]
  • SwiftyStoreKit version: [0.16.1]

Potentially Related Issues

@womandroid
Copy link

The same error, macOS 11.2.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants