|
@@ -267,20 +267,20 @@ class Pay extends Controller
|
|
|
public function validateApplePay()
|
|
|
{
|
|
|
$receipt_data = input('receipt_data'); //receipt_data参数
|
|
|
- if (!$receipt_data) $this->error('receipt_data参数错误');
|
|
|
+ if (!$receipt_data) return $this->resultT('receipt_data参数错误',0);
|
|
|
$order_no = input('order_no'); //订单号
|
|
|
- if (!$order_no) $this->error('订单号参数错误');
|
|
|
+ if (!$order_no) $this->resultT('订单号参数错误',0);
|
|
|
$order_type = input('order_type'); //订单类型 1订单 2充值
|
|
|
- if (!$order_type) $this->error('订单类型参数错误');
|
|
|
+ if (!$order_type) $this->resultT('订单类型参数错误',0);
|
|
|
$pay_money = input('pay_money'); //支付金额
|
|
|
- if (!$pay_money) $this->error('支付金额参数错误');
|
|
|
+ if (!$pay_money) $this->resultT('支付金额参数错误',0);
|
|
|
file_put_contents("validate_apple_pay_error.txt", $receipt_data . "\n", FILE_APPEND);
|
|
|
file_put_contents("validate_apple_pay_error.txt", $order_no . "\n", FILE_APPEND);
|
|
|
file_put_contents("validate_apple_pay_error.txt", $order_type . "\n", FILE_APPEND);
|
|
|
file_put_contents("validate_apple_pay_error.txt", $pay_money . "\n", FILE_APPEND);
|
|
|
// 验证参数
|
|
|
if (strlen($receipt_data) < 20) {
|
|
|
- $this->error("非法参数");
|
|
|
+ $this->resultT("非法参数",0);
|
|
|
}
|
|
|
// // 请求验证
|
|
|
$html = $this->acurl($receipt_data);
|
|
@@ -301,9 +301,9 @@ class Pay extends Controller
|
|
|
$result['out_trade_no'] = $order_no;
|
|
|
$return = $this->dealData($result);
|
|
|
if ($return){
|
|
|
- $this->success("操作成功");
|
|
|
+ $this->resultT("操作成功",1);
|
|
|
}else{
|
|
|
- $this->error("操作失败");
|
|
|
+ $this->resultT("操作失败",0);
|
|
|
}
|
|
|
break;
|
|
|
case '2':
|
|
@@ -325,25 +325,25 @@ class Pay extends Controller
|
|
|
->update($order_upd);
|
|
|
$this -> addMoney($order['mem_id'],$order['money']);
|
|
|
Db::commit();
|
|
|
- $this->success("购买成功");
|
|
|
+ $this->resultT("购买成功",1);
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
|
$msg = $e->getMessage();
|
|
|
- $this->error($msg);
|
|
|
+ $this->resultT($msg,0);
|
|
|
}
|
|
|
}else{
|
|
|
- $this->error('金额验证失败');
|
|
|
+ $this->resultT('金额验证失败',0);
|
|
|
}
|
|
|
}else{
|
|
|
- $this->error('订单状态错误');
|
|
|
+ $this->resultT('订单状态错误',0);
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
- $this->error('订单类型错误');
|
|
|
+ $this->resultT('订单类型错误',0);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- $this->error("购买失败".$data['status']);
|
|
|
+ $this->resultT("购买失败".$data['status'],0);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -376,4 +376,10 @@ class Pay extends Controller
|
|
|
curl_close($ch);
|
|
|
return $result;
|
|
|
}
|
|
|
+ protected function resultT($msg,$code){
|
|
|
+ $result = ['msg' => $msg, 'code' => $code];
|
|
|
+ header('Content-Type:application/json; charset=utf-8');
|
|
|
+ echo json_encode($result);
|
|
|
+ die;
|
|
|
+ }
|
|
|
}
|