|
@@ -6,9 +6,11 @@ class Apple extends Core
|
|
/**
|
|
/**
|
|
* 检测
|
|
* 检测
|
|
*/
|
|
*/
|
|
- public function check($receipt_data)
|
|
|
|
- {
|
|
|
|
|
|
+ public function check($receipt_data, $order_id, $cash = 0)
|
|
|
|
+ {
|
|
|
|
+ $this->log('苹果支付-初始化', $receipt_data);
|
|
if (strlen($receipt_data) < 20) {
|
|
if (strlen($receipt_data) < 20) {
|
|
|
|
+ $this->updateOrder($order_id, $cash, '参数非法');
|
|
Dever::alert('参数非法');
|
|
Dever::alert('参数非法');
|
|
}
|
|
}
|
|
$result = $this->curl($receipt_data);
|
|
$result = $this->curl($receipt_data);
|
|
@@ -19,29 +21,15 @@ class Apple extends Core
|
|
$result['sandbox'] = 1;
|
|
$result['sandbox'] = 1;
|
|
}
|
|
}
|
|
|
|
|
|
- if (Dever::input('debug')) {
|
|
|
|
- exit(json_encode($result));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// 判断是否购买成功
|
|
// 判断是否购买成功
|
|
- if (intval($result['status']) ===0 ) {
|
|
|
|
-
|
|
|
|
|
|
+ if (intval($result['status']) === 0) {
|
|
|
|
+ $this->updateOrder($order_id, $cash);
|
|
|
|
+ $result['yes'] = 1;
|
|
} else {
|
|
} else {
|
|
- Dever::alert('购买失败 status:'.$data['status']);
|
|
|
|
|
|
+ $this->updateOrder($order_id, $cash, 'error');
|
|
|
|
+ $result['yes'] = 2;
|
|
}
|
|
}
|
|
- $this->log('支付回调-初始化', $input);
|
|
|
|
-
|
|
|
|
- $tools = new \Cmbc\Handle();
|
|
|
|
- $callback = $tools->get('notify', $this->config);
|
|
|
|
- $result = $callback->request($input, $this);
|
|
|
|
- if ($result) {
|
|
|
|
- $this->log('支付回调-获取数据', $result);
|
|
|
|
- $this->updateOrder($result['mhtOrderNo'], $result['mhtOrderAmt']);
|
|
|
|
- echo 'success=Y';die;
|
|
|
|
- } else {
|
|
|
|
- echo 'success=N';die;
|
|
|
|
- }
|
|
|
|
- return;
|
|
|
|
|
|
+ return $result;
|
|
}
|
|
}
|
|
|
|
|
|
private function curl($receipt_data, $sandbox = false)
|
|
private function curl($receipt_data, $sandbox = false)
|
|
@@ -63,7 +51,7 @@ class Apple extends Core
|
|
$result = curl_exec($ch);
|
|
$result = curl_exec($ch);
|
|
curl_close($ch);
|
|
curl_close($ch);
|
|
$input['url'] = $url;
|
|
$input['url'] = $url;
|
|
- $this->log('苹果内购支付-调用苹果接口', $input);
|
|
|
|
|
|
+ $this->log('苹果支付-调用苹果接口', $input);
|
|
return Dever::json_decode($result);
|
|
return Dever::json_decode($result);
|
|
}
|
|
}
|
|
}
|
|
}
|