概述
礼品卡是一种数字化支付工具,支持商户:- 创建带有品牌元素和自定义封面的礼品卡
- 按指定金额和币种发卡
- 跟踪卡片状态及兑换情况
- 查询剩余余额
API 参考
创建礼品卡
接口:POST /v1/pay/giftcard/create
使用指定参数创建新的礼品卡。成功后会返回礼品卡号、密钥和初始状态。
请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
title | string | Yes | Gift card title or name |
templateId | string | Yes | Cover template ID for the gift card design |
currency | string | Yes | Gift card currency (e.g., USD, EUR) |
amount | string | Yes | Gift card initial amount |
响应 字段
| 字段 | 类型 | 说明 |
|---|---|---|
cardNumber | string | Unique gift card number for customer identification |
key | string | Gift card key for activation and redemption |
status | string | Initial gift card status (see status enumeration below) |
Example 请求
Example 响应
Query 礼品卡 Cover Templates
接口:GET /v1/pay/giftcard/template/list
Retrieves available cover templates for gift card customization.
响应 字段
| 字段 | 类型 | 说明 |
|---|---|---|
templateId | string | Unique template identifier |
templateName | string | Display name of the template |
coverUrl | string | URL to the template cover image |
status | string | Template availability status |
Query Balance
接口:GET /v1/pay/balance/query
Retrieves the current balance of a gift card.
Query 参数
Query by eithercardNumber or key (mutually exclusive—provide only one).
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
cardNumber | string | Conditional | Gift card number |
key | string | Conditional | Gift card key |
Query 礼品卡 Details
接口:GET /v1/pay/giftcard/query
Retrieves complete gift card information including status and 交易 history.
Query 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
cardNumber | string | Conditional | Gift card number for lookup |
key | string | Conditional | Gift card key for lookup |
礼品卡 状态 Enumeration
| 状态 | 说明 |
|---|---|
CREATED | Gift card has been created and is ready for distribution |
REDEEMED | Gift card balance has been fully redeemed |
EXPIRED | Gift card has reached its expiration date |
CANCELLED | Gift card has been cancelled and is no longer valid |
回调 Behavior
Gift cards do not provide 异步 回调s. 状态 changes and balance updates must be retrieved through the query APIs (GET /v1/pay/giftcard/query or GET /v1/pay/balance/query).
For information on 回调 handling for other products, see 通知 & 回调.
Error 处理方式
| 错误码 | 说明 | 适用 API | Resolution |
|---|---|---|---|
400001 | Invalid request parameters | All gift card APIs | Verify all required fields are present and correctly formatted |
400007 | Unsupported Content-类型 | All gift card APIs | Ensure Content-Type: application/json is set in 请求头 |
Integration Guide
Basic Flow
- Retrieve available templates using
GET /v1/pay/giftcard/template/list - Create a gift card using
POST /v1/pay/giftcard/createwith your chosen template - Store the card details (cardNumber and key) securely
- Distribute the gift card to your customer
- Query status periodically using
GET /v1/pay/giftcard/queryorGET /v1/pay/balance/query
最佳实践
- Store both
cardNumberandkeyin your system for redundant lookups - Query status before displaying balance to customers
- Implement expiration date handling in your 应用
- Use template IDs that align with your brand guidelines

