PHP code example of datalinkage / wxpay

1. Go to this page and download the library: Download datalinkage/wxpay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

datalinkage / wxpay example snippets


 /**
     * 微信配置(假定值)
     * @return array
     */
    private function wechatInfo(){
        $mp = [
            'appid'=>'xxxxxxxxx',//微信appid
            'paykey'=>'xxxxxxxxxxx',//微信支付密码
            'mch_id'=>'xxxxxxxx',//商户号
        ];
        return $mp;
    }

/**
*文件application->config.php
*/

// 原
'url_common_param'=>false
// 改成
'url_common_param'=>true


namespace app\index\controller;
vendor("datalinkage.wxpay.Wxpay");
class Index 
{
    public function index()
    {
      $object = new \Wxpay('0.01','李益达','obmm3s4oXl_xj03qHUfOCP36UbkQ');//金额,商品信息,openid
      $param = $object->getWxpayConfig();//此为所有参数回执
      dump($param);
    }
}