1
This commit is contained in:
@@ -53,69 +53,17 @@ class Order extends base{
|
||||
}
|
||||
|
||||
|
||||
public function completePaystation(Request $request){
|
||||
|
||||
// 获取请求的原始数据(Paystation 发送的 payload)
|
||||
$payload = $request->getContent();
|
||||
|
||||
|
||||
$filePath = ROOT_PATH . '/payload_log.txt';
|
||||
|
||||
// 将payload写入文本文件
|
||||
file_put_contents($filePath, $payload . PHP_EOL, FILE_APPEND);
|
||||
|
||||
|
||||
|
||||
// 获取请求头
|
||||
// $headers = $request->header();
|
||||
//
|
||||
// // 获取HMAC签名和时间戳
|
||||
// $hmac_signature = $headers['x-signature'] ?? '';
|
||||
// $timestamp = $headers['x-timestamp'] ?? '';
|
||||
//
|
||||
// // 使用HMAC密钥验证签名
|
||||
// $get_hmac = hash_hmac('sha512', $timestamp . $payload, config('paystation.HMAC_KEY'));
|
||||
//
|
||||
// if ($hmac_signature != $get_hmac) {
|
||||
// Log::error('HMAC验证失败', ['timestamp' => $timestamp, 'hmac_signature' => $hmac_signature, 'calculated_hmac' => $get_hmac]);
|
||||
// return 'HMAC verification failed';
|
||||
// }
|
||||
|
||||
// 解析JSON格式的payload
|
||||
$data = json_decode($payload);
|
||||
|
||||
|
||||
|
||||
|
||||
// 检查result字段是否为空
|
||||
if (empty($data->result)) {
|
||||
return jsonError("Paystation responds with no results");
|
||||
} else {
|
||||
// 交易成功或失败的处理
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($data->result->success) {
|
||||
public function completePaystation(){
|
||||
$data = $this->request->post();
|
||||
if(!isset($data['transaction_id'])|| !$data['result']['success']){
|
||||
return jsonError("Paystation responds with no results or result fail");
|
||||
}
|
||||
$tid = $data['transaction_id'];
|
||||
$paystation_info = $this->paystation_obj->where("transaction_id",$tid);
|
||||
$order_info = $this->order_obj->where("ps_id",$paystation_info['ps_id'])->find();
|
||||
$this->article_obj->where("article_id",$order_info['article_id'])->update(['is_buy'=>1]);
|
||||
$this->order_obj->where("order_id",$order_info['order_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
} else {
|
||||
return jsonError('Transaction failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// $sn = $request->param("sn");
|
||||
// $order_info = $this->order_obj->where("order_sn",$sn)->find();
|
||||
//
|
||||
// $this->article_obj->where("article_id",$order_info['article_id'])->update(['is_buy'=>1]);
|
||||
// $this->order_obj->where("order_sn",$order_info['order_sn'])->update(['state'=>1]);
|
||||
//
|
||||
// return jsonSuccess([]);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +177,7 @@ class Order extends base{
|
||||
"merchant_reference"=>$ca_sn,
|
||||
"amount" =>(int)((((int)$journal_info['fee'])*726/416)*100),
|
||||
// "currency"=>"USD",//目前paystation仅支持nzd
|
||||
"return_url"=>"https://www.tmrjournals.com/",
|
||||
"return_url"=>"https://submission.tmrjournals.com/success?id=".$article_info['article_id'],
|
||||
"response_url"=>"http://api.tmrjournals.com/public/index.php/api/Order/completePaystation"
|
||||
];
|
||||
$data = json_encode($data_array);
|
||||
|
||||
@@ -689,6 +689,9 @@ class Preaccept extends Base
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
$order_info = $this->order_obj->where("article_id",$article_info['article_id'])->find();
|
||||
if($order_info['pay_type']==2){
|
||||
$order_info['paystation'] = $this->paystation_obj->where("ps_id",$order_info['ps_id'])->find();
|
||||
}
|
||||
$re['state'] = $order_info?$order_info['state']:0;
|
||||
$re['fee'] = $journal_info['fee'];
|
||||
$re['order'] = $order_info;
|
||||
|
||||
@@ -172,7 +172,7 @@ return [
|
||||
// 日志保存目录
|
||||
'path' => LOG_PATH,
|
||||
// 日志记录级别
|
||||
'level' => [],
|
||||
'level' => ['error'],
|
||||
],
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user