PHP Zalo Pay integration.
- Payment
- Disbursement
composer require toanppp/php-zalo-pay
Create Zalo Pay service instance
param
must containappID
,paymentID
,hMacKey
,privateKey
env
:ZaloPay::ENV_PRODUCTION
|ZaloPay::ENV_SANDBOX
|ZaloPay::ENV_SANDBOX_QC
$params = [
'appID' => 'appID',
'paymentID' => 'paymentID',
'hMacKey' => 'hMacKey',
'privateKey' => 'privateKey',
];
$zaloPay = new ZaloPay($params, ZaloPay::ENV_SANDBOX_QC);
Query Zalo Pay user info.
Transfer fund to user's wallet.
Params:
string
mUID : response inqueryUser
functionint
amountstring
descriptionarray
partnerEmbedDataarray
extraInfostring
&partnerOrderID
Query order info (status,...).
Query merchant's wallet balance.
Transfer fund to user's wallet & query status.
// 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);