PHP code example of yuxiaobo / ant-cloudpay-sdk
1. Go to this page and download the library: Download yuxiaobo/ant-cloudpay-sdk 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/ */
yuxiaobo / ant-cloudpay-sdk example snippets
$config = new Config();
$config->setBAppId('云支付应用ID');
$config->setGateway('云支付网关');
$config->setRsaPrivateKey('私钥');
$config->setAliPublicKey('支付宝公钥');
$config->setCpMid('云支付商户id');
$req = new Client($config);
$resp = $req->execute('ant.antfin.eco.cloudpay.trade.pay', array(
'out_order_no' => '545454345', // 订单编号
'scene' => 'bar_code', // 条形码
'total_amount' => '0.01', // 金额: 元
'auth_code' => '28763443825664394', // 支付授权码:如果是扫码就是支付宝或者微信付款码对应的那串数字
'subject' => 'Iphone6 16G', // 订单标题
'body' => 'Iphone6 16G', // 对交易或商品的描述 [非必填]
'notify_url' => '2145', // 回调地址
'cp_store_id' => '20200901145300003099286200000650' // 云支付商户门店编号
));
$config = new Config();
$config->setBAppId('云支付应用ID');
$config->setGateway('云支付网关');
$config->setRsaPrivateKey('私钥');
$config->setAliPublicKey('支付宝公钥');
$config->setCpMid('云支付商户id');
$req = new Client($config);
$resp = $req->execute('ant.antfin.eco.cloudpay.trade.refund', array(
'out_order_no' => '1651715489', // 商户订单号,和第三方支付号不能同时为空
// 'trans_no' => '12131', // 第三方支付号,和商户订单号不能同时为空
'refund_amount' => '0.01', // 退款金额
'out_request_no' => '131324', // 外部退款单号,标识一次退款请求
'notify_url' => '2145',
// 'pay_channel' => 'alipay', // 第三方支付类型,如果选择trans_no,则不能为空 [alipay, wechat]
// 云支付商户门店编号
));
$success = $aop->checkSign($_POST);
if ($success == false) {
die('error');
}
die('success');