SwiftyStoreKit seems to have a check when a purchase happens, whether the product is restored before.
This could lead to an error when purchasing a new subscription while an outdated subscription restore result already exists.
Since both share the same product identifier, SwiftyStoreKit would recognize the restored transaction as the result of the new purchase, returns a success result directly while no payment actually happened.
To Reproduce
Expected behavior
Since we are starting a new subscription, (the old subscription is already invalid), the purchase should continue to App Store Purchase flow.
same bug,have you fix it ?
Same, it is related to SKPaymentQueue have lots of transactions in the queue, if you will wait 5-10 minutes, the buy window will appear.
I've tried to finish all the transactions in the queue, by calling finish transaction, but it's not helping, they are still in the queue for too long.
Also I'm getting this in the console, after I try to purchase, after the restore:
Unexpected restored transaction for payment yearly_7
Finishing transaction for payment "yearly_7" with state: restored
In iOS13 sandbox environment, if you call SKPaymentQueue.default().finishTransaction(t) , the transaction will finish instantly.However,in iOS14,the transaction will finish after about one second, for example if you finish ten restored transaction, you must wait about ten second, otherwise you will get a restored transaction if you purchase.
@dx777 @githubdelegate So this is much like an iOS bug in sandbox environment, and doesn't exist in production environment?
In that way I'll close this issue, since it won't be a problem in production.
Just wanted to note, I have noticed this exact same behavior. I hope it is not in production and agree it is a bug.
This should not be a closed bug until we have confirmation that it will not occur in production and.or an explanation and work around to avoid such an issue.
I have same error when i click restore button and in 5 sec click 1 month subscription button i get error "Unexpected restored transaction for payment BAV.Jiletka.autoRenewableOneMoth" from SwiftStoreKit
What I have noticed is that once the error that @fury21 quoted comes up, Swifty then "Completes" the purchase as a success, even though no new purchase has happened. This in turn activates whatever item is in question. The app will then shortly thereafter realize its not supposed to have this item and take it away if you've programmed it right but this should be looked into a bit further.
It seems that there are maybe some unfinished purchases in the payment queue. And even if these have expired, they get finished, as they should.. But then for some reason, swifty thinks they are valid for a short period..
Can we re-open this bug report?
I have same error when i click restore button and in 5 sec click 1 month subscription button i get error "Unexpected restored transaction for payment BAV.Jiletka.autoRenewableOneMoth" from SwiftStoreKit
Also, i had same bug before i begin use SwiftyStoreKit, so maybe problem in receipt validator?
Good to know..
Most helpful comment
Same, it is related to SKPaymentQueue have lots of transactions in the queue, if you will wait 5-10 minutes, the buy window will appear.
I've tried to finish all the transactions in the queue, by calling finish transaction, but it's not helping, they are still in the queue for too long.
Also I'm getting this in the console, after I try to purchase, after the restore: