PHP code example of iboxs / payment
1. Go to this page and download the library: Download iboxs/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/ */
iboxs / payment example snippets
$orderInfo=array(
'order_name'=>"订单测试", //订单名称或标题
'amount'=>1, //订单金额(最低0.01)
'out_trade_no'=>"2021101247845", //商户订单号(同一个商户本订单号需唯一)
'authCode'=>'4444444444444444', //条码信息
'store_id'=>'Stroe01' //分店ID(本参数可有可无)
);
$orderInfo=array(
'account'=>"[email protected] ", //转入的账户(支持手机号或邮箱)
'real_name'=>'张三', //账户的真实姓名
'amount'=>1, //转账金额
'remark'=>'佣金' //转账备注
);
boxs\payment\Client;
use iboxs\payment\Notify;
//支付宝配置信息
$alipayconfig=[
'publicKey' =>"", //支付宝公钥
'rsaPrivateKey' =>"", //商户私钥
'appid' => "2016192400584878", //应用APPID
'notify_url' => "http://auth.itgz8.com/return", //异步通知地址
'return_url' => "http://auth.itgz8.com/return", //同步通知地址
'charset' => "UTF-8",
'sign_type'=>"RSA2",
'gatewayUrl' =>"https://openapi.alipay.com/gateway.do" //应用网关,若为沙箱环境则为:"https://openapi.alipaydev.com/gateway.do"
];
//订单信息
$orderInfo=array(
'order_name'=>"订单测试",
'amount'=>1,
'out_trade_no'=>"2021101247845"
);
$alipay=new Client($alipayconfig); //实例化,若需使用支付宝则传入支付宝配置数组
var_dump($alipay->AlipayWeb($orderInfo)); //调用网页支付接口启动支付,若为其他接口,则根据上方需示例的各个接口函数调用不同的函数,并传入指定格式的$orderInfo参数即可.
boxs\payment\Client;
use iboxs\payment\Notify;
//支付宝配置信息
$alipayconfig=[
'publicKey' =>"", //支付宝公钥
'rsaPrivateKey' =>"", //商户私钥
'appid' => "2016192400584878", //应用APPID
'notify_url' => "http://auth.itgz8.com/notify", //异步通知地址
'return_url' => "http://auth.itgz8.com/return", //同步通知地址
'charset' => "UTF-8",
'sign_type'=>"RSA2",
'gatewayUrl' =>"https://openapi.alipay.com/gateway.do" //应用网关,若为沙箱环境则为:"https://openapi.alipaydev.com/gateway.do"
];
$result=Notify::alipayNotify($alipayconfig); //调用支付宝异步验签 ////返回布尔型或数组,验签失败返回false,验签成功返回回调的数据
if($result==false){
echo 'fail';
return;
}
//进行订单处理($result内为回调的数据数组)【这里不需要再输出success,接口内已经输出了,这里只需要进行各种业务流程即可】
//订单处理逻辑,订单号$result['out_trade_no'],订单金额$result['total_amount']等,这里的$result含有所有支付宝的反馈信息
namespace iboxs\test;
$wxpayconfig=[
'mchid'=>'1504922561', //商户号
'appid'=>'', //APPID(公众号支付必须)
'apiKey'=>'', //Key
'notify_url'=>'http://auth.itgz8.com/notify', //异步通知地址
'return_url'=>'http://auth.itgz8.com/return' //网站地址(手机网页支付接口必须,其他接口不需要)
];
$orderInfo=array(
'order_name'=>"订单测试",
'amount'=>1,
'out_trade_no'=>"2021101247845"
);
$wxpay=new Client($wxpayconfig);
var_dump($wxpay->WxPayCode($orderInfo));
namespace iboxs\test;
$qqpayconfig=[
'mchid'=>'1504922561', //商户号
'apiKey'=>'', //Key
'notify_url'=>'http://auth.itgz8.com/notify' //异步通知地址
];
$orderInfo=array(
'order_name'=>"订单测试", //订单名称
'amount'=>1, //订单金额
'out_trade_no'=>"2021101247845" //订单号
);
$qqpay=new Client($qqpayconfig);
var_dump($qqpay->QQPay($orderInfo));
$orderInfo=array(
'trade_no'=>21010101010101, //微信支付流水号(微信支付回调获得的微信支付内的交易号)
'amount'=>1, //订单金额(最低0.01)
'out_trade_no'=>"2021101247845", //商户订单号(需退款的订单号),
'refund_amount'=>0.5, //退款金额
'refund_trade_no'=>54145414512541, //退款订单号(与订单号不同,退款的编号,可临时生成)
'desc'=>'用户退款' //退款说明
);
boxs\payment\Notify;
$wxpayconfig=[
'mchid'=>'1504922561', //商户号
'appid'=>'', //APPID(公众号支付必须)
'apiKey'=>'', //Key
'notify_url'=>'http://auth.itgz8.com/notify', //异步通知地址
'return_url'=>'http://auth.itgz8.com/return' //网站地址(手机网页支付接口必须,其他接口不需要)
];
$result=Notify::WxPayNotify($wxpayconfig); //调用微信回调验签 //返回布尔型或数组,验签失败返回false,验签成功返回回调的数据
if($result==false){
echo 'fail'; //回调验签失败
return;
}
//进行订单处理($result内为回调的数据数组)
//var_dump($result)
//处理订单逻辑,付款金额$result['cash_fee'],获取订单号$result['out_trade_no']等等,这里的$result含有所有微信返回的通知信息数组
boxs\payment\Notify;
$qqpayconfig=[
'mchid'=>'1504922561', //商户号
'apiKey'=>'', //Key
'notify_url'=>'http://auth.itgz8.com/notify' //异步通知地址
];
$result=Notify::QqPayNotify($qqpayconfig); //调用QQ回调验签 //返回布尔型或数组,验签失败返回false,验签成功返回回调的数据
if($result==false){
echo 'fail'; //回调验签失败
return;
}
//进行订单处理($result内为回调的数据数组)
//var_dump($result)
//处理订单逻辑,付款金额$result['cash_fee'],获取订单号$result['out_trade_no']等等,这里的$result含有所有QQ钱包返回的通知信息数组