4

So, Apple has implemented their server to server notification for various events in the subscription lifecycle.

I was very excited to get going on this but then it seems there is some sort of glaring thing I'm missing. I'm not sure how to match the notification data to a user on my side. I'm surprised there isn't a uid/apple id passed with the notification to match on. Maybe I'm supposed to be using the original_transaction_id but its unclear whether that is unique.

Does anyone know what to use in the status response?

jmichas
  • 1,139
  • 1
  • 10
  • 21
  • please let us know what setting you did for getting this "statusUpdateNotification" from Apple. Please help us here. Thanks – Sukeshj Aug 01 '17 at 10:40

2 Answers2

2

I use the original_transaction_id to match the event to a user.

Christian Brink
  • 663
  • 4
  • 18
  • Yeah, I guess this seems to be the thing to use. Some other sources say to use that and product id and it will ensure it is unique. Thanks! – jmichas Aug 01 '17 at 01:42
  • 1
    Question for you, though... Are you receiving notifications? I haven't actually received any notifications this way yet, despite having set up my notification URL in iTunes Connect almost 24 hours ago. And I know there have been both cancelations and reactivations since then. (I knew how to match up receipts with users in the way I describe above because my app needs to do so in another situation.) – Christian Brink Aug 01 '17 at 04:34
  • 3
    We are also not getting "statusUpdateNotification" from Apple server. We have checked Apple security norms and we are good for that. https://stackoverflow.com/questions/45433136/how-subscription-status-url-works-for-apple-in-app-purchases-auto-renewable – Sukeshj Aug 01 '17 at 10:37
  • 1
    Anybody who is successfully receiving these notifications: please tell us so here. – Christian Brink Aug 01 '17 at 16:04
  • @ChristianBrink: I received successfully this notification from apple. Should I write down answer for this question ? Or create a new topic? – Loint Aug 09 '17 at 10:55
  • Thanks Loint, I would love to know more. I just created this thread: https://stackoverflow.com/questions/45595499/how-have-you-configured-your-webhook-to-receive-apples-iap-status-change-notifi – Christian Brink Aug 09 '17 at 15:58
0

Apple will send to your server a receipt_data. In receipt_data will have original_transaction_id. But If you just only have original_transaction_id received from apple, you couldn't detect who is buyer this item. So in my opinion, Your server need store an unique id between original_transaction_id and user_id. When apple send receipt_data to hook that you set up to receive apple statusUpdateNotification, you will get user_id from match with original_transaction_id to put data into your database.

Loint
  • 3,560
  • 7
  • 26
  • 46
  • 1
    So how to match userId with original_transaction_id? – tounaobun Jan 08 '20 at 06:01
  • could not understand " get user_id from match with original_transaction_id" , in the server status notification how we can set user_id – Vivek Chaturvedi Jan 08 '20 at 08:43
  • 2
    How to determine the user from INITIAL_BUY server-sever notification? – HV Sharma Mar 09 '20 at 07:52
  • @HVSharma Did you find a solution to determine the user from INITIAL_BUY server-sever notification? – isuru Sep 16 '20 at 09:49
  • 2
    @isuru No, I was not determine user from INITAL_BUY. Instead, I created a POST API, which will be called when user purchases any subscription, in that you get receipt from front-end, you validate it with apple server, after that you check whether the receipt with that transaction_id & original_transaction_id exists or not, if not, I create the subscription for that particular user. I think that's what I did. yeah – HV Sharma Sep 16 '20 at 12:29
  • @HVSharma how did you handle subscription renewals then? – ZN123 Mar 13 '21 at 19:03
  • @ZN123 From what I can recall, you receive ```DID_RENEW``` event, and in that you match```original_transaction_id``` with the one you've stored in the user's row. – HV Sharma Mar 15 '21 at 18:03
  • @HVSharma, yes, but I'm asking about PurchaseQueue event on device. If you've hooked up your POST API call when transaction is finished, it will get called on renewal too, which is not needed since it was already done via notification. Where did you hook up initial buy post API call then? – ZN123 Mar 16 '21 at 19:10