小bug修复

This commit is contained in:
wangjinlei
2025-11-13 13:15:42 +08:00
parent 0e7f0e45e0
commit e65359433d
3 changed files with 433 additions and 37 deletions

View File

@@ -81,26 +81,87 @@ class Order extends base{
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$time = time();
$param = "pi=616562&ms=".$data['ms'];
$hmac = hash_hmac('sha512', $time."paystation".$param, Env::get("paystation.hmac"));
$url = "https://payments.paystation.co.nz/lookup?".$param."&pstn_HMAC=".$hmac."&pstn_HMACTimestamp=".$time;
$url = "https://payments.paystation.co.nz/lookup?".$param;
$res = myGet($url);
return jsonSuccess($res);
}
public function testtest(){
public function testPaystationLookup1(){
$data = $this->request->post();
$rule = new Validate([
"id"=>"require"
"transaction_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$res = paystationLookup($data['id']);
return jsonSuccess(object_to_array(json_decode($res)));
// $accessToken = createPayStationToken();
// $curl = curl_init();
// curl_setopt_array($curl, array(
// CURLOPT_URL => 'https://api.paystation.co.nz/v1/transactions/'.$data['transaction_id'],
// CURLOPT_RETURNTRANSFER => true,
// CURLOPT_ENCODING => '',
// CURLOPT_MAXREDIRS => 10,
// CURLOPT_TIMEOUT => 0,
// CURLOPT_FOLLOWLOCATION => true,
// CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
// CURLOPT_CUSTOMREQUEST => 'GET',
// CURLOPT_HTTPHEADER => array(
// 'Content-Type: application/json',
// 'Authorization: Bearer '.$accessToken
// )
// ));
// $response = curl_exec($curl);
// curl_close($curl);
$response = paystationLookup($data['transaction_id']);
$res = object_to_array(json_decode($response));
return jsonSuccess($res);
}
public function testPays(){
$data = $this->request->post();
$rule = new Validate([
"ms"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$url = "https://payments.paystation.co.nz/lookup/";
$time = time();
$params = [
"pi" => "616562",
"ms" => $data['ms'],
"pstn_HMACTimestamp" => $time
];
$secret_key = Env::get("paystation.hmac");// 使用提供的HMAC认证密钥
// function calculate_hmac($key, $message) {
// return hash_hmac('sha256', $message, $key);
// }
$query_string = http_build_query($params);
$hmac_signature = hash_hmac('sha256', $time."paystation".$query_string,$secret_key);
$params["pstn_HMAC"] = $hmac_signature;
$url_with_params = $url . '?' . http_build_query($params);
echo $url_with_params;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_with_params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
if(curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo "Response: " . $response;
}
curl_close($ch);
return jsonSuccess($response);
}
@@ -263,12 +324,6 @@ class Order extends base{
return jsonSuccess($frag);
}
public function myPrin(){
echo prin(600);
}
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();
@@ -377,20 +432,6 @@ class Order extends base{
return jsonSuccess([]);
}
public function mytest(){
$data = $this->request->post();
$rule = new Validate([
"order_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$info = $this->order_obj->where("order_id",$data['order_id'])->find();
$re = $this->getOrderStatus($info['paypal_order_id']);
return jsonSuccess($re);
}
private function getOrderStatus($orderId){
$client = $this->createClient();
return $client->getOrdersController()->ordersGet(["id"=>$orderId]);