PHP code example of peteryangs / wechatpay

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

    

peteryangs / wechatpay example snippets



use wechatPay\WeChatPay;

ay(
    'xxxx',
    'xxx',
    'xxxxxxxxxxxxx',
    __DIR__.DIRECTORY_SEPARATOR.'apiclient_cert.pem',
    __DIR__.DIRECTORY_SEPARATOR.'apiclient_key.pem'
);

//小程序和公众号支付
$weapp=$pay->getType('weapp');

//获取支付参数
$param=$weapp->getPayParam(
    '支付测试',
    time(),
    1,
    '127.0.0.1',
    'http://www.baidu.com',
    'xxx',
    '123'
);



//检查失败返回false,成功返回通知参数
$weapp->check();


$re=$weapp->refund(
    '1111111',
    time(),
    1,
    1,
    'http://www.baidu.com'
);


//失败返回false,成功返回退款参数
$data=$weapp->check_refund();



echo $weapp->return_success();