PHP code example of ycpfzf / pay

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

    

ycpfzf / pay example snippets


composer 

php artisan vendor:publish

ALI_APP_ID= 
ALI_PUBLIC_KEY= 
ALI_PRIVATE_KEY= 
WECHAT_APP_ID=
WECHAT_MINIAPP_ID=
WECHAT_APPID= 
WECHAT_MCH_ID= 
WECHAT_KEY= 

use Ycpfzf\Pay\Pay;

Pay::alipay()->outTradeNo($outid)->money(0.1)->subject('测试')->app(); //使用支付宝的app支付0.1元

use Ycpfzf\Pay\Pay;

Pay::wechat()->outTradeNo($outid)->money(0.1)->subject('7天无理由退款')->refund('app'); 

//返回结果
[
    'status'=>true,  //退款是否成功
    'trade_no'=>'xxxx'  //平台返回的退款编号
]

use Ycpfzf\Pay\Pay;

Pay::notify(function($data){
    
       .....
});

//回调函数中参数$data
[
    'out_trade_no'=>'xxx'  //商户订单编号 
    'status'=>true,  //支付是否成功
    'notify_no'=>//平台编号,
    'money'=>0.10  //支付金额,单位统一都是元,
    'appid'=>'xxx',   //商户申请的appid
    'mch_id'=>'xxx',  //微信时返回mch_id,支付宝返回0
    'type'=>'wechat',  //类别 wechat 或 alipay

]