URL API
https://spayment.net/api/zalopaysend
Code Example
// URL API ZaloPaySend
$url = 'https://spayment.net/api/zalopaysend';
// Dữ liệu gửi đi
$data = [
'token' => 'YOUR_VALID_TOKEN', // Token xác thực người dùng
'pin' => '123456', // Mã PIN ZaloPay
'phone' => '0987654321', // Số điện thoại người nhận tiền
'amount' => 100000, // Số tiền muốn chuyển (VNĐ)
'description' => 'Chuyển tiền qua API' // Nội dung chuyển khoản
];
// Khởi tạo cURL
$ch = curl_init();
// Cấu hình cURL
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Lấy phản hồi
curl_setopt($ch, CURLOPT_POST, true); // Sử dụng POST
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); // Gửi JSON
curl_setopt($ch, CURLOPT_HTTPHEADER, [ // Header
'Content-Type: application/json',
'Accept: application/json'
]);
// (Tùy chọn) Bỏ kiểm tra chứng chỉ SSL nếu test máy local
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Thực hiện yêu cầu
$response = curl_exec($ch);
// Kiểm tra lỗi cURL
if (curl_errno($ch)) {
echo '❌ Lỗi cURL: ' . curl_error($ch);
curl_close($ch);
exit;
}
// Lấy mã trạng thái HTTP
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// Giải mã JSON
$responseData = json_decode($response, true);
// Hiển thị kết quả
if ($httpCode === 200) {
echo "✅ Thành công:\n";
print_r($responseData);
} else {
echo "❌ Thất bại (HTTP $httpCode):\n";
print_r($responseData);
}