【问题标题】:How to make subscription session with prefilled removable promotion code or discount如何使用预填充的可移动促销代码或折扣进行订阅会话
【发布时间】:2023-02-07 18:16:24
【问题描述】:

我已经成功地创建了一个包含这样的促销代码的结帐页面

  const sessionParams: Stripe.Checkout.SessionCreateParams = {
    customer_email: user.email,
    mode: 'subscription',
    line_items: [
      {
        price: process.env.STRIPE_PRICE_CODE,
        quantity: 1,
      },
    ],
    metadata: {
      userId: user.userId,
    },
    // {CHECKOUT_SESSION_ID} is a string literal; do not change it!
    // the actual Session ID is returned in the query parameter when your customer
    // is redirected to the success page.
    success_url: `${origin}/account/download-app?session_id={CHECKOUT_SESSION_ID}`,
    cancel_url: `${origin}/account/plan-preview`,
  };

  if (req.query.coupon === 'special-access') {
    sessionParams.allow_promotion_codes = true;
  } else {
    sessionParams.discounts = [{ promotion_code: '***' }];
  }

  const session = await stripe.checkout.sessions.create(sessionParams);


但我注意到用户无法删除促销代码并添加他的自定义代码。

我看到其他公司在结帐时发现他们确实已经预先填充了带有 X 的促销代码以将其删除并添加他们自己的

我试过将折扣对象与 allow_promotion_codes: true 一起使用,但 API 似乎不允许这样做。

【问题讨论】:

    标签: stripe-payments


    【解决方案1】:

    结帐确实不是目前支持预填充客户可以在付款页面上删除的促销代码。同样,您不能同时通过allow_promotions_codeparameter和通过discountshash预填促销代码。 API 会出错(如您所见)。为了让您的客户能够移除促销代码,您将只需要使用 allow_promotion_codes 布尔值。

    支付链接支持通过URL parameter(例如https://buy.stripe.com/foo?prefilled_promo_code=bar)预填充促销代码,这可能是您所引用的。

    【讨论】:

      猜你喜欢
      • 2017-07-23
      • 2016-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-24
      • 1970-01-01
      • 1970-01-01
      • 2020-02-09
      相关资源
      最近更新 更多