https://github.com/zhan3333/alipay
个人使用的支付宝支付库
https://github.com/zhan3333/alipay
Last synced: 12 months ago
JSON representation
个人使用的支付宝支付库
- Host: GitHub
- URL: https://github.com/zhan3333/alipay
- Owner: zhan3333
- Created: 2017-02-28T01:13:42.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-01T02:27:57.000Z (over 9 years ago)
- Last Synced: 2025-04-14T00:50:05.188Z (about 1 year ago)
- Language: PHP
- Size: 190 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 库目的
1. 导入阿里支付宝新版sdk
2. 增加一些配置入口,让配置更简单
3. 添加example示例
# 配置文件
```php
'RSA2',
// 配置
// 异步通知地址
// 'notifyUrl' => 'https://local.ykxing.com/zhan/yiyuan/AliPay_notify',
// 支付宝提供的appId
// 'appId' => '2017021705720667'
// rsa签名验证的私钥地址
// 'rsaPrivateKey' => file_get_contents(__DIR__ . '/key/rsa_private_key'),
// 支付宝提供的公钥地址
// 'rsaAliPubPath' => file_get_contents(__DIR__ . '/key/ali_pay_rsa_public_key'),
// 沙箱配置
'notifyUrl' => 'https://local.ykxng.com/zhan/zhan/example/notify.php',
'appId' => '2016080100139922',
'getewayUrl' => 'https://openapi.alipaydev.com/gateway.do',
'rsaPrivateKey' => file_get_contents(__DIR__ . '/sandboxKey/rsa_private_key'),
'rsaAliPubPath' => file_get_contents(__DIR__ . '/sandboxKey/ali_pay_rsa_public_key'),
];
```
# 创建订单
```php
(string)time(),
'total_amount' => '0.01',
'subject' => '测试商品',
'timeout_express' => '30m',
'body' => '我是测试数据'
]);
$order = $payment->getPayOrder($bizcontent); // 获取订单信息返回前端
echo $order;
```
# 接收支付宝异步回调数据
```php
pushHandler(new StreamHandler(__DIR__ . '/log/notify.log'));
$aop = new \Payment\api\AopClient();
$aop->alipayrsaPublicKey = file_get_contents(__DIR__ . '/key/ali_pay_rsa_public_key');
$log->debug('11', []);
$flag = $aop->rsaCheckV2($_POST, null, 'RSA2'); // 签名验证
$log->debug('post data', ['flag' => $flag, 'POST' => $_POST]);
```