Developer Quickstart

Bắt đầu với Pay27 API

Tích hợp trong 5 phút. Gọi API đầu tiên của bạn ngay bây giờ.

REST API SDK Node.js SDK Python
01

Đăng ký & lấy API Key

Tạo tài khoản Pay27 và lấy API Key chỉ trong 30 giây. API Key sẽ được dùng để xác thực mọi request sau này.

cURL
curl -X POST https://api.pay27.vn/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "dev@yourcompany.vn",
    "password": "your-secure-password",
    "name": "Your Company"
  }'

# Response
{
  "id": "usr_abc123",
  "email": "dev@yourcompany.vn",
  "api_key": "pb_live_x1y2z3a4b5c6d7e8f9",
  "plan": "starter"
}

Console Dashboard - API Key Management

(Screenshot placeholder - Bảng quản lý API Key)

02

Gọi API đầu tiên

Tạo payout đầu tiên qua endpoint POST /v1/payouts. Chọn cổng thanh toán, số tiền, đơn vị tiền tệ và người nhận.

cURL
curl -X POST https://api.pay27.vn/v1/payouts \
  -H "Authorization: Bearer pb_live_x1y2z3..." \
  -H "Content-Type: application/json" \
  -d '{
    "gateway": "paypal",
    "amount": 100.00,
    "currency": "USD",
    "recipient": "recipient@example.com",
    "note": "Thanh toán tháng 6/2026"
  }'

# Response
{
  "id": "txn_9k8j7h6g5f",
  "status": "processing",
  "gateway": "paypal",
  "amount": 100.00,
  "currency": "USD",
  "created_at": "2026-06-02T07:30:00Z"
}
Node.js
// Cài đặt: npm install @pay27/sdk

import { Pay27 } from "@pay27/sdk";

const client = new Pay27({
  apiKey: "pb_live_x1y2z3a4b5c6d7e8f9",
  environment: "production",
});

const payout = await client.payouts.create({
  gateway: "paypal",
  amount: 100.0,
  currency: "USD",
  recipient: "recipient@example.com",
  note: "Thanh toán tháng 6/2026",
});

console.log(payout.id);  // txn_9k8j7h6g5f
console.log(payout.status);  // processing
Python
# Cài đặt: pip install pay27-sdk

from pay27 import Pay27Client

client = Pay27Client(
    api_key="pb_live_x1y2z3a4b5c6d7e8f9",
    environment="production"
)

payout = client.payouts.create(
    gateway="paypal",
    amount=100.00,
    currency="USD",
    recipient="recipient@example.com",
    note="Thanh toán tháng 6/2026"
)

print(payout.id)       # txn_9k8j7h6g5f
print(payout.status)   # processing
03

Nhận Webhook

Expose một endpoint trên server của bạn để nhận thông báo giao dịch real-time. Pay27 sẽ gửi POST request với chữ kýHMAC-SHA256 để bạn xác thực.

Node.js (Express)
// Webhook endpoint (Express.js)
const express = require("express");
const crypto = require("crypto");

const app = express();

app.post("/webhooks/pay27", express.json(), (req, res) => {
  const signature = req.headers["x-pay27-signature"];
  const secret = process.env.PAY27_WEBHOOK_SECRET;

  // Verify signature
  const payload = JSON.stringify(req.body);
  const expected = crypto
    .createHmac("sha256", secret)
    .update(payload)
    .digest("hex");

  if (signature !== expected) {
    return res.status(401).json({ error: "Invalid signature" });
  }

  // Xử lý event
  const { event, data } = req.body;
  switch (event) {
    case "payout.completed":
      console.log(`Payout ${data.id} thành công!`);
      break;
    case "payout.failed":
      console.error(`Payout ${data.id} thất bại`);
      break;
  }

  res.json({ received: true });
});

app.listen(3000, () => console.log("Webhook server running on :3000"));

Endpoint cần expose

POST endpoint public (HTTPS), trả về 200 OK trong 5 giây.

Luôn verify signature

Dùng secret từ Dashboard để HMAC-SHA256 verify payload.

Bạn đã sẵn sàng

Chỉ với 3 bước đơn giản, bạn đã có thể nhận thanh toán từ 27 cổng toàn cầu qua một API duy nhất. Bắt đầu ngay hôm nay.