eee
This commit is contained in:
@@ -5,6 +5,7 @@ namespace wchat\wx\V3;
|
||||
use Exception;
|
||||
use OpenSSLAsymmetricKey;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use wchat\common\PayConfig;
|
||||
use wchat\wx\SmallProgram;
|
||||
use wchat\wx\V3\Notify\GoodsDetail;
|
||||
use wchat\wx\V3\Notify\NotifyModel;
|
||||
@@ -13,25 +14,6 @@ use wchat\wx\V3\Notify\PromotionDetail;
|
||||
const KEY_TYPE_PUBLIC = 'public';
|
||||
const KEY_TYPE_PRIVATE = 'private';
|
||||
|
||||
const LOCAL_FILE_PROTOCOL = 'file://';
|
||||
const PKEY_PEM_NEEDLE = ' KEY-';
|
||||
const PKEY_PEM_FORMAT = "-----BEGIN %1\$s KEY-----\n%2\$s\n-----END %1\$s KEY-----";
|
||||
const PKEY_PEM_FORMAT_PATTERN = '#-{5}BEGIN ((?:RSA )?(?:PUBLIC|PRIVATE)) KEY-{5}\r?\n([^-]+)\r?\n-{5}END \1 KEY-{5}#';
|
||||
const CHR_CR = "\r";
|
||||
const CHR_LF = "\n";
|
||||
|
||||
const RULES = [
|
||||
'private.pkcs1' => [PKEY_PEM_FORMAT, 'RSA PRIVATE', 16],
|
||||
'private.pkcs8' => [PKEY_PEM_FORMAT, 'PRIVATE', 16],
|
||||
'public.pkcs1' => [PKEY_PEM_FORMAT, 'RSA PUBLIC', 15],
|
||||
'public.spki' => [PKEY_PEM_FORMAT, 'PUBLIC', 14],
|
||||
];
|
||||
const ASN1_OID_RSAENCRYPTION = '300d06092a864886f70d0101010500';
|
||||
const ASN1_SEQUENCE = 48;
|
||||
const CHR_NUL = "\0";
|
||||
const CHR_ETX = "\3";
|
||||
|
||||
|
||||
class WxV3PaymentNotify extends SmallProgram
|
||||
{
|
||||
|
||||
@@ -46,16 +28,14 @@ class WxV3PaymentNotify extends SmallProgram
|
||||
* @param string $event_type
|
||||
* @param string $summary
|
||||
* @param array $resource
|
||||
* @param string $publicKey
|
||||
*/
|
||||
public function __construct(
|
||||
public string $id = "EV-2018022511223320873",
|
||||
public string $create_time = "2015-05-20T13:29:35+08:00",
|
||||
public string $resource_type = "encrypt-resource",
|
||||
public string $event_type = "TRANSACTION.SUCCESS",
|
||||
public string $summary = "支付成功",
|
||||
public array $resource = [],
|
||||
public string $publicKey = ''
|
||||
public string $id = "EV-2018022511223320873",
|
||||
public string $create_time = "2015-05-20T13:29:35+08:00",
|
||||
public string $resource_type = "encrypt-resource",
|
||||
public string $event_type = "TRANSACTION.SUCCESS",
|
||||
public string $summary = "支付成功",
|
||||
public array $resource = []
|
||||
)
|
||||
{
|
||||
}
|
||||
@@ -74,7 +54,7 @@ class WxV3PaymentNotify extends SmallProgram
|
||||
*/
|
||||
public function verify(RequestInterface $request): bool
|
||||
{
|
||||
$platformPublicKeyInstance = $this->rsaFrom($this->publicKey, KEY_TYPE_PUBLIC);
|
||||
$platformPublicKeyInstance = $this->rsaFrom($this->payConfig->wx->mchKey, KEY_TYPE_PUBLIC);
|
||||
$inWechatpaySignature = $request->getHeaderLine('Wechatpay-Signature'); // 请根据实际情况获取
|
||||
$inWechatpayTimestamp = $request->getHeaderLine('Wechatpay-Timestamp'); // 请根据实际情况获取
|
||||
$inWechatpayNonce = $request->getHeaderLine('Wechatpay-Nonce'); // 请根据实际情况获取
|
||||
@@ -147,7 +127,7 @@ class WxV3PaymentNotify extends SmallProgram
|
||||
*/
|
||||
public function decode($ciphertext, $nonce, $associated_data): bool
|
||||
{
|
||||
$data = $this->decrypt($ciphertext, $this->getConfig()->getMchKey(), $nonce, $associated_data);
|
||||
$data = $this->decrypt($ciphertext, $this->payConfig->wx->secret, $nonce, $associated_data);
|
||||
$this->notifyModel = new NotifyModel();
|
||||
$this->notifyModel->amount = $data['amount'];
|
||||
$this->notifyModel->payer = $data['payer'];
|
||||
|
||||
Reference in New Issue
Block a user