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

Restore outdated subscription and then Purchase, SwiftyStoreKit refuse to proceed #587

Closed
xiao99xiao opened this issue Oct 11, 2020 · 12 comments

Comments

@xiao99xiao
Copy link

Bug Report

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

  1. Purchase subscription.
  2. Invalidate the subscription. (In sandbox any subscription would be invalidated automatically after several hours.)
  3. Restart the app, restore purchase. (Actually restores a bunch of subscription transaction, but none of them is valid at the moment)
  4. Keep the app opening, purchase subscription (again).
  5. SwiftyStoreKit return success immediately, without triggering the App Store Purchase action. <--- This is wrong.

Expected behavior
Since we are starting a new subscription, (the old subscription is already invalid), the purchase should continue to App Store Purchase flow.

Platform Information

  • OS: iOS 14.0.2
  • Purchase Type: auto-renewable subscription
  • Environment: sandbox
  • SwiftyStoreKit version:0.16.1
@githubdelegate
Copy link

same bug,have you fix it ?

@dx777
Copy link

dx777 commented Oct 20, 2020

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

@githubdelegate
Copy link

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.

@xiao99xiao
Copy link
Author

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

@louiskabo
Copy link

louiskabo commented Nov 20, 2020

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.

@fury21
Copy link

fury21 commented Nov 27, 2020

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

@louiskabo
Copy link

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?

@fury21
Copy link

fury21 commented Nov 30, 2020

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?

@louiskabo
Copy link

Good to know..

@ponomarew
Copy link

any ideas?

@zipme
Copy link

zipme commented Jul 22, 2021

We are still having this issue (in production env), it doesn't even help when you delete and reinstall the app.

@ShoaibPenta
Copy link

ShoaibPenta commented Aug 24, 2023

Still getting this issue.
Unexpected restored transaction for payment 'subcriptionKey'

Does anyone have any solution?

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

8 participants