条纹 - 定期付款中包含的附加发票项目 [英] Stripe - Additional Invoice Item included on recurring payment

查看:32
本文介绍了条纹 - 定期付款中包含的附加发票项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在订阅中添加发票项目时遇到问题,目前我的头撞在墙上.

I am having a problem adding invoice item on subscription and currently banging my head on the wall.

我在条带上创建了一个发票项目,我希望发票项目包含在定期付款中

I've created an Invoice Item on stripe and I’d like the Invoice Item to be included on the recurring payment

这是我的代码,它在第一张发票上添加了发票项目,但在下一张发票上不添加.

Here’s my code, it adds an invoice item on first invoice but not on the next invoice.

$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));

在我目前的设置上.根据订阅时的客户选择,我有额外的自定义费用,因此我需要为定期付款添加额外费用.

On my current set-up. I have additional custom charges based on customer selection upon subscription thats way I need to add additional charges on recurring payment.

是这样的

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.

希望有人能帮忙.非常感谢

I hope someone could help. Thanks so much

干杯肯

推荐答案

我有一个关于 Stripe 的支持问题,所以会在必要时更新.

I have a support question open with Stripe, so will update as / if necessary.

但是,我刚刚重新阅读了有关计量计费

However, I have just re-read the documentation on 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.

它继续......

要开始,只需使用 webhooks监听 invoice.created 事件.每当发票打开时修改,您的 webhook 端点可以创建一个发票项目引用现有发票的 ID.我们会自动拉这个在向客户收费之前将金额计入发票总额.

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.

因此,我们似乎需要创建一个网络钩子处理程序,以便每个月重新添加这些发票项目.

So, it seems we'll need to create a web hook handler in order to re-add these invoice items each month.

根据发票

创建发票后,系统会自动尝试付款.笔记付款虽然是自动的,但并不完全在当时发生发票创建.如果您已配置 webhook,发票将等到最后一个 webhook 成功发送后一小时(或失败后最后一个 webhook 超时).

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).

这允许我们创建一个网络钩子,以便在尝试付款之前修改发票.

That allows us to create a web hook, in order to modify the invoice, prior to payment being attempted.

我建议的InvoiceCreatedWebhook流程

  1. 监听 invoice.created 事件的主体 - 完整主体 看起来像这样
  2. 从您的数据库中检索您的客户.在此示例中,我们的条带客户 ID 为 cus_00000000000000
  3. 假设您以某种方式记录了客户的额外项目,创建发票项目,并通过设置发票属性将它们应用于发票 - 在本例中为 id in_00000000000000
  1. Listen for the body of the invoice.created event - the full body looks like this
  2. Retrieve your customer from your database. In this example, our stripe customer id is cus_00000000000000
  3. Assuming you have somehow recorded the additional items against your customer, create invoice items, and apply them to the invoice by setting the invoice property - in this example id in_00000000000000

这篇关于条纹 - 定期付款中包含的附加发票项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆