Prevent same apple account in auto renewal in app purchase - ios

I have implemented auto-renewal subscription in app purchase in my app, but I am stuck in 1 case scenario.
User can sign up into app after successfully in-app purchase done. App is offer 2 plans Yearly & Monthly.
Let's suppose abc#apple.com in there as apple ID in device settings.
Scenario:
User A gets the subscription with his app credentials and his Apple ID.
User B uses User A's device and signup with User B app credentials but uses User A's Apple ID to buy a subscription.
Currently, it allows that User B to purchase this item but it says that there is a subscription with this user and asks for a permission to modify this subscription.
My question is how to prevent User B to modify User A's subscription? I could not find any solution before the receipt creation. I do not want to allow User B that modifies User A's subscription. I want to inform User B about using different Apple ID to continue to buy a subscription.
How can I restrict user B before he initiate the purchase?
My Try
I try to compare original transactionID, but it is after the purchase initiated & this will restrict the user B to sign up via backend server. But as it is valid purchase so server is update its plan if User B choose other plan than user A chosen before.
Thank you,

Related

Can another app user have subscription from same itunes connect after 1st user's subcription gets expired in ios

If app user 1 purchases a subscription and later he cancels it after some renewals and now app user 2 want to purchase a subscription from the same itunes account, so is this possible and if, how should we handle this on server side?
one itunes account can be use as one subscription only but if you said user 1 already cancel subscription then obviously if another user come to register with the same itunes account that user is possible to purchase a subscription because previously user1 cancel his subscription once his cancel you can use flag on database side that this user in cancel subscription and now whoever is using this account can re subscription or purchase new subscription service
but if user1 decided to purchase another subscription with an existing subscription of user2 now it impossible since they shared same itune account
Yes, it is possible. And to handle it you have to save the Subscription receipt over the server and every time map the new receipt over the server with other receipts. if it does not exist over the server (for your current user) then it's the in-app purchase from new apple id or it's purchased again.

How do apps tie accounts with in-app purchase subscription?

I'm working on an iOS app where a user must sign up/sign in to an account for my app. To be able to use my services I want users to pay via in-app purchases (auto-renewing in my case). This would then tie their IAP to their account (they created with us) to be able to use on any other iOS device.
Case 1:
For example if a subscription was bought on phone A for an account, when signing on to phone B (using the same account) shouldn't make the user pay again.
Case 2:
Or if a subscription was bought for account A on a phone, when signing up for account B on the same phone should make the user pay for account B.
Basically I want an in-app purchase to tie to my account (rather than a apple device/Apple account which is how it works to my understanding.)
I understand that their are receipts which is probably part of the answer to my question. Or if this a limitation to in app purchases what other ways can this be done (other than using Apple's IAP)
The answer to the title of the question:
When a purchase is made there is an update received in the app, the next time it is launched which contains a transaction_id (original_transaction_id for renewals), you should associate this transaction id with your app user id.
Case 1: Apple provides an option to "Restore Purchases" in your app. Since, the same account is used, your app servers would already know that a user has already paid and the app shouldn't prompt the user to pay again. However, in order to receive the upcoming renewal updates on phone B, you must "Restore Purchases" which would let Apple link the previous purchase on this device as well. Once the restore is done, the users purchase receipt will be available on the device and all subsequent actions should be taken based on the content validation of the receipt.
Few points here:
Apple will reject your app, if it doesn't provide this option to the user.
Even if your app is buggy, and you failed to restore purchases, user wouldn't be charged again. The purchase would fail saying you already have purchased this.
The above case is completely based on the assumption that the user is using the same Apple Id on both the devices(same application user id doesn't matter).
Case 2: I am not sure if that is anyhow possible. Since it's the same device, the user uses the same AppleId(unless he signs out and changes apple id in App Store) and Apple will restrict the repurchase. At best you may restrict the account B with the subscription content but if your application allows multiple accounts on the same device use case(e.g Instagram), I am not sure if there's a provision for the same.
I tested the same scenario for a music service app I use. Have an active subscription, logged out and signed up with other email (app), but the purchase was denied alerting I have already purchased. However, it was allowing me upgrade and downgrade options. I didn't opt for testing them so not to mess up my account.
P.S: There are a lot of other caveats/gotchas to take care of. Some of them:
In case 2, apple restricts the repurchase but it doesn't restrict if the user chooses an option other than the current active subscription, which will upgrade/ downgrade the subscription. Based on how you have implemented things, it might even change the subscription for user A immediately or next time the user logs back in or on next renewal thereafter.
In both the cases discussed here, user uses the same Apple Id, but consider the cases - same Apple Id different app id AND different Apple Id and same app Id. (See this)
For case 2, you should always refresh receipts or restore purchases(if there's no receipt available) for a fresh user login. The receipt has a original transaction id which you should have linked the first time the purchase was made with user A. Based on the receipt, you can either choose to let user B access the content or restrict. However, you cannot let the user pay for the new account(I suppose so).
Helpful Links:
Restoring Purchases
Receipt Validation

Differentiating two Users for In-App Purchases in Application to Buy Non-Renewable Subscription by different users?

I am implementing In-App Purchases first time in my application and new to In-app purchases Store Kit.
I have few doubts regarding In-app purchases:
What happens if a user purchased a subscription and logged out from the application and another user logs in and trying to purchase the same?
Does iTunes allow the second user to use the First user's purchased product?
If it allows how can we handle the second user's subscription?
What details we will get post Successful/Failed transactions from itunes to save in my database?
For a non-renewing subscription then it is entirely up to you to track expiration and determine what content a user has access to and when.
For example, say your subscription gave access to "the word of the day". If the subscription was active for the month of January, then the user would receive access to new words each day in January. The user should continue to be able to see January's words even after the subscription expires, but no new words.
If they resubscribe in March then they would now get new words throughout March.
You need to track all of this on your server against the user account.
Non-renewable subscription IAPs act much like consumable IAPs. The "Restore purchases" Store Kit function does not restore non-renewable IAP items.
To answer your specific questions:
If a new user logs in to your account system in the app (but the same iTunes account is still active on the device) then a second purchase will succeed and you need to update the subscription start and end dates for the new active account on your server.
You also need to cater for the following:
- The original account logs back in; In this case the original subscription entitlements need to be available
- The original or second account log in to another device; Again, the accounts subscription entitlements need to be available.
No, since non-renewing subscriptions are not restorable, the second user cannot "use" the first user's subscription.
You handle each account in your system independently.
Information about the mechanics of the purchase process are described in the In App Purchase Programming Guide

Is it possible for in app purchase in ios to use account specific subscription?

Is it possible for in app purchase in ios to use account specific subscription?
For example:
Let us say, I have one requirement that user have to subscribe to generate ticket (ticket is nothing but a secret code).
Now if user 'A' subscribe once from one device let say 'Device-1', then 'A' can login with other device let say 'Device-2', so in other device(Device-2) it should not be ask for purchase. Because 'A' is the same user who already subscribed in previous device (Device-1).
Apple track purchases as device specific not account.
Is there any way or any idea to achieve above problem?
No,apple only track the device based purchase
i had same type of problem but i have the backend with webapi service so i can handle with when the user purchase subscription then i will mark that user in our web server as their subscriber when he login into another device with that user-id i will manage to give them back their subscription.
cheers

Auto-renewable subscription model

Well, I am working on app, which is a basically free app to download, but the user has to sign-up through the app through an auto-renewable subscription.
Also every time when the user tries to log-in, my app will check for the subscription.
When the user tries to sign-up with the same user and but on another iOS device (with the different iTunes account), he/she has to buy the subscription again, as the device has the different iTunes account.
Along with that, if the user has bought the subscription from an Android device, he/she has to buy it again for the same username, if he/she wants to use it on an iOS devive and vice versa.
Now I am wondering whether this subscription model will be approved by Apple or not.
Or should I just change the subscription model to non-renewable subscription.
Thanks in advance.
-Shoan
Do you really want the user to pay for his subscription multiple times? Probably not...
You should manage the account on your server. If the user buys from the store when logged in, update your server data to reflect his extended membership. And it's your server that decides whether the subscription is still valid or not.
It really shouldn't matter which iTunes account or device he uses to buy/extend his membership.

Resources