📜 ⬆️ ⬇️

We make payments iOS AppStore with checking on the server

Good day, Habrovchane!
I read a lot of information on payments for this good mobile OS. But I did not find any normal and understandable examples, so I decided to write about my experience.
Want to know more - welcome under cat.

So.
I only do back-end, so I’m not going to write about front-end development.
On our server we do the most common handler of http requests.
From the client we need the following data:
1 - user ID for internal transaction
2 - Receipt - data from Apple.

In processing, we accept this data and make a request to Apple to verify the validity of the data.
I give an example of the handler in Python.
import requests //   bundle_id = "com.MyCompany.MyApp" // URL     (   ). //      : "https://buy.itunes.apple.com/verifyReceipt" url = "https://sandbox.itunes.apple.com/verifyReceipt" //     receipt = GetRequestParam("receipt") //    Apple resp = requests.post(url,receipt) response = resp.json() //    if response["status"] != 0: return "Error" response = response["receipt"] //        if response["bundle_id"] != bundle_id: return "Error" //    package = response["in_app"][0] productId = package["product_id"] transaction_id = package["transaction_id"] UserID = GetRequestParams("UserID") //      //    . //     ,    


Here is the simplest example of payment processing.
Everything is simple and clear.
Use. Thank.

')

Source: https://habr.com/ru/post/254257/


All Articles