ShipAny Docs

支付

支持的支付渠道

渠道模式Webhook 地址
Stripe一次性 + 订阅POST /api/payment/notify/stripe
PayPal一次性 + 订阅POST /api/payment/notify/paypal
支付宝一次性POST /api/payment/notify/alipay
微信支付一次性 + 订阅POST /api/payment/notify/wechat
Creem一次性 + 订阅POST /api/payment/notify/creem

凭证在 管理后台 → Settings → Payment 中配置(如 stripe_secret_keystripe_publishable_keystripe_signing_secret;alipay_app_id / alipay_private_key / alipay_public_key;wechat_app_id / wechat_mch_id / wechat_api_v3_key 等)。同名环境变量(STRIPE_SECRET_KEY 等)可作兜底。

定价目录

商品定义在 src/config/pricing.ts —— 服务端唯一可信源,客户端传来的价格一律忽略。

src/config/pricing.ts
{
  productId: 'starter_monthly',
  productName: 'Starter',
  description: 'Starter Monthly',
  type: PaymentType.SUBSCRIPTION,   // 或 PaymentType.ONE_TIME
  priceInCents: 900,
  currency: 'usd',
  credits: 5000,
  creditsValidDays: 30,
  plan: { name: 'starter', interval: 'month', intervalCount: 1 },
}

默认商品:starter|pro|enterprise × monthly|yearly|lifetime

支付流程

  1. 客户端调用 POST /api/payment/checkout,传 { product_id, payment_provider, redirect }
  2. 服务端校验商品、创建订单,返回 { checkout_url }
  3. 用户在支付渠道页面完成付款,经 /api/payment/callback?order_no=...&redirect=... 跳回
  4. 渠道的 Webhook(/api/payment/notify/[provider])是可靠的完成路径:将订单标记为 PAID,订阅类商品创建订阅记录,并发放积分

务必在渠道后台配置 Webhook——同步回调只是兜底。