PHP code example of houdunwang / alipay
1. Go to this page and download the library: Download houdunwang/alipay 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/ */
houdunwang / alipay example snippets
$data = [
//商户订单号,商户网站订单系统中唯一订单号,必填
'WIDout_trade_no' => time(),
//订单名称,必填
'WIDsubject' => '定单名称',
//付款金额单位元,必填
'WIDtotal_amount' => 0.01,
//商品描述,可空
'WIDbody' => '定单描述',
];
$pay->PagePay($data);
$pay = new \Houdunwang\Alipay\Alipay;
$pay->config($config);
//签名验证
if($pay->signCheck()){
//商户订单号
$out_trade_no = htmlspecialchars($_GET['out_trade_no']);
//支付宝交易号
$trade_no = htmlspecialchars($_GET['trade_no']);
echo "验证成功<br />支付宝交易号:".$trade_no;
}else{
echo '支付失败';
}