eee
This commit is contained in:
+11
-12
@@ -13,18 +13,18 @@ class WxV3Payment extends SmallProgram
|
||||
use WxV3PaymentTait;
|
||||
|
||||
|
||||
/**
|
||||
* @param $orderNo
|
||||
* @param int $total
|
||||
* @param string|null $openId
|
||||
* @param string $payer_client_ip
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
/**
|
||||
* @param $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
|
||||
{
|
||||
$body = $this->getInitCore($orderNo, $total);
|
||||
$body['payer'] = ['openid' => $openId];
|
||||
$body = $this->getInitCore($orderNo, $total);
|
||||
$body['payer'] = ['openid' => $openId];
|
||||
$body['scene_info'] = ['payer_client_ip' => $payer_client_ip];
|
||||
|
||||
$sign = $this->signature('POST', '/v3/pay/transactions/jsapi', $json = json_encode($body, JSON_UNESCAPED_UNICODE));
|
||||
@@ -34,9 +34,8 @@ class WxV3Payment extends SmallProgram
|
||||
$client->close();
|
||||
|
||||
$json = json_decode($client->getBody(), TRUE);
|
||||
var_dump($client->getBody());
|
||||
if (!isset($json['prepay_id'])) {
|
||||
throw new Exception('微信支付调用失败');
|
||||
throw new Exception('微信支付调用失败: ' . $client->getBody());
|
||||
}
|
||||
|
||||
return $this->createResponse($json, $body);
|
||||
|
||||
@@ -12,28 +12,11 @@ use wchat\common\Help;
|
||||
*/
|
||||
const BLOCK_SIZE = 16;
|
||||
|
||||
/**
|
||||
* Bytes length of the AES secret key.
|
||||
*/
|
||||
const KEY_LENGTH_BYTE = 32;
|
||||
|
||||
/**
|
||||
* Bytes Length of the authentication tag in AEAD cipher mode
|
||||
* @deprecated 1.0 - As of the OpenSSL described, the `auth_tag` length may be one of 16, 15, 14, 13, 12, 8 or 4.
|
||||
* Keep it only compatible for the samples on the official documentation.
|
||||
*/
|
||||
const AUTH_TAG_LENGTH_BYTE = 16;
|
||||
|
||||
/**
|
||||
* The `aes-256-gcm` algorithm string
|
||||
*/
|
||||
const ALGO_AES_256_GCM = 'aes-256-gcm';
|
||||
|
||||
/**
|
||||
* The `aes-256-ecb` algorithm string
|
||||
*/
|
||||
const ALGO_AES_256_ECB = 'aes-256-ecb';
|
||||
|
||||
trait WxV3PaymentTait
|
||||
{
|
||||
|
||||
@@ -111,7 +94,7 @@ trait WxV3PaymentTait
|
||||
{
|
||||
$payConfig = $this->getPayConfig();
|
||||
|
||||
$mch_private_key = openssl_get_privatekey($payConfig->pay->wx->mchKey);
|
||||
$mch_private_key = openssl_get_privatekey(file_get_contents($payConfig->pay->wx->mchKey));
|
||||
|
||||
openssl_sign($body, $raw_sign, $mch_private_key, 'sha256WithRSAEncryption');
|
||||
return base64_encode($raw_sign);
|
||||
|
||||
Reference in New Issue
Block a user