【问题标题】:How to setup charges to be recurring?如何设置重复收费?
【发布时间】:2021-05-02 03:35:23
【问题描述】:

我正在 WooCommerce Stripe 插件已经提供的功能之上构建一个新功能,以使客户能够更改他们现有的正在进行的订阅,这基本上取消了他们当前的订阅并设置一个新的订阅,以便在他们之前的订阅结束时开始.我通过 Stripe API 执行此操作,然后在 WooCommerce 中进行相应更新,效果很好。

我似乎遗漏了一部分,以确保重复收费。有谁知道 WooCommerce 订阅如何设置未来使用 Stripe 付款的重复收费?

我通过以下方式发起收费:

    $charge = $stripe->charges->create([
        'amount' => intval( $newOrder->get_total() * 100 ),
        'currency' => 'gbp',
        'source' => $card,
        'description' => 'Subscription Update ' . $user->user_email,
        'metadata' => [
            'Order ID' => $newOrder->get_id(),
            'payment_type' => 'recurring',
        ...

我注意到他们将“payment_type”的元数据字段设置为循环,所以我添加了。

我确实找到了这篇关于设置卡以供将来付款的文章,但我不确定这是我需要的还是我必须以不同的方式来做?

https://stripe.com/docs/payments/save-and-reuse

我应该使用 PaymentIntent 而不是 Charge?

https://stripe.com/docs/api/payment_intents/create

谢谢

【问题讨论】:

    标签: woocommerce stripe-payments subscription


    【解决方案1】:

    可以在此处找到设置订阅(即经常性费用)的过程 [1]。提供的代码仅创建一次性费用。元数据是一种通过 API [2] 在对象上传递临时数据的方法,因此在这种情况下不相关。 PaymentIntents 是进行结算集成的方式,因为它们已准备好 SCA [3]。

    [1]https://stripe.com/docs/billing/subscriptions/fixed-price

    [2]https://stripe.com/docs/api/metadata

    [3]https://stripe.com/docs/strong-customer-authentication

    【讨论】:

    • 我不确定,因为 WooCommerce 订阅插件只是在 Stripe 中创建定期付款,实际上并没有使用订阅 API。如果我理解正确的话,id需要先用stripe.com/docs/api/setup_intents再用stripe.com/docs/api/payment_intents/create
    • WooCommerce 很可能有自己的内部计费引擎,并根据自己的时间表创建一次性费用。如果我的理解是正确的,并且您想直接针对 Stripe API 管理订阅,那么在这种情况下答案是否定的。创建订阅时,会在后台自动创建 PaymentIntent 或 SetupIntent 以支持处理与发票关联的费用,系统需要利用这些现有对象:stripe.com/docs/billing/subscriptions/…
    猜你喜欢
    • 2018-05-18
    • 1970-01-01
    • 2019-01-26
    • 2011-08-01
    • 2021-09-17
    • 2018-10-20
    • 2012-08-03
    • 2019-11-06
    • 2022-01-26
    相关资源
    最近更新 更多