There is my architect system about in app purchase feature.
My in app purchase includes the compoments such as:
Client: My mobile application.
Server: My server system.
Apple's Store : Apple's store that connect to iTunes connect configured to in app purchase.
Hook statusUpdateNotification: A statusUpdateNotification
is a server-to-server notification service for auto-renewable subscriptions. A notification specifies the status of a subscription at the time the notification is sent. reference link : https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html#//apple_ref/doc/uid/TP40008267-CH7-SW6
Database: My database system.
The current workflow:
- Step 1 : Mobile app request to payment to apple's store via
ios's Storekit
and user's ituneconnect when user buy an item in app. - Step 2(1) : Apple's store charged for user if
product_id
match with store and return for mobile app a bill. - Step 3(1) : Mobile app send this bill to server with authentication to server know who is buyer. Server will validate bill with apple's store by step 5(1) , if bill valid , apple's store will response result to notify that this bill valid ( step 4(1) ) and server will update this product for user, moreover server will store an unique
bill_id
anduser_id
to renewable next time---------- step 6(1). And server will response for client to exit process ( step empty number ) => the first way to purchase success.
In solution this item is renewable , the system will use Hook statusUpdateNotification system.
Step 1 : The same action above.
Step 2(2) : Apple's store will deliver JSON objects via an HTTP POST to your server for the key subscription events listed in Table 6-3. My problem start at here. . Apple will send for hook with a
latest_receipt_info
and I can parsing to getoriginal_transaction_id
, but if just only haveoriginal_transaction_id
, my system will can't know to update for someone, so I need to query from my database withoriginal_transaction_id
and getuser_id
stored ( step 3(2)) before ( step 3(1) if luckey because if hook received receipt_info from apple before client send bill to server, I don't know thisoriginal_transaction_id
foruser_id
. )If Hook can get
user_id
from database withoriginal_transaction_id
, my purchase process will success. Otherwise my system will fail because I can't know user will be updated bought product.
I don't sure when apple's store will send bill to my client and when it will send to hook. It's suck.
My question: My solution is exactly? Anyone have solution to improve this problem? thank you. Please provide request take clear information if you don't understand any my description.