gpt4 book ai didi

stripe-payments - Stripe -定期付款中包含其他发票项目

转载 作者:行者123 更新时间:2023-12-04 03:11:43 27 4
gpt4 key购买 nike

我在订阅中添加发票项目时遇到问题,目前无法正常工作。
我已经在 strip 上创建了一个发票项目,并且希望该发票项目包含在定期付款中
这是我的代码,它在第一个发票上添加了一个发票项目,但在下一个发票上却没有。

$new_customer = Stripe_Customer::create(array(
'card' => $card,
'email' => $email,)
);
Stripe_InvoiceItem::create(array(
'customer' => $new_customer['id'],
'amount' => $additiona_charges,
'currency' => 'gbp',
'description' => 'Addtional Cities'
));
$new_customer->updateSubscription(array('plan' => $selected_plan, 'prorate' => true));
在我当前的设置中。根据订阅时客户的选择,我还有其他自定义费用,因此我需要在定期付款中添加其他费用。
它是这样的
计划
1 Cookie - 99GBP  / Per month
2 Cookies - 199GBP / Per month
3 Cookies - 300GBP / Per month
附加费用-发票项目
-With Candle - +20GBP // must be included on recurring payment.
-With Icecream - +26GBP // must be included on recurring payment.
-With Cheese - +28GBP // must be included on recurring payment.
-With Ketchup - +30 // must be included on recurring payment.
-With Poison (for your X) - +50 // must be included on recurring payment.
我希望有人可以帮忙。非常感谢
干杯
肯恩

最佳答案

我有一个关于Stripe的支持问题,因此如有必要,将更新为/。

但是,我刚刚重新阅读了有关metered billing的文档

The account balance and invoice items are simply one-time adjustments to your customer's account, so they won't be automatically applied each month.
If your service uses metered billing or needs to add custom amounts for taxes or other dynamic costs, then you will need to create invoice items every month.



它继续....

To get started, just use webhooks to listen for the invoice.created event. Whenever an invoice is open for modification, your webhook endpoint can create an invoice item that references the existing invoice's ID. We'll automatically pull this amount into the invoice total before charging your customer.



因此,似乎我们需要创建一个Web Hook 处理程序,以便每月重新添加这些发票项目。

根据 invoices上的文档

Once an invoice is created, payment is automatically attempted. Note that the payment, while automatic, does not happen exactly at the time of invoice creation. If you have configured webhooks, the invoice will wait until one hour after the last webhook is successfully sent (or the last webhook times out after failing).



这样,我们可以在尝试付款之前创建一个Web Hook ,以修改发票。

我建议的 InvoiceCreatedWebhook 流程
  • 监听invoice.created事件的主体-全身looks like this
  • 从数据库中检索您的客户。在此示例中,我们的 strip 客户标识为cus_00000000000000
  • 假设您已经以某种方式记录了与客户相对的其他项目,创建了发票项目,然后通过设置invoice属性将它们应用于发票-在此示例中,id in_00000000000000
  • 关于stripe-payments - Stripe -定期付款中包含其他发票项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22082277/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com