条纹创建费用的发票/发票

时间:2018-05-26 18:53:42

标签: php stripe-payments

我正在使用一次性付款,我正在尝试为收费生成发票,我可以列出所有费用,但在那里我没有看到生成收费发票的方法。

以下是我如何收取费用。

\Stripe\InvoiceItem::create(array(
                    "customer" => $customer_id,
                    "amount" => $price,
                    "currency" => "aud",
                    "description" => $courseTitle)
            );// creating invoice items here


$charges = \Stripe\InvoiceItem::all(array("customer" => $customer_id));

1 个答案:

答案 0 :(得分:0)

以这种方式使用Invoices有点不寻常,在大多数情况下,它们与Stripe的订阅一起使用。如果你想为一系列物品收取一次性费用,你只需要为总金额收取一笔费用,然后将你身边/逻辑中的物品加起来。

https://3v4l.org/0VlN0

\Stripe\Charge::create(array(
  "amount" => 2000,
  "currency" => "usd",
  "customer" => "cus_xxxyyyzz", // charge my existing customer
  "description" => "Charge items"
));

如果您打算使用发票,则需要创建客户,添加发票项目,然后创建发票。

https://stripe.com/docs/api/php#create_charge

// create customer
$customer = \Stripe\Customer::create(array(
  "description" => "Jamie Smith",
  "source" => "tok_mastercard" // normally obtained with Stripe.js
));

// create invoice items
\Stripe\InvoiceItem::create(array(
    "customer" => $customer->id,
    "amount" => 2500,
    "currency" => "usd",
    "description" => "One-time fee")
);

// pulls in invoice items
\Stripe\Invoice::create(array(
    "customer" => $customer->id
));