PHP code example of kennedymbale / zynle-pay-php-sdk
1. Go to this page and download the library: Download kennedymbale/zynle-pay-php-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/ */
kennedymbale / zynle-pay-php-sdk example snippets
use ZynlePay\Client;
use ZynlePay\MomoDeposit;
// Initialize client for sandbox
$client = new Client(
merchantId: 'your_merchant_id',
apiId: 'your_api_id',
apiKey: 'your_api_key',
channel: 'momo',
serviceId: '1002'
);
// Create service instance
$momoDeposit = new MomoDeposit($client);
// Process a payment
try {
$result = $momoDeposit->runBillPayment(
senderId: '09XXXXXXXX',
referenceNo: uniqid('ref_', true),
amount: 1000.00,
description: 'Payment for services'
);
echo "Payment initiated: " . $result['transaction_id'];
} catch (ZynlePay\Exception\ApiException $e) {
echo "Payment failed: " . $e->getMessage();
}
$client = new Client(
string $merchantId, // Your ZynlePay merchant ID
string $apiId, // Your API ID
string $apiKey, // Your API key
string $channel, // Payment channel (momo, card, bank, etc.)
string $serviceId = '1002', // Service ID (default: '1002')
bool $sandbox = true // true for sandbox, false for production
);
use ZynlePay\MomoDeposit;
$momoDeposit = new MomoDeposit($client);
// Process payment
$result = $momoDeposit->runBillPayment(
senderId: '09XXXXXXXX', // Sender's phone number
referenceNo: uniqid('ref_', true), // Unique reference number
amount: 1000.00, // Amount in float
description: 'Payment' // Optional description
);
// Check payment status
$status = $momoDeposit->checkPaymentStatus('REF123456');
use ZynlePay\WalletToBank;
$walletToBank = new WalletToBank($client);
// Transfer to bank
$result = $walletToBank->runPayToBank(
referenceNo: uniqid('ref_', true),
amount: 500.00,
description: 'Bank transfer',
bankName: 'Bank of Example',
receiverId: '1234567890'
);
// Check transfer status
$status = $walletToBank->checkBankTransferStatus('REF123456');
use ZynlePay\MomoWithdraw;
$momoWithdraw = new MomoWithdraw($client);
// Withdraw to MOMO
$result = $momoWithdraw->runPayToEwallet(
referenceNo: 'REF123456',
amount: 200.00,
receiverId: '09XXXXXXXX'
);
// Check withdrawal status
$status = $momoWithdraw->checkEwalletTransferStatus('REF123456');