PHP code example of antom / global-open-sdk-php

1. Go to this page and download the library: Download antom/global-open-sdk-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/ */

    

antom / global-open-sdk-php example snippets






Language:PHP
PHP version:5.4.7+
Releass ^1.3.4
Copyright:Ant financial services group
bash
composer 

class YourAlipayClient extends  \Client\BaseAlipayClient{

     function __construct()
    {
        $a = func_get_args();
        $i = func_num_args() - 2;
        if (method_exists($this, $f = '__construct' . $i)) {
            call_user_func_array(array($this, $f), $a);
        }
    }

    function __construct1($gatewayUrl, $merchantPrivateKey, $alipayPublicKey)
    {
        parent::__construct($gatewayUrl, $merchantPrivateKey, $alipayPublicKey);
    }

    function __construct2($gatewayUrl, $merchantPrivateKey, $alipayPublicKey, $clientId)
    {
        parent::__construct($gatewayUrl, $merchantPrivateKey, $alipayPublicKey, $clientId);
    }

    protected function buildCustomHeader(){
        return null;
    }

    protected function sendRequest($requestUrl, $httpMethod, $headers, $reqBody){
        $httpRpcResult = new HttpRpcResult();

        // TODO
        // $httpRpcResult->setRspBody($rspBody);
        // $httpRpcResult->setRspSign($rspSign);
        // $httpRpcResult->setRspTime($rspTime);

        return $httpRpcResult;
    }

}

$yourAlipayClient  = new YourAlipayClient("https://open-sea.alipay.com", $merchantPrivateKey, $alipayPublicKey);
$alipayPayResponse = $yourAlipayClient->execute($aliPayRequest);