2019-11-11 18:14:47 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
2020-03-05 12:41:49 +08:00
|
|
|
namespace wchat\wx;
|
2019-11-11 18:14:47 +08:00
|
|
|
|
|
|
|
|
|
2026-03-17 16:48:52 +08:00
|
|
|
use Exception;
|
2022-09-09 16:42:55 +08:00
|
|
|
use wchat\common\Multiprogramming;
|
2026-03-17 16:48:52 +08:00
|
|
|
use wchat\wx\V3\Libs\WxMsgCrypt;
|
|
|
|
|
use wchat\wx\V3\Libs\XPayGoodsDeliverNotify;
|
2019-11-11 18:14:47 +08:00
|
|
|
|
2022-09-09 16:42:55 +08:00
|
|
|
class SmallProgram extends Multiprogramming
|
2019-11-11 18:14:47 +08:00
|
|
|
{
|
2026-03-17 16:48:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $encrypt
|
|
|
|
|
* @param string $signature
|
|
|
|
|
* @param string $timestamp
|
|
|
|
|
* @param string $nonce
|
|
|
|
|
* @param string $msg_signature
|
|
|
|
|
* @return array|bool
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function decode(string $encrypt, string $signature, string $timestamp, string $nonce, string $msg_signature): XPayGoodsDeliverNotify|bool
|
|
|
|
|
{
|
2026-03-17 16:55:45 +08:00
|
|
|
$WxMsgCrypt = new WxMsgCrypt($this->payConfig->notice->token, $this->payConfig->notice->encodingAESKey, $this->payConfig->appId);
|
2026-03-17 16:48:52 +08:00
|
|
|
if (!$WxMsgCrypt->verifySignature($timestamp, $nonce, $encrypt, $msg_signature)) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
return XPayGoodsDeliverNotify::fromJson($WxMsgCrypt->decryptMsg($encrypt));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-11-11 18:14:47 +08:00
|
|
|
}
|