PHP code example of iicc / pay-sdk
1. Go to this page and download the library: Download iicc/pay-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/ */
iicc / pay-sdk example snippets
// SDK实例化,传入公共配置
$pay = new \Iiccn\PaySDK\Alipay\SDK($params);
// 支付接口
$request = new \Iiccn\PaySDK\Alipay\Params\Pay\Request;
$request->notify_url = ''; // 支付后通知地址(作为支付成功回调,这个可靠)
$request->return_url = ''; // 支付后跳转返回地址
$request->businessParams->seller_id = $GLOBALS['PAY_CONFIG']['appid']; // 卖家支付宝用户号
$request->businessParams->out_trade_no = 'test' . mt_rand(10000000,99999999); // 商户订单号
$request->businessParams->total_fee = 0.01; // 价格
$request->businessParams->subject = '测试商品'; // 商品标题
// 跳转到支付宝页面
$pay->redirectExecute($request);
// SDK实例化,传入公共配置
$pay = new \Iiccn\PaySDK\AlipayApp\SDK($params);
// 支付接口
$request = new \Iiccn\PaySDK\AlipayApp\Wap\Params\Pay\Request;
$request->notify_url = ''; // 支付后通知地址(作为支付成功回调,这个可靠)
$request->return_url = ''; // 支付后跳转返回地址
$request->businessParams->out_trade_no = 'test' . mt_rand(10000000,99999999); // 商户订单号
$request->businessParams->total_amount = 0.01; // 价格
$request->businessParams->subject = '小米手机9黑色陶瓷尊享版'; // 商品标题
// 跳转到支付宝页面
$pay->redirectExecute($request);
// SDK实例化,传入公共配置
$pay = new \Iiccn\PaySDK\Weixin\SDK($params);
// 支付接口
$request = new \Iiccn\PaySDK\Weixin\H5\Params\Pay\Request;
$request->body = 'test'; // 商品描述
$request->out_trade_no = 'test' . mt_rand(10000000,99999999); // 订单号
$request->total_fee = 1; // 订单总金额,单位为:分
$request->spbill_create_ip = '127.0.0.1'; // 客户端ip
$request->notify_url = ''; // 异步通知地址
// 调用接口
$result = $pay->execute($request);
if($pay->checkResult())
{
// 跳转支付界面
header('Location: ' . $result['mweb_url']);
}
else
{
var_dump($pay->getErrorCode() . ':' . $pay->getError());
}
exit;
\Yurun\Util\YurunHttp::setDefaultHandler('Yurun\Util\YurunHttp\Handler\Swoole');