There is an error in Wechat's CA certificate for enterprise payment. Please log in to WeChat Pay's merchant platform to download the certificate.

easywechat used

clipboard.png

Code:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use EasyWeChat\Factory;
use DB;

class WechatController extends Controller
{
    private $app;

    public function __construct()
    {
        $config = [
            // 
            "app_id" => "xxxxxxxxx",
            "mch_id" => "xxxxxxx",
            "key" => "xxxxxxxxxxx",   // API 

            //  API ( API )
            "cert_path" => public_path("/cert/apiclient_cert.pem"), // XXX: 
            "key_path" => public_path("/cert/apiclient_key.pem"),      // XXX: 

            "notify_url" => "https://xx.xx/
        ];

        $this->app = Factory::payment($config);
    }


    public function money()
    {
        $time =time();
        $withdraw = DB::table("withdraw")->insertGetId([
            "user_id" => 1,
            "num" => 1,
            "created_at" => $time,
            "order_code" => $time,
        ]);
        if (!$withdraw) {
            dd("shibai");
        }
        $this->app->transfer->toBalance([
            "partner_trade_no" => $time, // ()
            "openid" => "olQ2H02-a6pMF7yh0raqt7RMVAyo",
            "check_name" => "NO_CHECK", // NO_CHECK:, FORCE_CHECK:
            "re_user_name" => "", //  check_name FORCE_CHECK
            "amount" => 1, // 
            "desc" => "ceshi", // 
        ]);
        dd($withdraw);
    }

    public function result()
    {
        $partnerTradeNo = DB::table("withdraw")->orderByDesc("id")->value("order_code");
        $return = $this->app->transfer->queryBalanceOrder($partnerTradeNo);
        dd($return);
    }
}
Mar.24,2021

immediately prompts for a certificate error, download a new certificate and replace it with
and verify that the path is correct.

Menu