ZaloPay Gateway Integration: Tap Into the 75 Million Zalo User Ecosystem
If MoMo is the "king" of standalone e-wallets, ZaloPay holds a "nuclear weapon" that no competitor can match: it lives directly inside the Zalo app—Vietnam's #1 messaging platform with over 75 million regular users.
Integrating ZaloPay isn't just about adding another payment gateway; it's about opening the door to reach customers right while they are chatting or browsing Zalo OA. This article will guide you on how to harness the power of the Zalo ecosystem via its payment API.
1. Why Is ZaloPay a "Goldmine" for Businesses?
- No extra app installation required: 75 million Zalo users already have the ZaloPay wallet built right into their devices. Payment friction is virtually zero.
- In-chat payments on Zalo: Customers can pay directly inside the chat window while consulting with your staff (via Zalo OA).
- Zalo Mini App support: If you build a sales Mini App on Zalo, integrating ZaloPay delivers the smoothest native experience.
- Strong promotions: ZaloPay frequently runs deep discount campaigns for utility bills, Tiki and Lazada shopping, and more.
2. Popular ZaloPay Integration Methods
2.1. Gateway (Website Payment Gateway)
Designed for standard e-commerce websites. Customers select ZaloPay -> scan the QR code on screen or switch to the Zalo app to confirm.
2.2. Quick Pay
Designed for mobile apps or Zalo Mini Apps. Users link their ZaloPay account once, and subsequent payments take just 1 tap (no need to re-enter details).
2.3. Multi-Purpose QR
A single QR code that accepts both ZaloPay wallets and Mobile Banking apps. Extremely convenient for in-store (offline) counter payments.
3. ZaloPay Merchant Registration Process
Similar to MoMo, you need to register a Business account:
- Visit the ZaloPay Merchant Portal.
- Register and verify your legal business documents.
- Retrieve your integration credentials under the "Technical" (Kỹ thuật) section:
<li>App ID: Your application identifier.
- Key1 (Mac Key): Used to generate encrypted signatures for outgoing requests.
- Key2 (Callback Key): Used to verify data returned by ZaloPay.
</li>
4. Technical Integration Guide (ZaloPay API)
We will use the order creation API: <code>/v2/create</code>.
Step 1: Create Order Data (Payload)
<code>$config = [
"app_id" => 2553,
"key1" => "PcY4...",
"key2" => "kLtg...",
"endpoint" => "https://sb-openapi.zalopay.vn/v2/create" // Sandbox
];
$embed_data = [
"redirecturl" => "https://yourwebsite.com/result",
"columninfo" => ["store_name" => "JAY Store"]
];
$items = [
["itemid" => "knb", "itemname" => "Kim Nguyen Bao", "itemprice" => 198400, "itemquantity" => 1]
]; // Product items array
$order = [
"app_id" => $config["app_id"],
"app_time" => round(microtime(true) * 1000), // Milliseconds
"app_trans_id" => date("ymd") . "_" . uniqid(), // Transaction ID (Format: YYMMDD_xxxx)
"app_user" => "user123",
"item" => json_encode($items, JSON_UNESCAPED_UNICODE),
"embed_data" => json_encode($embed_data, JSON_UNESCAPED_UNICODE),
"amount" => 50000,
"description" => "JAY Store - Payment for Order #123",
"bank_code" => "zalopayapp" // Default to opening ZaloPay wallet
];</code></pre>
Step 2: Generate Signature (HMAC)
<p>ZaloPay uses a simpler signing string structure than MoMo: <code>app_id|app_trans_id|app_user|amount|app_time|embed_data|item</code>.
<code>$data = $order["app_id"] . "|" . $order["app_trans_id"] . "|" . $order["app_user"] . "|" . $order["amount"] .
"|" . $order["app_time"] . "|" . $order["embed_data"] . "|" . $order["item"];
$order["mac"] = hash_hmac("sha256", $data, $config["key1"]);</code></pre>
Step 3: Send Request and Handle Response
<pre><code>$context = stream_context_create([
"http" => [
"header" => "Content-type: application/x-www-form-urlencoded\r\n",
"method" => "POST",
"content" => http_build_query($order)
]
]);
$response = file_get_contents($config["endpoint"], false, $context);
$result = json_decode($response, true);
if ($result['return_code'] == 1) {
// Redirect customer to ZaloPay payment page
header('Location: ' . $result['order_url']);
} else {
// Handle error
echo "Order creation error: " . $result['return_message'];
}</code></pre>
Step 4: Handle Callback (Webhook)
<p>ZaloPay will call the callback URL you registered in the Merchant admin portal (rather than passing it in the order creation request like MoMo).
<code>// File: callback.php
$postdata = file_get_contents('php://input');
$result_data = json_decode($postdata, true);
// Recalculate MAC for verification
$mac = hash_hmac("sha256", $result_data["data"], $config["key2"]);
if ($mac != $result_data["mac"]) {
// MAC mismatch -> Possible tampering
$return["return_code"] = -1;
$return["return_message"] = "Invalid MAC";
} else {
// MAC matched -> Update order status to paid
// Parse data JSON
$order_data = json_decode($result_data["data"], true);
// ... Update Database ...
$return["return_code"] = 1;
$return["return_message"] = "Success";
}
echo json_encode($return);</code></pre>
5. Key Differences Between ZaloPay and MoMo
<table><thead><tr><th>Criteria</th><th>ZaloPay</th><th>MoMo</th></tr></thead><tbody><tr><td>Users</td><td>75 Million (Zalo Users)</td><td>31 Million (App Users)</td></tr><tr><td>Integration</td><td>Slightly more complex (Callback configured in Portal)</td><td>Flexible (Pass notifyUrl in request)</td></tr><tr><td>Encryption</td><td>Uses separate Key1 (Request) and Key2 (Response)</td><td>Uses a single shared Secret Key</td></tr><tr><td>Strengths</td><td>Mini App & Zalo OA</td><td>In-store payments & Entertainment</td></tr></tbody></table>
6. JAYbranding - Strategic ZaloPay Integration Partner
<p>ZaloPay is part of the massive Zalo ecosystem. To maximize its potential, you don't just need a payment API—you also need to combine it with Zalo OA and ZNS.
JAYbranding's Solutions:
- ✅ Combo Integration: ZaloPay payment + automated order confirmation messages via Zalo OA (ZNS).
- ✅ Mini App Development: Build a storefront right inside Zalo with built-in 1-tap checkout.
- ✅ Automated Reconciliation: Tools that automatically match revenue between ZaloPay and your sales management software.
🚀 Reach 75 million Zalo customers today!
Contact us for a solution consultation: 0989 971 131
FAQ - Frequently Asked Questions About ZaloPay
[faqs]
#### Can I integrate ZaloPay if I don't have a Zalo OA yet?
Yes. ZaloPay Merchant and Zalo OA are two separate accounts. However, having both helps you deliver much better post-payment customer care.
#### Does ZaloPay support Visa/Mastercard?
Yes. If customers have linked an international card to their ZaloPay wallet, they can use that funding source to pay you.
[/faqs]