Files
kiri-wchat/wx/SmallProgram.php
2026-03-17 16:55:45 +08:00

39 lines
891 B
PHP

<?php
namespace wchat\wx;
use Exception;
use wchat\common\Multiprogramming;
use wchat\wx\V3\Libs\WxMsgCrypt;
use wchat\wx\V3\Libs\XPayGoodsDeliverNotify;
class SmallProgram extends Multiprogramming
{
/**
* @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
{
$WxMsgCrypt = new WxMsgCrypt($this->payConfig->notice->token, $this->payConfig->notice->encodingAESKey, $this->payConfig->appId);
if (!$WxMsgCrypt->verifySignature($timestamp, $nonce, $encrypt, $msg_signature)) {
return false;
} else {
return XPayGoodsDeliverNotify::fromJson($WxMsgCrypt->decryptMsg($encrypt));
}
}
}