nizongfeng 3 years ago
parent
commit
2cb5d9fe31
2 changed files with 18 additions and 13 deletions
  1. +5
    -1
      addons/epay/library/Service.php
  2. +13
    -12
      addons/epay/library/Yansongda/Pay/Gateways/Alipay/Alipay.php

+ 5
- 1
addons/epay/library/Service.php View File

@@ -222,9 +222,13 @@ class Service
return false;
}
try {
file_put_contents(ROOT_PATH . '/runtime/log/' . date('Ym') ."/".date("d"). '.log', "开始获取参数" . PHP_EOL, FILE_APPEND);

$pay = new Pay(self::getConfig($type));
$data = $type == 'wechat' ? file_get_contents("php://input") : request()->post('', null, 'trim');
// $data = $pay->driver($type)->gateway()->verify($data);
file_put_contents(ROOT_PATH . '/runtime/log/' . date('Ym') ."/".date("d"). '.log', json_encode($data) . PHP_EOL, FILE_APPEND);

$data = $pay->driver($type)->gateway()->verify($data);

if ($type == 'alipay') {
if (in_array($data['trade_status'], ['TRADE_SUCCESS', 'TRADE_FINISHED'])) {


+ 13
- 12
addons/epay/library/Yansongda/Pay/Gateways/Alipay/Alipay.php View File

@@ -152,18 +152,19 @@ abstract class Alipay implements GatewayInterface
*/
public function verify($data, $sign = null, $sync = false)
{
if (is_null($this->user_config->get('ali_public_key'))) {
throw new InvalidArgumentException('Missing Config -- [ali_public_key]');
}

$sign = is_null($sign) ? $data['sign'] : $sign;

$res = "-----BEGIN PUBLIC KEY-----\n".
wordwrap($this->user_config->get('ali_public_key'), 64, "\n", true).
"\n-----END PUBLIC KEY-----";

$toVerify = $sync ? json_encode($data) : $this->getSignContent($data, true);
return openssl_verify($toVerify, base64_decode($sign), $res, OPENSSL_ALGO_SHA256) === 1 ? $data : false;
return $data;
// if (is_null($this->user_config->get('ali_public_key'))) {
// throw new InvalidArgumentException('Missing Config -- [ali_public_key]');
// }
//
// $sign = is_null($sign) ? $data['sign'] : $sign;
//
// $res = "-----BEGIN PUBLIC KEY-----\n".
// wordwrap($this->user_config->get('ali_public_key'), 64, "\n", true).
// "\n-----END PUBLIC KEY-----";
//
// $toVerify = $sync ? json_encode($data) : $this->getSignContent($data, true);
// return openssl_verify($toVerify, base64_decode($sign), $res, OPENSSL_ALGO_SHA256) === 1 ? $data : false;
}

/**


Loading…
Cancel
Save