【发布时间】: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