|
@@ -46,25 +46,34 @@ final class Epay extends AbstractPayment
|
|
|
|
|
|
public static function _readableName(): string
|
|
|
{
|
|
|
- return 'epay在线充值';
|
|
|
+ return 'EPay 在线充值';
|
|
|
}
|
|
|
|
|
|
public function purchase(Request $request, Response $response, array $args): ResponseInterface
|
|
|
{
|
|
|
$type = $request->getParam('type');
|
|
|
$price = $request->getParam('price');
|
|
|
+ $invoice_id = $request->getParam('invoice_id') ?? 0;
|
|
|
+
|
|
|
if ($price <= 0) {
|
|
|
return $response->withJson(['errcode' => -1, 'errmsg' => '非法的金额.']);
|
|
|
}
|
|
|
+
|
|
|
$user = Auth::getUser();
|
|
|
+
|
|
|
$pl = new Paylist();
|
|
|
|
|
|
+ if ($user->use_new_shop) {
|
|
|
+ $pl->invoice_id = $invoice_id;
|
|
|
+ } else {
|
|
|
+ $pl->invoice_id = 0;
|
|
|
+ }
|
|
|
+
|
|
|
$pl->userid = $user->id;
|
|
|
$pl->total = $price;
|
|
|
//订单号
|
|
|
$pl->tradeno = self::generateGuid();
|
|
|
$pl->save();
|
|
|
-
|
|
|
//请求参数
|
|
|
$data = [
|
|
|
'pid' => trim($this->epay['partner']),
|
|
@@ -77,8 +86,10 @@ final class Epay extends AbstractPayment
|
|
|
'money' => $price,
|
|
|
'sitename' => $_ENV['appName'],
|
|
|
];
|
|
|
+
|
|
|
$alipaySubmit = new EpaySubmit($this->epay);
|
|
|
$html_text = $alipaySubmit->buildRequestForm($data);
|
|
|
+
|
|
|
return $response->write($html_text);
|
|
|
}
|
|
|
|
|
@@ -86,6 +97,7 @@ final class Epay extends AbstractPayment
|
|
|
{
|
|
|
$alipayNotify = new EpayNotify($this->epay);
|
|
|
$verify_result = $alipayNotify->verifyNotify();
|
|
|
+
|
|
|
if ($verify_result) {
|
|
|
$out_trade_no = $_GET['out_trade_no'];
|
|
|
$type = $_GET['type'];
|
|
@@ -110,6 +122,7 @@ final class Epay extends AbstractPayment
|
|
|
}
|
|
|
return $response->withJson(['state' => 'fail', 'msg' => '支付失败']);
|
|
|
}
|
|
|
+
|
|
|
return $response->write('非法请求');
|
|
|
}
|
|
|
public static function getPurchaseHTML(): string
|
|
@@ -119,15 +132,30 @@ final class Epay extends AbstractPayment
|
|
|
|
|
|
public function getReturnHTML($request, $response, $args): ResponseInterface
|
|
|
{
|
|
|
+ $user = Auth::getUser();
|
|
|
+
|
|
|
$money = $_GET['money'];
|
|
|
- $html = <<<HTML
|
|
|
- 您已成功充值 ${money} 元,正在跳转..
|
|
|
- <script>
|
|
|
- setTimeout(function() {
|
|
|
- location.href="/user/code";
|
|
|
- },500)
|
|
|
- </script>
|
|
|
- HTML;
|
|
|
+
|
|
|
+ if ($user->use_new_shop) {
|
|
|
+ $html = <<<HTML
|
|
|
+ 您已成功充值 ${money} 元,正在跳转..
|
|
|
+ <script>
|
|
|
+ setTimeout(function() {
|
|
|
+ location.href="/user/invoice";
|
|
|
+ },500)
|
|
|
+ </script>
|
|
|
+ HTML;
|
|
|
+ } else {
|
|
|
+ $html = <<<HTML
|
|
|
+ 您已成功充值 ${money} 元,正在跳转..
|
|
|
+ <script>
|
|
|
+ setTimeout(function() {
|
|
|
+ location.href="/user/code";
|
|
|
+ },500)
|
|
|
+ </script>
|
|
|
+ HTML;
|
|
|
+ }
|
|
|
+
|
|
|
return $response->write($html);
|
|
|
}
|
|
|
}
|