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

buySubscription does not resolve when changing subscriptions in iOS #274

Closed
kevinEsherick opened this issue Sep 26, 2018 · 14 comments
Closed
Assignees
Labels
🐛 bug Something isn't working 🍗 enhancement New feature or request 📱 iOS Related to iOS

Comments

@kevinEsherick
Copy link

kevinEsherick commented Sep 26, 2018

Version of react-native-iap

2.2.2

Platforms you faced the error (IOS or Android or both?)

iOS

Expected behavior

buySubscription should resolve when changing from Monthly to Yearly subscription, rather than reject and return an error, forcing the catch clause.

Actual behavior

If currently subscribed to one plan, changing to another causes buySubscription to catch and return the following error:
screen shot 2018-09-27 at 1 21 10 am

Tested environment (Emulator? Real Device?)

Real device, iPhone 6

Steps to reproduce the behavior

This occurs when the modify subscription dialog boxes pop up in-app, asking if you'd like to change from your present subscription to the newly selected one. Upon tapping through this dialog the error is thrown instead of the expected resolved promise. It seems this use case has not been accounted for or something.

This is breaking for me right now because there's then no way to confirm that they actually purchased or validate receipts for these cases. Please let me know if you know of a workaround or fix, or if there's anything I can do to help (though I have no Obj-C experience). The only possible workaround I can think of for now is if buySubscriptions returns an error, checking this error and if it matches this error then confirming the purchase. But this is very dangerous as it renders receipt validation impossible and some other error (like inability to connect to server or something) could produce the same error code, giving the user the subscription without actually having to pay for it. So in other words, I can think of no feasible workarounds at the moment. Am I missing something here? Is there some reason I wouldn't need the promise from buySubscriptions resolved? Would be very grateful to hear from someone.

EDIT: This may be an obvious consequence of what I've already described, but after attempting to modify your subscription, this purchase is not added to your purchase history. There are no indications on the user side that this purchase is not succeeding—the user proceeds through the purchase flow of dialog boxes successfully, concluding with one saying "You're all set".

EDIT2: Sometimes it works but I'm not yet sure how to reproduce, will report back if I find a way. When it works the first dialog box requests my password then proceeds normally as if I don't already have another subscription, as opposed to when the first dialog box is "Confirm Purchase" and it asks if I want to modify my subscription, which is what appears when it's not working. When it works, the purchased subscription gets added to my purchase history as expected.

EDIT3: I took a picture of the wrong error message before. I've now corrected it. The error message reads: "Error: An unknown or unexpected error has occured. Please try again later." Also you may want to consider looking at the method used for buying products in react-native-in-app-utils. They use a different method and the differences could help explain why this is happening, though I haven't used that library and so can't confirm it wouldn't happen there.

@hyochan
Copy link
Member

hyochan commented Oct 24, 2018

Could you try recent version now which is 2.3.15?

@kevinEsherick
Copy link
Author

Yea I'll take it for a spin at some point today

@hyochan
Copy link
Member

hyochan commented Oct 28, 2018

@kevinEsherick What's your result for this one?

@kevinEsherick
Copy link
Author

Still not working. If I'm subscribed to monthly and switch to yearly it hits the catch clause. There have been some times where it has randomly worked but haven't found a way to reproduce yet. I will keep you updated on what I find and please do the same for me. Thanks!

@JJMoon
Copy link
Contributor

JJMoon commented Oct 31, 2018

@kevinEsherick How did you "switch" the subscription? I guess you "cancel" monthly subscription, and "buy again" yearly subscription. Is that right?

@curiousdustin
Copy link
Contributor

On iOS, can't you switch a subscription by going into the settings app to manage your subscriptions, and then choosing a different product within the same group?

@kevinEsherick
Copy link
Author

kevinEsherick commented Oct 31, 2018

@JJMoon No, I simply buy the Monthly subscription in-app, then buy the Yearly subscription in-app. They're autorenewing subscriptions in the same subscription group. If two subscriptions (A and B) are in the same group on iTunes Connect, buying B while subscribed to A is supposed to automatically cancel A and subscribe you to B. Do you think it's a problem with this package not supporting this functionality? If so, can we find a way to implement this?

@curiousdustin
Copy link
Contributor

I am also running into this issue. Any progress?

@kevinEsherick
Copy link
Author

No. Haven't had much time to address it lately. I'll look into it again soon.

@kevinEsherick
Copy link
Author

Looking into it some and I've realized that it appears Apple recognizes the change in subscription at least to some extent. If I switch from, say, monthly to yearly, it shows the appropriate modal with language about modifying your subscription. When I purchase yearly, there's an error and buySubscription doesn't resolve. BUT, when I go back to make a purchase again, this time returning to the monthly subscription, Apple's API knows that I'm on the yearly subscription and shows the "Do you want to modify your subscription..." modal again. How this manifests in production I'm not yet sure, as this is all sandboxed. I'll look into this further at some point tonight, but this might mean that things are alright on Apple's end and that it's just an error on the client side. If this is the case, this may no longer be a critical bug, but it still does warrant a fix.

@kevinEsherick
Copy link
Author

Looked into it again some today and I think I've found something of note. What seems to be happening is what was found in this error: bizz84/SwiftyStoreKit#269. When switching between autorenewing subscriptions in the same group, the transaction does not go through because the user will not be billed until the current subscription expires. But it has been successfully registered and the payment will be processed once the current subscription is up, but not until then. Thus, the transaction returns failed because no transaction is actually occurring yet. So I don't think anything is actually going wrong in the payment process, it's just that the bounced transaction registers as an error. But I have yet to test this since I just stumbled across it and my debugger is acting up and it's getting late so I'm not going to try to sort it out until tomorrow. Would be great if someone could try to confirm in the meantime (i.e. by switching between subscriptions and then seeing if the transaction for the second one pops up in your purchase history once the first has expired, or something like this). If this IS what's going on, it would be great if we could figure out some way to handle it. If the error that it generates is specific to this process, we could just pass that down as the return value of the promise so we can properly handle (e.g. not generating an error message for the user, updating user subscription info). Would love to hear anyone's thoughts on whether this checks out and how to proceed.

@JJMoon
Copy link
Contributor

JJMoon commented Dec 15, 2018

@JJMoon JJMoon added the 🍗 enhancement New feature or request label Dec 31, 2018
@JJMoon JJMoon self-assigned this Dec 31, 2018
@JJMoon
Copy link
Contributor

JJMoon commented Jan 8, 2019

I hope this issue can be handled by the methods I mentioned.
Closing...

@JJMoon JJMoon closed this as completed Jan 8, 2019
@Gazfay
Copy link

Gazfay commented May 8, 2019

Have the same behavior, any steps to resolve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🍗 enhancement New feature or request 📱 iOS Related to iOS
Projects
None yet
Development

No branches or pull requests

5 participants