iTunes purchase in Objective-C - in-app-purchase

Is there any way to purchase a song on iTunes programmatically using the user iTunes credentials (given for granted the user safely stores his account information inside the app)? In other words is it possible to automatise the in-app-purchase process if the user grants his permission?

Related

Login popup for In App Purchase (Automatically pick account for In App Purchase)

Am using In App Purchase in my app. It is working fine but client posted a requirement that, while purchasing it prompts a popup to enter a password of the account. But client says that it must not be the case account must be automatically picked up. like the following image.
Am not getting any solution regarding that please help me out.
Developers don't have any control over whether Apple prompts for a login or not when authorizing in-app purchases. If Apple needs account verification or if a user has certain settings enabled it will prompt for a password.

How to verify ios In-App Purchase with different account?

I'm developing an app with non-consumable products. My app need to register and log in for service.
I figure out that the products that user has bought are tied with Apple ID. If user use same Apple ID but different accounts from my server, how will I verify them whether the account buy the product or not?
I have used original_transaction_id to validate it.
Steps-
When any user make a payment, validate the receipt on server.
If a valid payment then update paid in your database and store
original_transaction_id of that receipt.
Next time if the user use same Apple ID, after validating the receipt, check if the original_transaction_id exists in the database or not. If already
exists means user is using same Apple ID for other accounts too,
else its using its Apple ID to make payment first time.

How to prevent same Apple ID usage for multiple users' in app purchases

I am developing cross-platform mobile app and using InAppBiling Plugin for my app's in app purchase feature but I have a question about below scenario on iOS:
Scenario:
User A gets the subscription with his app credentials and his Apple ID.
User B uses User A's device and login 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.
Thanks in advance
Your question is related to this one
You have to have backend that is your source of truth about subscriptions.
The situation that you have provided would look like this:
User A gets the subscription with his app credentials and his Apple ID.
You send receipt to your backend to validate it as described here
Your server stores information about subscription and link it with user A
User B uses User A's device and login with User B app credentials but uses User A's Apple ID to buy a subscription.
You send that receipt to your backend as in point 2
Your backend responds that this subscription is already connected with user A
Edit:
As mentioned in apple docs:
Send a copy of the receipt to your server along with some kind of
credentials or identifier so you can keep track of which receipts
belong to a particular user. For example, let users identify
themselves to your server with an email or user name, plus a password.

iOS inapp purchase subscription serverside validation security

The logic of the app.
You register with login password. Then if you doesn't have subscription (checked by server) you go to "Buy subscription page".
Problem.
I register user1. buy subscription. token1 goes to server.
I register user2. as he doesn't have subscription he goes to "Buy subscription page", clicks "Buy", apple says "You already bought subscription" and gives token2 (why does it give different token?)
var receiptUrl = NSData.FromUrl(NSBundle.MainBundle.AppStoreReceiptUrl);
return receiptUrl.GetBase64EncodedString(NSDataBase64EncodingOptions.None);
token2 goes to server. As a result we have 1 bought subscription but 2 users that use the same subscription.
Is there any way to identify itunes of user? to save along the token and be able to check if that itunes user already bought subscription for some server side account
This is a fundamental problem in StoreKit receipts and I think most developers don't realize it.
The problem is that Apple doesn't give developers a way to identify which iTunes account a receipt belongs to. This makes it trivial for a user to share their iTunes credentials with other users and unlock subscriptions.
The correct way to handle this is to, in your database, store the actual transaction_id from the Apple verifyReceipt response, and ensure it is unique in your database. This is a lot of work, so it may not be worth it.
It is further complicated by the fact that sometimes, you want an iTunes account to be usable with different app side accounts. For example if a user creates an account and purchases a subscription, lets the subscription expire, then later creates a new account and tries to purchase again, it should be permitted, even though the same receipt is now being used by multiple accounts.
If you don't want to deal with it, I have a service that handles all these edge cases automatically.

itunes connect sandbox user wants mail verification

I have added an user under sandbox testing in itunes connect to check IAP. After logged out from App store account, when I try to put the sandbox account it wants a mail verification. Whatever as far I know, it should be a dummy account.

Resources