1
This commit is contained in:
@@ -59,7 +59,10 @@ class Order extends base{
|
||||
return jsonError("Paystation responds with no results or result fail");
|
||||
}
|
||||
$tid = $data['transaction_id'];
|
||||
$paystation_info = $this->paystation_obj->where("transaction_id",$tid);
|
||||
$paystation_info = $this->paystation_obj->where("transaction_id",$tid)->find();
|
||||
if (!$paystation_info){
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
$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]);
|
||||
@@ -173,9 +176,21 @@ class Order extends base{
|
||||
$re['paystation'] = null;
|
||||
return jsonSuccess($re);
|
||||
}else{
|
||||
$re['detail'] = $check;
|
||||
$re['paypal'] = null;
|
||||
$re['paystation'] = $check['ps_id']==0?null:$this->paystation_obj->where("ps_id",$check['ps_id'])->find();
|
||||
$paystation_res = $this->creatPaystation($article_info['article_id']);
|
||||
$ps_insert['transaction_id'] = $paystation_res['transaction_id'];
|
||||
$ps_insert['session_id'] = $paystation_res['session_id'];
|
||||
$ps_insert['paystation_id'] = $paystation_res['paystation_id'];
|
||||
$ps_insert['currency'] = $paystation_res['currency'];
|
||||
$ps_insert['amount'] = $paystation_res['amount'];
|
||||
$ps_insert['merchant_session'] = $paystation_res['merchant_session'];
|
||||
$ps_insert['request_time'] = $paystation_res['request_time'];
|
||||
$ps_insert['payment_url'] = $paystation_res['payment_url'];
|
||||
$ps_insert['data'] = json_encode($paystation_res);
|
||||
$ps_id = $this->paystation_obj->insertGetId($ps_insert);
|
||||
$this->order_obj->where("order_id",$check['order_id'])->update(['ps_id'=>$ps_id,"paystation_url"=>$paystation_res['payment_url']]);
|
||||
$re['paystation'] = $this->paystation_obj->where("ps_id",$ps_id)->find();
|
||||
$re['detail'] =$this->order_obj->where("order_id",$check['order_id'])->find();
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
}
|
||||
@@ -247,6 +262,27 @@ class Order extends base{
|
||||
}
|
||||
|
||||
|
||||
private function creatPaystation($article_id){
|
||||
$article_info = $this->article_obj->where("article_id",$article_id)->find();
|
||||
$journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find();
|
||||
$ca_sn = 'TMR'.date('Ymd') . strtoupper(bin2hex(random_bytes(8)));
|
||||
$accessToken = createPayStationToken();
|
||||
$data_array = [
|
||||
'paystation_id' => Env::get("paystation.client_id"),
|
||||
'gateway_id' => "PAYSTATION",//GATEWAY_ID,
|
||||
"merchant_session" => $ca_sn,
|
||||
"merchant_reference"=>$ca_sn,
|
||||
"amount" =>(int)((((int)$journal_info['fee'])*726/416)*100),
|
||||
"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);
|
||||
$purchase = postPayStationQuery('v1/hosted/purchases', $accessToken, $data);
|
||||
$paystation_res = object_to_array(json_decode($purchase));
|
||||
return $paystation_res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getUserOrder(){
|
||||
$data = $this->request->post();
|
||||
|
||||
Reference in New Issue
Block a user