This commit is contained in:
wangjinlei
2025-02-24 09:24:50 +08:00
parent 2ed8c60fe9
commit 3620475d2d
3 changed files with 172 additions and 57 deletions

View File

@@ -1130,7 +1130,7 @@ class Preaccept extends Base
$accessToken = $this->payStationAccessToken();
$data_array = [
'paystation_id' => Env::get("paystation.client_id"),
'gateway_id' => "v1",//GATEWAY_ID,
'gateway_id' => "PAYSTATION",//GATEWAY_ID,
'merchant_session' => "myTestSN001",
// 'merchant_reference' => 'testReference',
'amount' => 2000, //$20 in cents value
@@ -1165,35 +1165,15 @@ class Preaccept extends Base
$accessToken = $this->payStationAccessToken();
$data_array = [
'paystation_id' => Env::get("paystation.client_id"),
'gateway_id' => "v1",//GATEWAY_ID,
"order_name" => "mytestOrderSn",
"amount" =>200,
'gateway_id' => "PAYSTATION",//GATEWAY_ID,
"order_name" => "mytestOrderSn11",
"amount" =>100,
"test_mode"=>true
];
$data = json_encode($data_array);
$purchase = $this->postRequest('v1/payme/purchases', $accessToken, $data);
return jsonSuccess($purchase);
}
public function patStationReturn(){
$query_string = $_SERVER['QUERY_STRING'];
parse_str($query_string, $data);
if (isset($data['code'])) {
// Add code here to display result
// Do not update transaction status here because query strings can be manipulated
// Do a transaction lookup instead to verify the results. Check documentation for more details.
if ($data['code'] == '0') {
echo 'Transaction ok: ' . $data['message'];
} else {
echo 'Transaction failed: ' . $data['message'];
}
}
$r= object_to_array(json_decode($purchase));
return jsonSuccess($r);
}
private function payStationAccessToken(){
@@ -1201,7 +1181,7 @@ class Preaccept extends Base
'client_id' => Env::get("paystation.client_id"),
'client_secret' => Env::get("paystation.client_secret"),
'grant_type' => 'client_credentials',
'scope' => "mytest"
'scope' => "read write"
];
$accessTokenUrl = Env::get("paystation.api_url") . '/oauth/token';
$curlHandle = curl_init($accessTokenUrl);