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

Returning an error when switching to another subscription plan within the same group #269

Open
5 tasks
mk0116 opened this issue Sep 12, 2017 · 6 comments
Open
5 tasks
Labels
duplicate type: apple bug an issue pending Apple fixes

Comments

@mk0116
Copy link

mk0116 commented Sep 12, 2017

Platform

  • [v] iOS
  • macOS
  • tvOS

In app purchase type

  • Consumable
  • Non-consumable
  • [v] Auto-Renewable Subscription
  • Non-Renewing Subscription

Environment

  • [v] Sandbox
  • [v] Production

Version

0.10.7

Related issues

Report

Issue summary

When the subscription changes to another plan, it returns unknown-error.

Steps to reproduce

  1. purchase an auto-renewable subscription
  2. switch to another plan within the same group
  3. it returns error even though the os says it succeeded

What did you expect to happen

it returns success

What happened instead

it returns an error

Recently, Apple added a feature the user can change their subscription plan within the same group.
But it seems like this library doesn't cover the case.
Please fix this!

@umekun123
Copy link

I have the same problem. When I buy the different in-app-purchase in the same group with SwiftyStoreKit.purchaseProduct, it shows the error.

@gapl
Copy link

gapl commented Oct 3, 2017

I can confirm this on my end and wanted to add some additional debugging information:

  • We have two tiers inside our subscription groups, let's call them lower and higher tier.
  • I purchase lower tier, all is fine
  • I upgrade to higher tier, upgrade works
  • I want to downgrade back to lower tier, I get system alert of success but an SKError.Code.unknown error is thrown.

Is there any progress on this?

@bizz84
Copy link
Owner

bizz84 commented Oct 12, 2017

May be related to #78. I'm not familiar with subscription groups.

Perhaps someone has implemented this before and could give some help?

@mvitas
Copy link

mvitas commented Dec 28, 2017

Hey guys,

I was puzzled also with this scenario.
Here is my reasoning around it.

My case (two subscriptions)

  1. user purchased monthly subscription
  2. user purchases yearly [monthly still active]

StoreKit alerts

  1. Do you want to purchase Yearly for $
  2. This purchase will be charged on date, when monthly expires [monthly currently active]
  3. Transaction successful

What is happening in StoreKit?
As Alert 2 tries to say, the transaction was queued and will go through once monthly subs expires.
The user will be charged at that point.
Alert 3 is misleading (poor wording) since it says that the transaction was successful. Better wording would be that the purchase order has been activated and will be triggered after monthly expires. This causes confusion.

Back to SwiftyStoreKit
Check https://github.com/bizz84/SwiftyStoreKit/blob/01df30888825657abe58797d920a570decaa9d98/SwiftyStoreKit/PaymentsController.swift

processTransaction(...)

Process Transaction works with SKPaymentTransaction which is focused on Payments.
Therefore, the transaction state is failed at the moment, since the user was not charged and the purchase request was added to a queue which will get triggered once the monthly subscription expires (i.e current month).

**Example from @gapl **
Upgrading to a higher tier works, since that payment transaction is (should be) executed instantaneously, while downgrading is executed after the Pro version expires (because the user already paid for it and it would lock them out of content that they paid for and the money wouldn't be refunded and it would cause confusion and anger).

Conclusion
SKPaymentTransaction - payment wasn't executed so SwiftyStoreKit returns failed, same way as the transaction from StoreKit.

UI/UX User related expecatations

  1. Ignore .unknown error and reverify all subscriptions just in case
  2. In case user presses again yearly and tries to buy it, StoreKit will notify them, that they already sent the purchase request and that it will be active after monthly expires. So, no big deal here.

You should verify the receipt periodically and this shouldn't be a problem. When yearly becomes active, it will be refreshed in your app (by you) and the new subscription will be shown to your user, together with the appropriate features based on your logic.

@bizz84 If you manage to dig up some contextual info in the error that could specify more closely this case, let me know. It could help with displaying a more precise alert to our users and a nicer usage flow .

@bizz84
Copy link
Owner

bizz84 commented Dec 29, 2017

Apologies for the late reply everyone.

@mvitas the scenario you're describing seems similar to this:

https://stackoverflow.com/questions/5224598/error-domain-skerrordomain-code-2-cannot-connect-to-itunes-store-userinfo-0x60

So, it's expected that the transaction will be .failed in your case.

StoreKit returns this error:

Error Domain=SKErrorDomain Code=2 “Cannot connect to iTunes Store” UserInfo=0x6083900 {NSLocalizedDescription=Cannot connect to iTunes Store}

This is quite generic so I don't think SwiftyStoreKit can be clever enough here (really, there should be a specific error case in StoreKit for this).

If your app lets users migrate across subscriptions, your best bet is to verify the receipt when new transactions are finished (you can do that in the completion block of completeTransactions()).

@bizz84
Copy link
Owner

bizz84 commented Dec 29, 2017

This issue is actually a duplicate of #125.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate type: apple bug an issue pending Apple fixes
Projects
None yet
Development

No branches or pull requests

5 participants