gzdsx / alipay-sdk
PHP SDK for Alipay
1.1.0
2023-03-22 06:34 UTC
Requires
- php: ^7.0
- ext-curl: *
- ext-json: *
- ext-openssl: *
This package is auto-updated.
Last update: 2025-03-29 01:06:21 UTC
README
开始
composer require gzdsx/alipay-sdk
注册APP
在应用入口处注册,如Laravel的AppSericeProvider的boot处
AlipaySdk::register('支付宝私钥','支付宝公钥','默认通知地址','默认返回地址');
创建订单
$order = new AlipayUnifiedOrderBuilder(); $order->out_trade_no = time(); $order->subject = '测试商品'; $order->total_amount = 100;
APP支付
AlipaySdk::appPay() ->setBizContent($order->getBizContent()) ->createPayStr();
网页支付
AlipaySdk::pagePay() ->setBizContent($order->getBizContent()) ->buildRequestForm();
订单查询
AlipaySdk::query()->setBizContent(['out_trade_no'=>'你的订单号'])->sendRequest();
关闭订单
AlipaySdk::close()->setBizContent(['out_trade_no'=>'你的订单号'])->sendRequest();
退款
$order = new AlipayRefundOrderBuilder(); $order->out_trade_no = '你的订单号'; $order->refund_amount = '退款金额'; $order->refund_reason = '退款原因'; AlipaySdk::refund()->setBizContent($order->getBizContent())->sendRequest();
退款查询
AlipaySdk::refundQuery()->setBizContent(['out_trade_no'=>'你的订单号'])->sendRequest();