简体   繁体   English

使用php创建发票后如何获取条带发票链接

[英]how to get stripe invoice link after create an invoice using php

I have created an invoice id using stripe invoice create:我使用条带发票创建创建了发票 ID:

$invoice = \Stripe\Invoice::create([
   "customer" => "customer_id",
   ]);

But want to get the invoice id which start with invst_ So how can i get this?但是想要获得以invst_开头的发票 ID 那么我怎样才能得到这个呢?

So i will access invoice with like this link所以我将使用这个链接访问发票

https://pay.stripe.com/invoice/invst_

I got my own answer.我得到了自己的答案。 Get invoice details with these:通过以下方式获取发票详细信息:

$invoiceId = $subscription->latest_invoice;
$invoice = \Stripe\Invoice::retrieve($invoiceId);
$invoice_hosted_url = $invoice->hosted_invoice_url;
$invoice_pdf = $invoice->invoice_pdf;

invoice_hosted_url is the main invoice link with invst_ and full link of invoice. invoice_hosted_url是带有invst_的主发票链接和发票的完整链接。

You need to finalize the invoice first.您需要先完成发票。

I'm not sure what language you are using.我不确定您使用的是什么语言。 It looks like PHP code, taken directly from the Stripe API docs, finalizing should look something like this:它看起来像 PHP 代码,直接取自 Stripe API 文档,最终确定应该是这样的:


$stripe = new \Stripe\StripeClient(
  'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);

$stripe->invoices->finalizeInvoice(
  'in_1BjOrj2eZvKYlo2CTTfU9xqe',
  []
);

Then the returned object should have a hosted_invoice_url property with the url you are looking for.然后返回的对象应该有一个带有您要查找的 url 的hosted_invoice_url属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM