PHP code example of linyuee / ali

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

    

linyuee / ali example snippets


$pay = new \Linyuee\AliPay('appid');
$biz_content = array('subject'=>'标题','out_trade_no'=>'订单号','total_amount'=>'金额单位分');
$pay->setFormat($biz_content);
$pay->setAppPrivateKey('app密钥');
$pay->setAliPayPublicKey('支付宝公钥');
$pay->setNotifyUrl('回调地址');
$res = $pay->unifiedorder(); 

$pay = new \Linyuee\AliPay('appid');
        $biz_content = array(
            'subject'=>'课程购买',
            'out_trade_no'=>121256465846,
            'total_amount'=>0.01,

        );
$pay->setPayFormat($biz_content);
$pay->setAppPrivateKey('app密钥');
$pay->setAliPayPublicKey('支付宝公钥');
$pay->setNotifyUrl('回调地址');
$pay->setReturnUrl('支付后跳转地址');
$res = $pay->wapPay(); 

$pay = new \Linyuee\AliPay('appid');
        $biz_content = array(
            'subject'=>'课程购买',
            'out_trade_no'=>121256465846,
            'total_amount'=>0.01,

        );
$pay->setPayFormat($biz_content);
$pay->setAppPrivateKey('app密钥');
$pay->setAliPayPublicKey('支付宝公钥');
$pay->setNotifyUrl('回调地址');
$pay->setReturnUrl('支付后跳转地址');
$res = $pay->pagePay(); 

$pay = new \Linyuee\AliPay('appid');
$biz_content = array('out_trade_no'=>121256465846,'refund_amount'=>0.01);
$pay->setRefundFormat($biz_content);
$pay->setAppPrivateKey('app密钥');
$pay->setAliPayPublicKey('支付宝公钥');
$res = $pay->refund();