I want to send the userId of my application with the inApp Purchase so that the transaction ID that I get after successful inApp purchase, I be able to know the userId of the user who purchased that product from Apple's server using the transaction ID. Is this possible ? or something related to it ?
Related
I am implementing auto renewable subscription in my iOS application. Monthly subscription auto renews after 5 mins in sandbox mode. I have added transaction observer in appDelegate. So when app restarts updated transaction method gets called and i m getting following logs.
payment store product purchased il_pkg1_1month_2
payment storee product purchased transaction id Optional("1000000792969469")
payment store product purchased il_pkg1_1month_2
payment storee product purchased transaction id Optional("1000000792972183")
payment store product purchased il_pkg1_1month_2
payment storee product purchased transaction id Optional("1000000792976003")
payment store product purchased il_pkg1_1month_2
payment storee product purchased transaction id Optional("1000000792978690")
payment store product purchased il_pkg1_1month_2
payment storee product purchased transaction id Optional("1000000792982052")
My questions are
1)This method is not getting called when app is open and transaction is renewed. is this correct behaviour?
I am planning to implement verification of receipt when this Method is called (on server side). So Suppose when i open app and transaction is auto renewed multiple times.Do i need to implement verify receipt for each transactions or the latest one only? How to verify receipt if app is open and transaction is auto renewed?
3)I have 3 kind of plans in same subscription group. I am not able to upgrade/downgrade in sandbox mode, is it possible to test upgrade/downgrade in sandbox mode?
4)After subscription has expired, if i renew subscription from manage subscription page updated transaction method is called but i m getting same transaction as before renewal.Even transaction expiry date is same as before renewal. Is this correct behaviour, do i need to do any additional things.
Any help would be appreciated.
That is the expected behaviour, also note that with each of the subsequent purchases there is an original_transaction_id so you can tell what the original purchase was.
Whenever you call your server receipt verification, you send up the receipt data the app has currently, and Apple always returns the very latest receipt info. So you can call Apple whenever you like to verify a subscription is still active, or an any subsequent transition to verify a re-subscriptiuon happened. You can also store the data from the app receipt on the server to check from time to time only on the server side, to verify a subscription is still active and has not been cancelled.
I think you used to be able to upgrade/downgrade in sandbox, if not from the sandbox account editing page in device settings, then try by allowing a downgrade/upgrade purchase in your app. At the very least I believe it should work using Xcode 12 App Store configuration local StoreKit testing.
I am not sure if that behaviour you are seeing is normal, If you subscribe after a subscription has lapsed, it should behave like a new purchase - but would still have an original_transaction_id of the original subscription.
I have implemented inapp purchase in my application. but i have problem i don't have any login part in my application. and i want to store transaction history for particular user on my server. but how would i get apple id for my sucessful transaction. i need any unique id for particular user. who do inapp purcahse.
and another question is that i have non consumable in app purcahse for that we need to do SKPaymentQueue.default().restoreCompletedTransactions(). there is no any restore button in my application so where should i do restore functionality.
We're using in-app purchases in our app and validating receipts on server side.
As a result of validation we get Receipt object described here. We store the transaction_id in our records as a unique identifier of the purchase.
Then, some time after the purchase a user who made a purchase in our app looks at Purchase History in the iTunes app and see this identifiers:
Question:
How can we match this identifiers with the validated receipt?
For example, it's useful in the case when users contact us via support channels and want to restore their accounts.
I had successfully implemented in-app purchase in my application.
My query is :
There is One apple id xyz#apple.com through which i am logged in to itunes in ipad or device.
now in my application there are several users. They will purchase products through in-app purchase. my product is non-consumable.
Now, for example there are two user A and B (they logged in to my application so they are application users).
case : user A purchase product using in-app purchase with apple id xyz#apple.com and get user rights of purchased product member (here on success of completion of payment i call web service to make user database update that he/she had purchased product) and logout from my application. Now User B logged in to my application and going to purchase product as well as User A purchased (here Note that the apple id is same xyz#apple.com). But while he trying to purchase product apple says that “you've already purchased this.Tap OK to download it again for free” so user tap OK and this product will again restore as per user and again on success of that method i call web service which make user database update.
so question is how can i differ both user while purchasing product that from this id (i.e. xyz.apple.com) you had already purchased and now user should be different then you have to login using another apple id (may be abc.apple.com).
finally i solved in app purchase issue with the following solution :
1) i get transaction id and update it with the database as per user if transaction id founds duplicate then it will throw error and don’t make user as a paid member.
Means when A user make purchase then i get it's transaction_id and update it to data base as Username : A and transaction_id : XYZ.
and if B user going to purchase from same iTunes id then i will get same transaction_id that is XYZ. So here it will not allow user to be proceed(i.e. from web service don't let user to be paid member and give error). following is code:
-(void)callinApp : (SKPaymentTransaction*) transaction
{
if (transaction.originalTransaction.transactionIdentifier == nil)
{
// send transection.transactionIdentifire
// means it's first time purchasing
NSLog(#"Transection Id : %#",transaction.transactionIdentifier);
UserId = A123;
TransectionID = transaction.transactionIdentifier;
}
else
{
// send transaction.originaltransection.transectionidentifier
// means already purchased one in past
NSLog(#"Original Transection Id:%#",transaction.originalTransaction.transactionIdentifier);
UserId = A123;
TransectionID = transaction.originalTransaction.transactionIdentifier;
}
// call web service and pass TransectionID & UserId
}
2) The error which was coming while doing transaction from another iTunes id the method (updateTransaction) calling multiple time i solved that by removing that apple(iTunes) id from sandbox tester in iTunes connect.
Non-consumable products are purchased once by users and do not expire or decrease with use.
even thought if you are looking for flow that how to match between login user id and in app purchase id. actually i did in App Purchase long times ago so i don't know what parameter sent from apple once in app purchase succeeded. there may be in-app purchase receipt and some other parameter as well. just need to pickup unique parameter that is same for number of time once product downloaded from same user.
So here i am consider "in-app purchase receipt" as unique parameter return once in App purchase succeeded. and once in App purchase succeeded, you can bind in-app purchase receipt with login user id on your sever. so next time when B user going to download same product with same apple user id, in App purchase request will return same in-app purchase receipt so check that weather this receipt id is bind with another login id, if YES then cancel download and show message to user that "This account is already linkup with some other login id".
I am implementing the In-App Purchase in iOS and the server want me to: "when buying something, I send some extra arguments such as user id, game zone id, and our unique order id with the product identifier, after the purchase success, Apple server send these value back". Can this be implemented?
For this you can send all the details you want just after receiving success message of In App purchase. For unique order Id you can just use UUID of the device.