快速开始

玲珑支付统一 API(v2)采用 REST + JSON,HMAC-SHA256 签名。完成以下四步即可收款:

  1. 登录商户后台 →「商户设置 → 我的支付产品」查看可用的产品编码(下单时填 product_code)
  2. 「API Key」页创建密钥(Secret 仅展示一次,请立即保存到服务器配置)
  3. 调用 POST /api/v2/payment-intents 创建订单,把用户引导到返回的 checkout_url 收银台
  4. 接收 payment.succeeded Webhook(或轮询查单)后发货
已有易支付对接的系统(发卡网、商城插件等)不用写代码,直接看左侧「易支付 V1 兼容」。
API 基地址:https://linglongpay.app · 金额一律为元字符串(最多两位小数),如 "100.00" · 所有时间为 ISO 8601(UTC)

创建支付订单

POST /api/v2/payment-intents
Content-Type: application/json
X-API-Key: llp_test_xxx          # Key ID
X-Timestamp: 1787000000          # Unix 秒,允许 ±300s
X-Nonce: 5f2c...                 # 8-64 位随机串,一次性
X-Signature: <hex>               # 见「签名与鉴权」
Idempotency-Key: order-20260825-001   # 创建类接口必填

{
  "merchant_order_no": "M20260825001",
  "product_code": "你的产品编码",
  "amount": "100.00",
  "subject": "VIP 会员",
  "notify_url": "https://shop.example.com/webhooks/llp",
  "return_url": "https://shop.example.com/return"
}

响应

{
  "payment_intent_id": "cmt7...",
  "system_order_no": "P20260825120000123456",
  "merchant_order_no": "M20260825001",
  "status": "PROCESSING",
  "amount": "100.00",
  "amount_minor": "10000",
  "fee": "5.00",
  "currency": "CNY",
  "payment_target": { "type": "PAY_URL", "value": "https://..." },
  "checkout_url": "https://pay.example.com/pay/cs_xxx",
  "expires_at": "2026-08-25T12:15:00.000Z",
  "created_at": "2026-08-25T12:00:00.000Z"
}

payment_target.type 取值 QR_CONTENT(自行渲染二维码)、PAY_URL(跳转链接)、URL_SCHEME(小程序/App 唤起); 或直接使用 checkout_url 让用户进入玲珑收银台(含二维码、倒计时与状态自动翻转)。

Node.js 完整示例

import { createHash, createHmac, randomUUID } from 'node:crypto';

const API = 'https://linglongpay.app';
const KEY_ID = 'llp_test_xxx';
const SECRET = 'llpsk_xxx';

async function createPayment() {
  const body = JSON.stringify({
    merchant_order_no: 'M' + Date.now(),
    product_code: '你的产品编码', // 商户设置 → 我的支付产品
    amount: '100.00',
    subject: 'VIP 会员',
    notify_url: 'https://shop.example.com/webhooks/llp',
  });
  const path = '/api/v2/payment-intents';
  const timestamp = Math.floor(Date.now() / 1000).toString();
  const nonce = randomUUID();
  const bodyHash = createHash('sha256').update(body).digest('hex');
  const canonical = ['POST', path, '', timestamp, nonce, bodyHash].join('\n');
  const signature = createHmac('sha256', SECRET).update(canonical).digest('hex');

  const res = await fetch(API + path, {
    method: 'POST',
    headers: {
      'content-type': 'application/json',
      'x-api-key': KEY_ID,
      'x-timestamp': timestamp,
      'x-nonce': nonce,
      'x-signature': signature,
      'idempotency-key': randomUUID(),
    },
    body,
  });
  return res.json();
}

查询与退款

接口方法说明
/api/v2/payment-intents/:idGET按 payment_intent_id 或系统订单号查询
/api/v2/payment-intents?merchant_order_no=GET按商户订单号查询
/api/v2/payment-intents/:id/cancelPOST取消未支付订单
/api/v2/refundsPOST创建退款(部分/多次;需 Idempotency-Key)
/api/v2/refunds/:idGET退款查询
/api/v2/accountGET账户余额(总余额/结算中/待到账/可结算)与结算阈值
/api/v2/webhook-endpointsPOST/GETWebhook 端点管理(含 rotate-secret)
安全提示:API Key 的 Secret 只能放在你的服务器上,禁止写进网页或 App;疑似泄露请在「API Key」页立即撤销并新建。