Browse Source

更新

master
wuliangbo 4 years ago
parent
commit
a93f8e766c
  1. 25
      src/Kernel/Events/EventHandlerInterface.php
  2. 3
      src/Kernel/Helpers.php
  3. 23
      src/Kernel/Traits/SingData.php
  4. 2
      src/Payment/Notify/Handler.php

25
src/Kernel/Events/EventHandlerInterface.php

@ -1,25 +0,0 @@
<?php
/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <i@overtrue.me>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace EasyAlipay\Kernel\Contracts;
/**
* Interface EventHandlerInterface.
*
* @author mingyoung <mingyoungcheung@gmail.com>
*/
interface EventHandlerInterface
{
/**
* @param mixed $payload
*/
public function handle($payload = null);
}

3
src/Kernel/Helpers.php

@ -33,8 +33,7 @@ function decrypt($str, $screct_key)
$screct_key = base64_decode($screct_key); $screct_key = base64_decode($screct_key);
$iv_size = openssl_cipher_iv_length('AES-128-CBC'); $iv_size = openssl_cipher_iv_length('AES-128-CBC');
$iv = str_repeat("\0", $iv_size); $iv = str_repeat("\0", $iv_size);
$decrypt_str = openssl_decrypt($str,"AES-128-CBC",$screct_key,OPENSSL_RAW_DATA,$iv); return openssl_decrypt($str,"AES-128-CBC",$screct_key,OPENSSL_RAW_DATA,$iv);
return $decrypt_str;
} }
/** /**

23
src/Kernel/Traits/SingData.php

@ -179,42 +179,38 @@ trait SingData
/** /**
* 生成应用证书SN. * 生成应用证书SN.
* @param $certPath * @param $cert_path
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
public function getCertSN($certPath): string public function getCertSN($cert_path): string
{ {
if (!is_file($certPath)) { if (!is_file($cert_path)) {
throw new \Exception('unknown certPath -- [getCertSN]'); throw new \Exception('unknown certPath -- [getCertSN]');
} }
$x509data = file_get_contents($certPath); $x509data = file_get_contents($cert_path);
if (false === $x509data) { if (false === $x509data) {
throw new \Exception('Alipay CertSN Error -- [getCertSN]'); throw new \Exception('Alipay CertSN Error -- [getCertSN]');
} }
openssl_x509_read($x509data); openssl_x509_read($x509data);
$certdata = openssl_x509_parse($x509data); $cert_data = openssl_x509_parse($x509data);
if (empty($certdata)) { if (empty($cert_data)) {
throw new \Exception('Alipay openssl_x509_parse Error -- [getCertSN]'); throw new \Exception('Alipay openssl_x509_parse Error -- [getCertSN]');
} }
$issuer_arr = []; $issuer_arr = [];
foreach ($certdata['issuer'] as $key => $val) { foreach ($cert_data['issuer'] as $key => $val) {
$issuer_arr[] = $key.'='.$val; $issuer_arr[] = $key.'='.$val;
} }
$issuer = implode(',', array_reverse($issuer_arr)); $issuer = implode(',', array_reverse($issuer_arr));
return md5($issuer.$certdata['serialNumber']); return md5($issuer. $cert_data['serialNumber']);
} }
/** /**
* 生成支付宝根证书SN. * 生成支付宝根证书SN.
* *
* @author 大冰 https://sbing.vip/archives/2019-new-alipay-php-docking.html
*
* @param $certPath * @param $certPath
*
* @return string * @return string
*
* @throws /Exception * @throws /Exception
*/ */
public function getRootCertSN($certPath) public function getRootCertSN($certPath)
@ -255,10 +251,7 @@ trait SingData
/** /**
* 0x转高精度数字. * 0x转高精度数字.
* *
* @author 大冰 https://sbing.vip/archives/2019-new-alipay-php-docking.html
*
* @param $hex * @param $hex
*
* @return int|string * @return int|string
*/ */
private static function bchexdec($hex) private static function bchexdec($hex)

2
src/Payment/Notify/Handler.php

@ -122,7 +122,7 @@ abstract class Handler
} }
try { try {
$message = json_decode(strval($this->app['request']->getContent()), true); parse_str($this->app['request']->getContent(), $message);
} catch (\Throwable $e) { } catch (\Throwable $e) {
throw new Exception('Invalid request: ' . $e->getMessage(), 400); throw new Exception('Invalid request: ' . $e->getMessage(), 400);
} }

Loading…
Cancel
Save