PHP code example of cccdl / ali-sdk

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

    

cccdl / ali-sdk example snippets




use cccdl\ali\Alipay\Util\SystemOauthToken;

$config = [
    'appid' => '请填写您的AppId',
    //支付宝公钥
    'public_key' => '请填写您的支付宝公钥',
    //应用私钥
    'private_key' => '请填写您的应用私钥',
    //回调地址
    'notify_url' => '请填写您的回调地址',
     //获取地址 https://openhome.alipay.com/platform/keyManage.htm?keyType=partner 合作伙伴身份pid
    'pid' => '请填写合作伙伴身份pid',
];
$app = new AlipayOpenSystemOauthToken($config);
$result = $app->apply([
    // 授权方式。支持:1.authorization_code,表示换取使用用户授权码code换取授权令牌access_token。 2.refresh_token,表示使用refresh_token刷新获取新授权令牌。
    'grant_type' => 'authorization_code',
    // 授权码,用户对应用授权后得到。本参数在 grant_type 为 authorization_code 时必填;为 refresh_token 时不填。
    'code' => '',
]);



use cccdl\ali\Alipay\Pay\AlipayTradeAppPay;
$config = [
    'appid' => '请填写您的AppId',
    //支付宝公钥
    'public_key' => '请填写您的支付宝公钥',
    //应用私钥
    'private_key' => '请填写您的应用私钥',
    //回调地址
    'notify_url' => '请填写您的回调地址',
     //获取地址 https://openhome.alipay.com/platform/keyManage.htm?keyType=partner 合作伙伴身份pid
    'pid' => '请填写合作伙伴身份pid',
];
$app = new AlipayTradeAppPay($config);
$app->notify();