PHP code example of gavin / chinaums

1. Go to this page and download the library: Download gavin/chinaums 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/ */

    

gavin / chinaums example snippets


# 在项目中加载初始化文件

try {
     手动加载入口文件
    ig = in\Ums\WePay\Pay::instance($config);

    //4. 组装参数,可以参考官方文档
    $options = [
        'merOrderId' => time(),
        'totalAmount' => '1',
        'subOpenId' => 'xxxxx',
        'attachedData' => '备注',
        'orderDesc' => '测试描述'
    ];
    // 生成预支付码
    $result = $ums->createOrder($options);

    echo '<pre>';
    echo "\n--- 创建预支付 ---\n";
    var_export($result);

} catch (Exception $exception) {
    // 出错啦,处理下吧
    echo $exception->getMessage() . PHP_EOL;
}
shell
php think ums:create
shell
php think ums:cache -d #将cache目录改为0777
php think ums:cache -u www:www #修改目录所有者为www