MKStoreKit restore purchases always success

575 Views Asked by At

I'm trying to make a simple IAP for delete all the Ad of my app. When I buy IAP it work, but when I try to restore purchase with clear sandbox account (which have never buy the IAP), it work.

So, the restorePurchases() always work, even if the user don't have buy the IAP previously.

There is my code : When user select restore button I perform this method :

func restaureIAP() {
    PKNotification.toast("Chargement en cours...")
    MKStoreKit.sharedKit().restorePurchases()
}

I have also add observer :

// Product restaure
        NSNotificationCenter.defaultCenter().addObserverForName(kMKStoreKitRestoredPurchasesNotification,
            object: nil, queue: NSOperationQueue.mainQueue()) { (note) -> Void in
                PKNotification.success("Restauré !")
                print ("Succes restaure: \(note.object)")

                NSUserDefaults.standardUserDefaults().setBool(true, forKey: "isPurchase")
        }

        NSNotificationCenter.defaultCenter().addObserverForName(kMKStoreKitRestoringPurchasesFailedNotification,
            object: nil, queue: NSOperationQueue.mainQueue()) { (note) -> Void in
                PKNotification.failed("Erreur")
                print ("Failed restaure: \(note.object)")
        }

This app is available on the AppStore, and have the same problem : buy IAP work but restore purchase are always successful.

Have you any ideas ?

1

There are 1 best solutions below

1
On BEST ANSWER

You may check Restored Transactions with MKStoreKitRestoredPurchasesNotification and kMKStoreKitRestoringPurchasesFailedNotification observers.

 MKStoreKit.sharedKit().startProductRequest()
 NSNotificationCenter.defaultCenter().addObserverForName(kMKStoreKitRestoredPurchasesNotification,
  object: nil, queue: NSOperationQueue.mainQueue()) { (note) -> Void in
    print ("Restored product: \(note.object)")
}

 NSNotificationCenter.defaultCenter().addObserverForName(kMKStoreKitRestoringPurchasesFailedNotification,
  object: nil, queue: NSOperationQueue.mainQueue()) { (note) -> Void in
    print ("Restored failed")
}