PHP code example of toanppp / php-zalo-pay

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

    

toanppp / php-zalo-pay example snippets


$params = [
    'appID'      => 'appID',
    'paymentID'  => 'paymentID',
    'hMacKey'    => 'hMacKey',
    'privateKey' => 'privateKey',
];

$zaloPay = new ZaloPay($params, ZaloPay::ENV_SANDBOX_QC);

// Query user
$phone = '0987654321';
$queryUserRequestID = '';
$userInfoResponse = $zaloPay->queryUser($phone, $queryUserRequestID);

if ($userInfoResponse['return_code'] != ZaloPay::RETURN_CODE_SUCCESS) {
    return false;
}

// Disbursement
$partnerOrderID = '';
return $zaloPay->disbursement($userInfoResponse['data']['m_u_id'], 1, 'Demo disbursement', [], [], $partnerOrderID, 3);
shell
composer