PHP code example of anerg2046 / payment

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

    

anerg2046 / payment example snippets


$params = [
    'order_no' => '*************', //商户订单号,无论什么渠道
    'fee' => 100, //支付金额,统一使用【分】为单位,无论什么支付渠道
    'body' => '商品名称', //无论什么渠道
    'detail' => '商品描述', //无论什么渠道
    'client_ip' => '127.0.0.1', //客户端IP
    'limit_pay' => '*****', //禁用的支付方式
    'attach' => '附加参数', //用户自定义值,会在回调或回跳的时候原样返回的值
    'refund_no' => '****************', //退款单号
    'refund_fee' => 100, //退款金额
];

try {
    $ret = Pay::支付渠道名称($配置文件信息)->支付方式名称($统一订单信息);
    var_dump($ret);
}catch(\Exception $e) {
    echo $e->getMessage();
}

//支付宝配置文件
return [
    'app_id' => '*************',
    'pem_private' => '/pathto/private.pem', //用户私钥
    'pem_public' => '/pathto/public.pem', //支付宝公钥
];

//微信配置文件
return [
    'app_id' => '***********',
    'app_secret' => '*******************',
    'mch_id' => '****************',
    'md5_key' => '*******************',
    'notify_url' => 'http://test.com/wxpay/notify',
    'pem_cert' => '/pathto/apiclient_cert.pem',
    'pem_key' => '/pathto/apiclient_key.pem',
];

//微信配置文件
return [
    'web' => [
        'app_id' => '****',
        'app_secret' => '****',
        'return_url' => 'http://test.com/vpay_suc.php',
        'quit_url' => 'http://test.com/vpay.php',
	],
	'wap' => [
        'app_id' => '****',
        'app_secret' => '****',
        'return_url' => 'http://test.com/vpay_suc.php',
        'quit_url' => 'http://test.com/vpay.php',
	],
];