Chuyển tới nội dung chính

Lấy danh sách phương thức thanh toán (Backend)

API getPaymentMethods cho phép Order Backend/Merchant Backend lấy danh sách phương thức thanh toán đang enable theo terminal (xác định bằng X-Payment-API-Key) và điều kiện giao dịch (amount, currency).

Endpoint

Endpoint: GET /api/payments/v1/payment-methods

Authentication

API yêu cầu xác thực bằng X-Payment-API-Key (service-to-service). API này không dành cho client/frontend gọi trực tiếp.

Headers

HeaderRequiredMô tả
X-Payment-API-KeyAPI key của merchant/terminal
Accept-LanguageNgôn ngữ phản hồi (nếu hệ thống có cấu hình localization)

Query Parameters

ParameterRequiredTypeMô tả
amountnumberSố tiền giao dịch, dùng để filter theo min/max giới hạn của từng payment method theo currency
currencystringMã tiền tệ (VD: VND, USD)

Lưu ý:

  • API hiện trả về full list (không phân trang).
  • merchantId/terminalId (nếu có trong request struct nội bộ) sẽ được enforce từ X-Payment-API-Key (không tin vào client-provided values).

Response

Success Response (200):

{
"items": [
{
"paymentMethodId": "uuid-string",
"code": "string",
"name": "string",
"type": "CARD",
"category": "CREDIT",
"iconUrl": "string",
"provider": {
"id": "uuid-string",
"name": "string",
"code": "string"
},
"supportsTokenization": true,
"requiresRedirect": false,
"sortOrder": 1,
"verificationAmount": 0.0,
"currencies": [
{
"currency": "VND",
"minAmount": 10000.0,
"maxAmount": 50000000.0
}
]
}
]
}

Response Field Details

  • items[] là danh sách PaymentMethodResponse đã được filter theo terminal/merchant config và điều kiện amount/currency.
  • Nếu nhiều provider cùng hỗ trợ một payment method, hệ thống sẽ chọn provider có priority cao nhất (giá trị ưu tiên nhỏ hơn).

Bảng chi tiết các field trong response:

FieldTypeMô tả
itemsarrayDanh sách phương thức thanh toán (PaymentMethodResponse)
items[].paymentMethodIdstring (UUID)ID phương thức thanh toán
items[].codestringMã phương thức (VD: CREDIT_CARD, WALLET)
items[].namestringTên hiển thị phương thức thanh toán
items[].typestringLoại: CARD, WALLET, BANK_TRANSFER, v.v.
items[].categorystringHạng mục (VD: CREDIT, DEBIT)
items[].iconUrlstringURL icon hiển thị
items[].providerobjectProvider được chọn cho method này
items[].provider.idstring (UUID)ID provider
items[].provider.namestringTên provider
items[].provider.codestringMã provider
items[].supportsTokenizationbooleanCó hỗ trợ lưu thẻ/tokenization không
items[].requiresRedirectbooleanCó cần redirect user sang trang provider không
items[].sortOrdernumberThứ tự ưu tiên hiển thị (số nhỏ ưu tiên cao hơn)
items[].verificationAmountnumberSố tiền verification (nếu có)
items[].currenciesarrayDanh sách currency và giới hạn min/max cho method này
items[].currencies[].currencystringMã tiền tệ (VD: VND, USD)
items[].currencies[].minAmountnumberSố tiền tối thiểu áp dụng cho currency này
items[].currencies[].maxAmountnumberSố tiền tối đa áp dụng cho currency này

Error Responses

HTTP StatusCodeMessageMô tả
4004001Invalid requestThiếu/invalid amount hoặc currency
4014101X-API-Key header is requiredThiếu X-Payment-API-Key
4014100Invalid API keyAPI key không hợp lệ / bị revoke
5005000Internal server errorLỗi hệ thống

Routing qua Mule (Payment Hub)

Quan trọng: API getPaymentMethods được gọi trực tiếp từ Order Backend/Merchant Backend tới Payment Hub thông qua MuleSoft, không được gọi trực tiếp tới Payment Hub.

Internal (PnL)

Kết nối Internal dành cho các PnL trong Vingroup.

Base URL trên Mule (endpoint tới Payment Hub):

  • DEV: {MULE_INTERNAL_BASE_URL}/payment-hub/
  • SIT: {MULE_INTERNAL_BASE_URL}/sit/payment-hub/
  • UAT: {MULE_INTERNAL_BASE_URL}/uat/payment-hub/
  • Production: {MULE_INTERNAL_PROD_URL}/payment-hub/

Lưu ý: Với môi trường Production, các bên kết nối sẽ được team Mule cấp key riêng (client_idclient_secret). Với môi trường DEV/SIT/UAT dùng chung key.

External (Đối tác)

Kết nối External dành cho các đối tác bên ngoài Vingroup. Chỉ hỗ trợ 2 môi trường: ProductionUAT.

Base URL trên Mule (endpoint tới Payment Hub):

  • UAT: https://test-api.vingroup.net:7445/payment-hub/
  • Production: https://api-cloud.vingroup.net/payment-hub/

Yêu cầu kết nối External:

  • Tất cả các request từ đối tác external cần cung cấp danh sách IPs để whitelist
  • Phía Mule sẽ cấp client_idclient_secret riêng cho từng đối tác
  • Có whitelist và limit access theo endpoint

Ví dụ

cURL Example

curl --location 'https://api.example.com/api/payments/v1/payment-methods?amount=100000&currency=VND' \
--header 'accept: */*' \
--header 'X-Payment-API-Key: <YOUR_PAYMENT_API_KEY>'

cURL Example (qua Mule)

curl --location '{MULE_INTERNAL_BASE_URL}/payment-hub/api/payments/v1/payment-methods?amount=100000&currency=VND' \
--header 'accept: */*' \
--header 'X-Payment-API-Key: <YOUR_PAYMENT_API_KEY>' \
--header 'client_id: YOUR_CLIENT_ID' \
--header 'client_secret: YOUR_CLIENT_SECRET'

Liên kết liên quan