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

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

Open
4 tasks done
natacodes opened this issue Oct 6, 2018 · 7 comments
Open
4 tasks done

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

natacodes opened this issue Oct 6, 2018 · 7 comments

Comments

@natacodes
Copy link

natacodes commented Oct 6, 2018

Platform

  • iOS

In app purchase type

  • Non-consumable
  • Auto-Renewable Subscription

Environment

  • 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?

@NunoAlexandre
Copy link

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.

@AdieOlami
Copy link

hi please I have been unable to get this project to work kind view my issue and contribute to it please thanks. #412

@DanijelHuis
Copy link

I've commented on issue (#307) about this, I think it is not related to this library since it also happens on my other app with native StoreKit implementation.

@intacto27
Copy link

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

@louiskabo
Copy link

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..

@yunzixun
Copy link

yunzixun commented Jan 5, 2022

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?

@louiskabo
Copy link

louiskabo commented Jan 5, 2022 via email

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

No branches or pull requests

7 participants