This commit is contained in:
xl
2023-11-14 14:10:36 +08:00
parent f263014948
commit 70222819b9
13 changed files with 133 additions and 129 deletions
+2 -2
View File
@@ -14,14 +14,14 @@ class WxV3AppPayment extends SmallProgram
/**
* @param $orderNo
* @param string $orderNo
* @param int $total
* @param string|null $openId
* @param string $payer_client_ip
* @return array
* @throws Exception
*/
public function payment($orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
{
$body = $this->getInitCore($orderNo, $total);
+9 -9
View File
@@ -14,16 +14,16 @@ class WxV3NativePayment extends SmallProgram
use WxV3PaymentTait;
/**
* @param $orderNo
* @param int $total
* @param string|null $openId
* @param string $payer_client_ip
* @return array
* @throws Exception
*/
/**
* @param string $orderNo
* @param int $total
* @param string|null $openId
* @param string $payer_client_ip
* @return array
* @throws Exception
*/
#[ArrayShape(['code_url' => "string"])]
public function payment($orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
{
$body = $this->getInitCore($orderNo, $total);
+2 -2
View File
@@ -14,14 +14,14 @@ class WxV3Payment extends SmallProgram
/**
* @param $orderNo
* @param string $orderNo
* @param int $total
* @param string|null $openId
* @param string $payer_client_ip
* @return array
* @throws Exception
*/
public function payment($orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
public function payment(string $orderNo, int $total, string $openId = NULL, string $payer_client_ip = '127.0.0.1'): array
{
$body = $this->getInitCore($orderNo, $total);
$body['payer'] = ['openid' => $openId];
+14 -14
View File
@@ -30,12 +30,12 @@ class WxV3PaymentNotify extends SmallProgram
* @param array $resource
*/
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 $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 = []
)
{
}
@@ -93,10 +93,10 @@ class WxV3PaymentNotify extends SmallProgram
/**
* @param string $message
* @param string $signature
* @param $publicKey
* @param OpenSSLAsymmetricKey $publicKey
* @return bool
*/
protected function notifyVerify(string $message, string $signature, $publicKey): bool
protected function notifyVerify(string $message, string $signature, OpenSSLAsymmetricKey $publicKey): bool
{
if (($result = openssl_verify($message, base64_decode($signature), $publicKey, OPENSSL_ALGO_SHA256)) === false) {
throw new \UnexpectedValueException('Verified the input $message failed, please checking your $publicKey whether or nor correct.');
@@ -106,11 +106,11 @@ class WxV3PaymentNotify extends SmallProgram
/**
* @param $thing
* @param string $thing
* @param string $type
* @return OpenSSLAsymmetricKey
*/
protected function rsaFrom($thing, string $type = KEY_TYPE_PRIVATE): OpenSSLAsymmetricKey
protected function rsaFrom(string $thing, string $type = KEY_TYPE_PRIVATE): OpenSSLAsymmetricKey
{
$pkey = (($isPublic = $type === KEY_TYPE_PUBLIC) ? openssl_pkey_get_public(file_get_contents($thing)) : openssl_pkey_get_private(file_get_contents($thing)));
if (false === $pkey) {
@@ -120,12 +120,12 @@ class WxV3PaymentNotify extends SmallProgram
}
/**
* @param $ciphertext
* @param $nonce
* @param $associated_data
* @param string $ciphertext
* @param string $nonce
* @param string $associated_data
* @return bool
*/
public function decode($ciphertext, $nonce, $associated_data): bool
public function decode(string $ciphertext, string $nonce, string $associated_data): bool
{
$data = $this->decrypt($ciphertext, $this->payConfig->pay->wx->secret, $nonce, $associated_data);
$this->notifyModel = new NotifyModel();
+8 -8
View File
@@ -21,11 +21,11 @@ trait WxV3PaymentTait
{
/**
* @param $orderNo
* @param $total
* @param string $orderNo
* @param int $total
* @return array
*/
public function getInitCore($orderNo, $total): array
public function getInitCore(string $orderNo, int $total): array
{
$payConfig = $this->getPayConfig();
if ($payConfig->typeIsApp()) {
@@ -87,10 +87,10 @@ trait WxV3PaymentTait
/**
* @param $body
* @param string $body
* @return string
*/
public function openssl_signature($body): string
public function openssl_signature(string $body): string
{
$payConfig = $this->getPayConfig();
@@ -102,11 +102,11 @@ trait WxV3PaymentTait
/**
* @param $json
* @param $body
* @param array $json
* @param array $body
* @return array
*/
private function createResponse($json, $body): array
private function createResponse(array $json, array $body): array
{
$responseArray['appId'] = $body['appid'];
$responseArray['timeStamp'] = (string)time();
+10 -3
View File
@@ -15,14 +15,14 @@ class WxV3Withdrawal extends SmallProgram
/**
* @param $orderNo
* @param string $orderNo
* @param string $batch_name
* @param string $batch_remark
* @param TransferDetail[] $details
* @return array
* @throws Exception
*/
public function payment($orderNo, string $batch_name, string $batch_remark, array $details): array
public function payment(string $orderNo, string $batch_name, string $batch_remark, array $details): array
{
$body = $this->create($orderNo, $batch_name, $batch_remark, $details);
@@ -41,8 +41,15 @@ class WxV3Withdrawal extends SmallProgram
}
/**
* @param string $orderNo
* @param string $batch_name
* @param string $batch_remark
* @param array $details
* @return array[]
*/
#[ArrayShape(['transfer_detail_list' => "array", 'total_amount' => "int", 'total_num' => "int", 'batch_remark' => "string", 'batch_name' => "string", 'out_batch_no' => ""])]
private function create($orderNo, string $batch_name, string $batch_remark, array $details): array
private function create(string $orderNo, string $batch_name, string $batch_remark, array $details): array
{
$total = 0;
$body = ['transfer_detail_list' => []];