跳转到主要内容
POST /v1/actions/subscription-product/create-product
认证方式: API Key

请求体

字段类型必需说明
storeIdstring门店 ID(STO_xxx 格式)
namestring产品名称
billingPeriodstringweeklymonthlyquarterlyyearly
pricesobject多币种定价(见价格格式
descriptionstring产品描述(支持 Markdown)
mediaarray产品图片/视频(见媒体格式
successUrlstring订阅成功后的重定向 URL
metadataobject自定义键值数据。可包含 trialDays(整数,1-365)以提供免费试用期

请求示例

import { WaffoPancake, BillingPeriod, TaxCategory } from "@waffo/pancake-ts";

const client = new WaffoPancake({
  merchantId: process.env.WAFFO_MERCHANT_ID!,
  privateKey: process.env.WAFFO_PRIVATE_KEY!,
});

const { product } = await client.subscriptionProducts.create({
  storeId: "STO_2D5F8G3H1K4M6N9P",
  name: "Pro Plan",
  billingPeriod: BillingPeriod.Monthly,
  prices: {
    USD: { amount: "29.00", taxIncluded: false, taxCategory: TaxCategory.SaaS },
    EUR: { amount: "27.00", taxIncluded: false, taxCategory: TaxCategory.SaaS },
  },
  description: "Full access to all Pro features.",
  successUrl: "https://example.com/welcome",
  metadata: { trialDays: 14 },
});

成功响应

{
  "data": {
    "id": "PROD_3F7H2J5L8N1Q4S6U",
    "storeId": "STO_2D5F8G3H1K4M6N9P",
    "prodVersionId": null,
    "testVersionId": "PVER_9A2C5E8G1J4L7N0P",
    "prodStatus": "inactive",
    "testStatus": "active",
    "createdAt": "2026-03-30T10:30:00.000Z",
    "updatedAt": "2026-03-30T10:30:00.000Z",
    "version": {
      "id": "PVER_9A2C5E8G1J4L7N0P",
      "productId": "PROD_3F7H2J5L8N1Q4S6U",
      "versionNumber": 1,
      "name": "Pro Plan",
      "billingPeriod": "monthly",
      "description": "Full access to all Pro features.",
      "prices": {
        "USD": { "amount": "29.00", "taxIncluded": false, "taxCategory": "saas" },
        "EUR": { "amount": "27.00", "taxIncluded": false, "taxCategory": "saas" }
      },
      "media": [],
      "successUrl": "https://example.com/welcome",
      "metadata": { "trialDays": 14 },
      "createdAt": "2026-03-30T10:30:00.000Z"
    }
  }
}

错误响应

状态码条件
400缺少必填字段(storeIdnamebillingPeriodprices
400无效的 billingPeriod
400trialDays 不是整数或不在 1-365 范围内
404门店未找到