SwiftyStoreKit icon indicating copy to clipboard operation
SwiftyStoreKit copied to clipboard

User is being asked to enter Apple ID twice during the purchase

Open natacodes opened this issue 7 years ago • 7 comments

Platform

  • [x] iOS

In app purchase type

  • [x] Non-consumable
  • [x] Auto-Renewable Subscription

Environment

  • [x] Sandbox

Version

0.13.3

Report

Issue summary

I'm using the following snippet for the subscription purchases:

SwiftyStoreKit.purchaseProduct("my-product", quantity: 1, atomically: true) { result in
    switch result {
    case .success(let product):
        if product.needsFinishTransaction {
            SwiftyStoreKit.finishTransaction(product.transaction)
        }
        let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: secret)

        SwiftyStoreKit.verifyReceipt(using: appleValidator) { result in
            switch result {
            case .success(let receipt):
                let purchaseResults = SwiftyStoreKit.verifySubscriptions(ofType: .autoRenewable, productIds: Set(subscriptionService.productIDs), inReceipt: receipt)
                
                switch purchaseResults {
                case .purchased(let expiryDate, let items):
                    ...

Here I'm being asked for iTunes Store login twice. First when the purchase is being performed using purchaseProduct and second when I'm retrieving subscriptions from the receipts using verifyReceipt and verifySubscriptions. It's going to be confusing for users to enter Apple ID twice. Has anyone else seen this behavior?

natacodes avatar Oct 06 '18 23:10 natacodes

Hi @natacodes,

I have played a bit with this library these last days so I might be able to help.

While on the Sandbox environment, a popup is prompted when you try to download the receipt from Apple. This happens when there is no receipt saved locally in the device and/or when you have the forceRefresh option on.

You also need to log in when making purchases on the sandbox environment. That explains the two login prompts. Now, before your SwiftyStoreKit.verifyReceipt.. line, could you add this debug print before it?

 print("Receipt file exists? \(FileManager.default.fileExists(atPath: 
    Bundle.main.appStoreReceiptURL!.path))")

Once the purchase result is success, I am not sure whether the receipt has already been saved locally or not at that specific moment. If it isn't, then verifyReceipt will need to download it from apple, which will trigger the popup.

Note

  • I don't know whether you should finishTrasaction on success. I'd expect the SwiftyStoreKit.completeTransactions block to take care of it and not having to do duplicate it here.

  • Make sure that the Apple ID you are using to test this is a Sandbox user for your In-App Purchase.

NunoAlexandre avatar Oct 08 '18 11:10 NunoAlexandre

hi please I have been unable to get this project to work kind view my issue and contribute to it please thanks. https://github.com/bizz84/SwiftyStoreKit/issues/412

AdieOlami avatar Oct 17 '18 20:10 AdieOlami

I've commented on issue (https://github.com/bizz84/SwiftyStoreKit/issues/307) about this, I think it is not related to this library since it also happens on my other app with native StoreKit implementation.

DanijelHuis avatar Oct 25 '18 08:10 DanijelHuis

try to replace SwiftyStoreKit.verifyReceipt(using: appleValidator) with SwiftyStoreKit.verifyReceipt(using: appleValidator, forceRefresh: false) this helps me)

intacto27 avatar Jun 27 '19 08:06 intacto27

I have a similar issue, but it seems to only happen the first time a purchase is made with a brand new tester account.. The purchase looks like it goes thru, then it starts the billing flow payment sheet over again. The second time, it finished properly..

louiskabo avatar Nov 19 '20 19:11 louiskabo

try to replace SwiftyStoreKit.verifyReceipt(using: appleValidator) with SwiftyStoreKit.verifyReceipt(using: appleValidator, forceRefresh: false) this helps me)

still not working, could be reproduced using only a brand new tester account for first time. Is this expected behavior?

yunzixun avatar Jan 05 '22 15:01 yunzixun

This is an apple bug. It happens on new tester account with plain StoreKit, no swifty involved.. there is a similar ticket explaining such.

On Jan 5, 2022, at 10:10 AM, Jornathan Thorne @.***> wrote:

 try to replace SwiftyStoreKit.verifyReceipt(using: appleValidator) with SwiftyStoreKit.verifyReceipt(using: appleValidator, forceRefresh: false) this helps me)

still not working, could be reproduced using only a brand new tester account for first time. Is this expected behavior?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.

louiskabo avatar Jan 05 '22 17:01 louiskabo