[更新]更新支付宝支付代码

This commit is contained in:
Anyon 2018-10-30 17:51:26 +08:00
parent 81a18b8b3a
commit 9dba6a72a6
4 changed files with 14 additions and 14 deletions

View File

@ -23,6 +23,10 @@ use AliPay\Contracts\AliPay;
*/
class Bill extends AliPay
{
/**
* Bill constructor.
* @param array $options
*/
public function __construct(array $options)
{
parent::__construct($options);

View File

@ -21,6 +21,7 @@ $config = include "./alipay.php";
try {
// 实例支付对象
$pay = new \AliPay\App($config);
// 请参考请求参数https://docs.open.alipay.com/api_1/alipay.trade.app.pay
$result = $pay->apply([
'out_trade_no' => time(), // 商户订单号
'total_amount' => '1', // 支付金额

View File

@ -19,8 +19,9 @@ include "../include.php";
$config = include "./alipay.php";
try {
// 实例支付对象
// 实例支付对象
$pay = new \AliPay\Bill($config);
// 请参考请求参数https://docs.open.alipay.com/api_15/alipay.data.dataservice.bill.downloadurl.query
$result = $pay->apply([
'bill_date' => '2017-11-03', // 账单时间(日账单yyyy-MM-dd,月账单 yyyy-MM)
'bill_type' => 'signcustomer', // 账单类型(trade指商户基于支付宝交易收单的业务账单,signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单)

View File

@ -19,9 +19,8 @@ include "../include.php";
$config = include "./alipay.php";
// 实例支付对象
$pay = new \Pay\Pay($config);
if ($pay->driver('alipay')->gateway()->verify($_POST)) {
$pay = new \AliPay\App($config);
if ($pay->verify($_POST)) {
file_put_contents('notify.txt', "收到来自支付宝的异步通知\r\n", FILE_APPEND);
file_put_contents('notify.txt', '订单号:' . $_POST['out_trade_no'] . "\r\n", FILE_APPEND);
file_put_contents('notify.txt', '订单金额:' . $_POST['total_amount'] . "\r\n\r\n", FILE_APPEND);
@ -29,14 +28,9 @@ if ($pay->driver('alipay')->gateway()->verify($_POST)) {
file_put_contents('notify.txt', "收到异步通知\r\n", FILE_APPEND);
}
// 下面是项目的真实代码
/*
$pay = new \Pay\Pay(config('pay'));
$notifyInfo = $pay->driver('alipay')->gateway('app')->verify(request()->post('', '', null));
p($notifyInfo, false, RUNTIME_PATH . date('Ymd') . '_notify.txt');
if (in_array($notifyInfo['trade_status'], ['TRADE_SUCCESS', 'TRADE_FINISHED'])) {
// 更新订单状态
$this->updateOrder($notifyInfo['out_trade_no'], $notifyInfo['trade_no'], $notifyInfo['receipt_amount'], 'alipay');
// 下面是支付通知处理
$pay = new \AliPay\App($config);
$notify = $pay->verify($_POST);
if (in_array($notify['trade_status'], ['TRADE_SUCCESS', 'TRADE_FINISHED'])) {
// @todo 更新订单状态,支付完成
}
*/