This commit is contained in:
wangjinlei
2025-02-18 11:00:38 +08:00
parent bd5f4fa187
commit a38b143c9f
4 changed files with 157 additions and 7 deletions

5
.env
View File

@@ -9,6 +9,11 @@ editor_email = publisher@tmrjournals.com
;读取的企业邮箱
mail_server = imap.qq.com
[paystation]
api_url = https://api.paystation.co.nz
client_id = 616562
client_secret = CfMDrllyqBTFKrUkO2XaE7OmWTYqP3yd
[journal]
;官网服务器地址

View File

@@ -1907,7 +1907,9 @@ class Article extends Base
$tt .= 'Email:' . $journal_info['email'] . '<br>';
$tt .= 'Website:' . $journal_info['website'];
sendEmail($reviewer_info['email'], $journal_info['title'], $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
$email_title = "Invitation to review manuscript for ".$journal_info['title']."-[".$article_info['accept_sn']."]";
sendEmail($reviewer_info['email'], $email_title, $journal_info['title'], $tt, $journal_info['email'], $journal_info['epassword']);
//记录userlog
$log_data['user_id'] = $article_info['editor_id'];
@@ -2936,12 +2938,12 @@ class Article extends Base
$article_id = $this->article_obj->insertGetId($inset_data);
} else {
$checkArticle = $this->article_obj->where("article_id", "<>", $article_id)->where("title", trim($data['title']))->select();
foreach ($checkArticle as $v) {
if ($v['state'] != 3) {
return json(['code' => 1, 'msg' => 'Warning: you are re-submitting the article!']);
}
}
// $checkArticle = $this->article_obj->where("article_id", "<>", $article_id)->where("title", trim($data['title']))->select();
// foreach ($checkArticle as $v) {
// if ($v['state'] != 3) {
// return json(['code' => 1, 'msg' => 'Warning: you are re-submitting the article!']);
// }
// }
$up['user_id'] = $user_info['user_id'];
$up['journal_id'] = $data['journal'];
$up['editor_id'] = $journal_info['editor_id'];

View File

@@ -3,6 +3,7 @@
namespace app\api\controller;
use think\Db;
use think\Env;
use think\Queue;
use think\Validate;
@@ -1125,6 +1126,147 @@ class Preaccept extends Base
return jsonSuccess([]);
}
public function payStationTest(){
$accessToken = $this->payStationAccessToken();
$data_array = [
'paystation_id' => Env::get("paystation.client_id"),
'gateway_id' => "v1",//GATEWAY_ID,
'merchant_session' => "myTestSN001",
// 'merchant_reference' => 'testReference',
'amount' => 2000, //$20 in cents value
"test_mode"=>true
];
// OPTIONAL, ideally should be set on your Paystation account
$data_array += [
'return_url' => "http://192.168.110.110/tougao/public/index.php/api/Preaccept/patStationReturn",//'http://localhost:8002/3party/return.php',
// Webhook receipt page. This should be publicly accessible (see example post-response.php)
'response_url' => "https://www.tmrjournals.com"//'https://webhook.site/sample-code-webhook'
];
$data = json_encode($data_array);
// Purchase initiate request
$purchase = $this->postRequest('v1/hosted/purchases', $accessToken, $data);
return jsonSuccess($purchase);
if ($purchase) {
$result = json_decode($purchase);
if ($result && isset($result->payment_url)) {
header("Location: {$result->payment_url}");
} else {
//@todo: Replace with your own error handling
print_r($result);
return null;
}
}
}
public function payStationTest1(){
$accessToken = $this->payStationAccessToken();
$data_array = [
'paystation_id' => Env::get("paystation.client_id"),
'gateway_id' => "v1",//GATEWAY_ID,
"order_name" => "mytestOrderSn",
"amount" =>200,
"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'];
}
}
}
private function payStationAccessToken(){
$bodyParams = [
'client_id' => Env::get("paystation.client_id"),
'client_secret' => Env::get("paystation.client_secret"),
'grant_type' => 'client_credentials',
'scope' => "mytest"
];
$accessTokenUrl = Env::get("paystation.api_url") . '/oauth/token';
$curlHandle = curl_init($accessTokenUrl);
$options = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => [
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded",
"accept: *",
"accept-encoding: gzip, deflate",
],
CURLOPT_POSTFIELDS => http_build_query($bodyParams)
];
curl_setopt_array($curlHandle, $options);
curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false);
$curlResponse = curl_exec($curlHandle);
$error = curl_error($curlHandle);
curl_close($curlHandle);
if ($error) {
echo "cURL error: " . $error;
} else {
$response = json_decode($curlResponse);
if (array_key_exists('access_token', $response)) {
return $response->access_token;
}
if (array_key_exists('error', $response)) {
echo $response->error_description;
}
}
}
public function postRequest($endpoint, $token, $body)
{
$curlHandle = curl_init(Env::get("paystation.api_url") . '/' . $endpoint);
$options = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER=>false,
CURLOPT_HTTPHEADER => [
"cache-control: no-cache",
"content-type: application/json",
"accept: *",
"accept-encoding: gzip, deflate",
"Authorization: Bearer " . $token
],
CURLOPT_POSTFIELDS => $body
];
curl_setopt_array($curlHandle, $options);
$response = curl_exec($curlHandle);
$error = curl_error($curlHandle);
curl_close($curlHandle);
if ($error) {
echo "cURL error: " . $error;
} else {
return $response ?: null;
}
return null;
}
// public function getArticleMains(){
// $data = $this->request->post();

View File

@@ -48,6 +48,7 @@ class Publish extends Base
continue;
}
$stages[$k]['articles'][$key]['tg_article_id'] = $pro_info['article_id'];
$stages[$k]['articles'][$key]['p_article_id'] = $pro_info['p_article_id'];
}
}