1

There is my architect system about in app purchase feature.

enter image description here

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 and user_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 get original_transaction_id, but if just only have original_transaction_id , my system will can't know to update for someone, so I need to query from my database with original_transaction_id and get user_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 this original_transaction_id for user_id. )

  • If Hook can get user_id from database with original_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.

Loint
  • 3,560
  • 7
  • 26
  • 46
  • 1
    Your server can effectively ignore `INITIAL_BUY` messages since you will receive subscription notification from your client that contains the receipt and your user id. For renewal events your server will know the user id – Paulw11 Sep 14 '18 at 07:51
  • @Paulw11: Do you mean when an event `INITIAL_BUY` comes , basically my server wil ignore this message and apple will send bill to my client? – Loint Sep 14 '18 at 07:59
  • 1
    Yes, you could ignore it or you could save the receipt and wait for the message from your client 3(1) that will contain the same receipt and the user id – Paulw11 Sep 14 '18 at 08:01
  • @Paulw11: I should put this apple's notify back my queue ( I use RabbitMQ such as a message broker ) or reject this message and remove out queue ?. Or back to queue to wait retry event execute ? :3 – Loint Sep 14 '18 at 08:18
  • 1
    You can probably just discard it since you will get the message from your client App anyway – Paulw11 Sep 14 '18 at 08:24

0 Answers0