PHP code example of jinzhisu / ali-pay-sdk-for-php

1. Go to this page and download the library: Download jinzhisu/ali-pay-sdk-for-php 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/ */

    

jinzhisu / ali-pay-sdk-for-php example snippets


$aop = new JinZhiSu\AliPay\AopClient ();
$aop->gatewayUrl = 'https://openapi.alipaydev.com/gateway.do';
$aop->appId = '应用ID';
$aop->rsaPrivateKey = '应用私钥';
$aop->alipayrsaPublicKey= '应用公钥';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='UTF-8';
$aop->format='json';
$request = new JinZhiSu\AliPay\request\AlipayTradeAppPayRequest();
$request->setBizContent(json_encode([
    'out_trade_no' => date('YmdHis') . mt_rand(10000,99999),
    'body' => 'XXX',
    'subject' => 'XXX',
    'goods_type' => 0,
]));
$result = $aop->sdkExecute($request);
var_dump($result);