39 lines
887 B
PHP
39 lines
887 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['secret'], $this->payConfig->appId);
|
|
if (!$WxMsgCrypt->verifySignature($timestamp, $nonce, $encrypt, $msg_signature)) {
|
|
return false;
|
|
} else {
|
|
return XPayGoodsDeliverNotify::fromJson($WxMsgCrypt->decryptMsg($encrypt));
|
|
}
|
|
}
|
|
|
|
|
|
}
|