PHP code example of busyphp / alipay-pay

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

    

busyphp / alipay-pay example snippets




return [
    
    // 支付相关配置
    'pay' => [
        // 电脑网站支付
        'pc'  => [
            // 'type'             => 1,
            // 'email'            => '',
            // 'pattern'          => '',
            // 'app_id'           => '',
            // 'rsa_private_path' => app()->getRootPath() . '私钥路径',
            // 'rsa_public_path'  => app()->getRootPath() . '公钥路径',
            // 'is_rsa2'          => true
        ],
        
        // H5支付
        'h5'  => [
            // 'type'             => 2,
            // 'email'            => '',
            // 'pattern'          => '',
            // 'app_id'           => '',
            // 'rsa_private_path' => app()->getRootPath() . '私钥路径',
            // 'rsa_public_path'  => app()->getRootPath() . '公钥路径',
            // 'is_rsa2'          => true
        ],
        
        // APP支付
        'app' => [
            // 'type'             => 3,
            // 'email'            => '',
            // 'pattern'          => '',
            // 'app_id'           => '',
            // 'rsa_private_path' => app()->getRootPath() . '私钥(pkcs8)路径',
            // 'rsa_public_path'  => app()->getRootPath() . '公钥文件路径',
            // 'is_rsa2'          => false
        ],
    ]
];


use BusyPHP\alipay\pay\AliPayPay;
use BusyPHP\trade\defines\PayType;

return [
    // 支付接口绑定
    'apis'            => [
        PayType::ALIPAY_PC => AliPayPay::pc(),
        PayType::ALIPAY_H5 => AliPayPay::h5(),
        PayType::ALIPAY_APP => AliPayPay::app(),
    ]
];