先正式环境测试,若是返回21007,则去测试环境验证,不管怎样,最终都是到测试环境下购买
/**
*1、 获取苹果内购验证数据
*/
public function getReceiptDataAction(){
$token = _post('token');
$apple_receipt = _post('apple_receipt'); //苹果内购的验证收据,由客户端传过来
if(empty($apple_receipt)) $this->error_callback('参数不能为空');
$jsonData = array('receipt-data' => $apple_receipt);//需要base64加密的,前端返回服务器端之前,已经作加密处理
$jsonData = json_encode($jsonData);
$url = 'https://buy.itunes.apple.com/verifyReceipt'; //正式验证地址
$response = $this->apple_post_data($url, $jsonData);
if($response->{"status"} == '0'){
$responseData = json_encode($response);
writeLog($responseData,'apple/getReceiptData1');
//苹果内购验证成功后的后续操作
$receipt = json_decode($responseData,true);
$in_app = $receipt['receipt']['in_app'];
writeLog(json_encode($in_app),'apple/getReceiptInApp1');
$this->dealVipMemberData($in_app);
$this->success_callback('验证成功');
}else if($response->{"status"} == '21007'){//收据信息是测试用(sandbox),但却被发送到产品环境中验证
$sandb