IOS:Auto renewable In App Purchase server to server notification parsing issue

懵懂的女人 提交于 2021-01-07 02:53:57

问题


I am unable to parse app store auto renewable purchase notification.I am only to get notification_type, but other fileds i am unable parse from server notification. my php code:

<?php

$input =json_decode(file_get_contents('php://input'), true);

$responseBody = $input['unified_receipt']['latest_receipt_info'][0]->original_transaction_id;
$notification_type = $input['notification_type'];

$sql="INSERT INTO testAppServerNotification (notification_type,notification) VALUES('$notification_type','$responseBody')";
$result=$conn->query($sql);
if($result){
   echo "success";
 }else{
     error_log("fail" . $conn->error);
 }
?>

回答1:


The boolean in json_decode() defines that json objects should be decoded as associative arrays instead of objects. Hence you access the orignal_transaction_id wrong.

You have to do like this:

$responseBody = $input['unified_receipt']['latest_receipt_info'][0]["original_transaction_id"];

This way you should be able to parse the notification.

If you want to learn more about the structure of server notifications, here is the documentation from Apple.



来源:https://stackoverflow.com/questions/65265197/iosauto-renewable-in-app-purchase-server-to-server-notification-parsing-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!