PHP code example of gzdsx / alipay-sdk

1. Go to this page and download the library: Download gzdsx/alipay-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/ */

    

gzdsx / alipay-sdk example snippets


AlipaySdk::register('支付宝私钥','支付宝公钥','默认通知地址','默认返回地址');

$order = new AlipayUnifiedOrderBuilder();
$order->out_trade_no = time();
$order->subject = '测试商品';
$order->total_amount = 100;

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();