国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

easywechat6 v3支付 JSAPI下單示例+流程

Achun

提交訂單示例代碼

use EasyWeChat\Pay\Application;
use WebmanTech\Logger\Logger;

public function submit(Request $request)
{
    $params = OrderSubmitRequest::validate($request->all());

    $lock_name = 'order:submit:' . $request->uid;
    $lock = Redis::setEx($lock_name, 3, 1);
    if (!$lock) return fail('請勿重復(fù)提交');

    $price = Config::cacheValue('fee_money');
    $data['price'] = $price;
    $data['order_sn'] = 'WA' . get_order_sn();
    $data['uid'] = $request->uid;
    $data['type'] = 1;
    $res = Order::create($data);
    if (!$res) return fail('創(chuàng)建訂單失敗');

    $config = config('wechat.payment.default');
    $order = [
        "mchid" => $config['mch_id'],
        "out_trade_no" => $data['order_sn'],
        "appid" => $config['app_id'],
        "description" => '微信支付測試',
        "notify_url" => 'https://'.request()->host() . "/xxx/callback", // 支付成功后回調(diào)通知URL
        "amount" => [
            "total" => (int)bcmul($price,100),
            "currency" => "CNY",
        ],
        "payer" => [
            "openid" => $request->user->openid,
        ],
    ];

    try {
        $app = new Application($config);
        $res = $app->getClient()->postJson("v3/pay/transactions/jsapi", $order);
        $res = $res->toArray();
    } catch (\Throwable $e) {
        Logger::info($e->getMessage());
        return fail($e->getMessage());
    }

    if (!isset($res['prepay_id'])) {
        Logger::info($res);
        return fail('獲取prepay_id失敗');
    }

    $prepayId = $res['prepay_id'];
    $utils = $app->getUtils();
    $config = $utils->buildMiniAppConfig($prepayId, $config['app_id'], 'RSA');
    Redis::del($lock_name);
    return success($config);
}

微信支付配置

截圖

微信商戶平臺申請商戶證書以及v3_api key

截圖

微信支付V3,平臺證書(EasyWechat的platform_certs參數(shù))下載

https://learnku.com/laravel/t/68840

查詢微信商戶序列號

openssl x509 -in apiclient_cert.pem -noout -serial

1342 0 2
0個評論

Achun

440
積分
0
獲贊數(shù)
0
粉絲數(shù)
2023-12-04 加入
??