【问题标题】:stripe subscription pay now and the first of each month条带订阅现在和每月的第一天付款
【发布时间】:2021-05-10 02:31:30
【问题描述】:

我正在尝试通过 Stripe API 创建订阅。我已经创建了产品和项目,现在需要为用户提交订阅,但我现在需要向客户收取全价 - 无论是在每月的哪一天 - 然后在每个月初收费 -即使明天开始。

看起来我现在可以创建一个一次性的项目来收费,然后为每月的计费周期设置订阅,但我想知道我是否可以使用订阅 => 创建功能在一个电话中完成所有操作.我不想按比例分配第一个月,而且我看不到一种方法来告诉它现在收取全价并在接下来的每个月的第一天设置重复。有没有办法做到这一点?

【问题讨论】:

    标签: stripe-payments


    【解决方案1】:

    处理您所描述的流程的一种方法是结合backdate_start_datebilling_cycle_anchor 属性。这个想法是,在创建订阅时,您会将billing_cycle_anchor 设置为下个月的第一天,并将backdate_start_date 设置为当月的第一天。例如,假设您想为用户注册从今天(2 月 5 日)开始的 10.00 美元订阅,但您想立即向他们收取 10.00 美元的全部费用(即使他们错过了前 5 天)。然后,您想在 3 月 1 日和之后每个月的第一天再次向他们收取 10.00 美元的账单。创建订阅时,您将设置:

    • billing_cycle_anchor: 1614556800(3月1日)
    • backdate_start_date: 1612137600(2月1日)

    这将导致今天开出 10.00 美元的发票,并在 3 月 1 日再次开出 10.00 美元的发票,之后每个月的第一天都会开出 10.00 美元的发票。

    这是 Node 中的样子:

    (async () => {
      const product = await stripe.products.create({ name: "t-shirt" });
    
      const customer = await stripe.customers.create({
        name: "Jenny Rosen",
        email: "jenny.rosen@gmail.com",
        payment_method: "pm_card_visa",
        invoice_settings: {
          default_payment_method: "pm_card_visa",
        },
      });
    
      const subscription = await stripe.subscriptions.create({
        customer: customer.id,
        items: [
          {
            quantity: 1,
            price_data: {
              unit_amount: 1000,
              currency: "usd",
              recurring: {
                interval: "month",
              },
              product: product.id,
            },
          },
        ],
        backdate_start_date: 1612137600,
        billing_cycle_anchor: 1614556800,
        expand: ["latest_invoice"],
      });
    
      console.log(subscription);
    })();
    

    【讨论】:

    • 我实际上也只是想通了这一点,但您已经发布了我看到的答案。哈哈,是的,backdate_start_date 正是我所需要的。
    猜你喜欢
    • 2018-10-02
    • 2016-10-06
    • 2013-01-13
    • 2017-05-12
    • 2020-01-16
    • 2022-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多