10

How can a server determine the amount of an iphone in-app purchase ?

The server receives the purchase's receipt sent by the app and uses this to validate it.

This returns some informations like a transaction_id, product_id, etc; but no amount or user details.

Since the amount depends on the currency and the user's country, how can I get the amount of the purchase on the server ?

sfelber
  • 888
  • 8
  • 23
Arnaud Le Blanc
  • 98,321
  • 23
  • 206
  • 194

2 Answers2

2

From the same document, you can get product details localized through the SKProduct class, check this

If you are asking about how do the server knows it, when you setup an in-app purchase on the server you choose the price as tier, each tier has the price in different currencies so when you send the in-app purchase product id in the request, it check its price you setup and reflects it in the corresponding currency.

For device locale, check this and for device language check this but to get it from the server itself, Apple doesn't provide an API for it.

Community
  • 1
  • 1
XIII
  • 2,036
  • 16
  • 25
  • So how do I know the price of a trier ? (given that it depends on the the country the user has entered in his itunes account apparently) – Arnaud Le Blanc Jul 17 '12 at 15:53
  • It's all arranged in tables on iTunes connect portal, an example is first tier: $.99, .70 Euro, ¥85,..etc, you can also find it in the developer agreement. – XIII Jul 17 '12 at 15:55
  • 2
    Is there any way to get user's country and currency then ? – Arnaud Le Blanc Jul 17 '12 at 16:00
  • Sorry, but what is the purpose for that? You just send the request with the product id and it takes care of the rest depending on the user apple id "iTunes appstore account". – XIII Jul 17 '12 at 16:01
  • 1
    I would like to do usual things like create sales reports with prices, without having to go to the iTunes store. – Arnaud Le Blanc Jul 17 '12 at 16:03
  • 2
    In this case I would recommend this answer: http://stackoverflow.com/questions/1619172/itunes-connect-api – XIII Jul 17 '12 at 16:07
1

Now it is possible to set a different price for each country so the mapping of in app purchase to a pricing tier can be cumbersome.

You can get the price as the user see it in the UI and the price locale from the client and then send that information to your server.

For renewals - You can see renewals by verifying the receipt data on the server side and use the price sent by the client in the first transaction.

little
  • 2,927
  • 2
  • 25
  • 36