PHP code example of guanguans / dcloud-app-pay

1. Go to this page and download the library: Download guanguans/dcloud-app-pay 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/ */

    

guanguans / dcloud-app-pay example snippets

 php
e Guanguans\Alipay\Alipay;

$config = [
    'app_id'         => '', // 支付宝提供的 APP_ID
    'notify_url'     => '', // 支付宝异步通知地址
    'ali_public_key' => '', // 支付宝公钥,1行填写
    'private_key'    => '', // 自己的私钥,1行填写
];

$alipy = new Alipay($config);

$config_biz = [
    'out_trade_no' => time(),    // 订单号
    'total_amount' => '1',       // 订单金额,单位:元
    'subject'      => 'subject', // 订单商品标题
    'body'         => 'body',    // 订单商品内容
];

echo $alipy->pay($config_biz);