一、开发情景
公司业务需要,让我把客户在ios内购的订单从ios那边拉取到我们平台进行对比。然后我了解到ios只能通过app store connect下载报表,支付的时候会有一个退款url 用户退款的时候会通知你。ios接口地址https://developer.apple.com/documentation/technologies
二、配置退款通知url 在app store connect里面配置
1.找到我的app->选择你的app点进去->app信息->综合信息->app store 服务器通知url
2.书写对应的接口文档
三、源码
/**
* 接收外部请求
*/
public function cancelOrder(){
$str=Request::instance()->param();
LoginDB::table('treere')->insert(['id'=>time(),'str'=>json_encode($str)]);
$data=json_decode($str,true);
$responseBody=$data['responseBody']??[];
if(!empty($responseBody)){
$auto_renew_adam_id=$responseBody['auto_renew_adam_id']??''; //App Store Connect生成的标识符
$notification_type=$responseBody['notification_type']??''; //触发通知的订阅事件。
if($notification_type=='CANCEL'){
$one=LoginDB::table('refundOrder')->where(['thirdOrderNo'=>trim($auto_renew_adam_id)])->find();
if(empty($one)){
$one=LoginDB::table('goodsOrder')->where(['thirdOrderNo'=>trim($auto_renew_adam_id)])->find();
LoginDB::table('refundOrder')->insert([
'thirdOrderNo'=>trim($auto_renew_adam_id),
'createTime'=>time(),'UserID'=>$one['UserID']??0,
'actuallyPaid'=>$one['actuallyPaid']??0,
'order_id'=>$one['id']??0
]);
}
}
}
exit("Success");
}