PHP code example of vrobin / alipay-sdk

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

    

vrobin / alipay-sdk example snippets


    $keyPair = \Alipay\Key\AlipayKeyPair::create(
        '应用私钥',
        '支付宝公钥',
    );
    

    $aop = new \Alipay\AopClient('APP_ID', $keyPair);
    

    $request = (new \Alipay\AlipayRequestFactory)->create('点号连接的API名称', [
        '请求参数名' => '对应参数值',
        // ...
    ]);
    

    $request = new \Alipay\Request\AlipaySystemOauthTokenRequest();
    $request->setCode('authcode');
    

    $result = $aop->execute($request)->getData();
    

   $aop->encryptKey = 'AES秘钥';
   $request = new \Alipay\Request\AlipaySystemOauthTokenRequest(['needNeedEncrypt'=>true]);
   

   $decrypt_string = \Alipay\AopEncrypt::decrypt('秘文','秘钥');