- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Stripe 支付网关,到目前为止一切正常,除了我的用户可以在我的网站上下载他们的发票的选项。可以在 Stripe 仪表板内下载发票,但这不是我需要的。我的用户付款后,他们应该能够将发票下载到我的系统。
目前我正在使用 stripe webhooks。用户付款,数据保存在我的数据库中。这是我的代码的样子:
\Stripe\Stripe::setApiKey("$stripe_secret_key_test");
// Retrieve the request's body and parse it as JSON:
$input = @file_get_contents('php://input');
$event_json = json_decode($input);
// Update database with new billing entry
if ($event_json->type == 'invoice.payment_succeeded') {
$invoice_id = $event_json->data->object->id;
$customer = $event_json->data->object->customer;
$date = $event_json->data->object->date;
$price = $event_json->data->object->amount_paid;
$user = $event_json->data->object->lines->data[0]->metadata->userid;
$stripe_sub_id = $event_json->data->object->lines->data[0]->id;
$plan_id = $event_json->data->object->lines->data[0]->plan->id;
$stamp_created = $event_json->data->object->lines->data[0]->plan->created;
$comments = $event_json->data->object->lines->data[0]->plan->nickname;
$period_start = $event_json->data->object->lines->data[0]->period->start;
$period_end = $event_json->data->object->lines->data[0]->period->end;
$content=array("invoice"=>$invoice_id,
"user"=>$user,
"stripe_cust_id"=>$customer,
"stripe_sub_id"=>$stripe_sub_id,
"idea_id"=>0,
"billing_date"=>$date,
"plan"=>$plan_id,
"price"=>$price,
"stamp_created"=>$stamp_created,
"period_start"=>$period_start,
"period_end"=>$period_end,
"status"=>'paid',
"printed"=>0);
insertGWInfo('billing',$content);
$content=array("user"=>$user,
"trans_time"=>date("Y-m-d H:i:s"),
"ip"=>$_SERVER['REMOTE_ADDR'],
"trans_type"=>1,
"cash_amount"=>$price,
"comments"=>"Subscription for ".$comments."",
"idea_id"=>0);
insertGWInfo('user_accounting',$content);
}
现在我创建了一个表,我从数据库中提取这些条目并将它们显示给我的客户。我现在想要一个带有“下载发票”的按钮,我的客户可以在其中下载每月出现的订阅发票。
知道我该怎么做吗?我有 invoice_id,但我从哪里获得下载发票的 URL?我无法在 stripe 文档中找到任何内容。非常感谢任何帮助。
编辑:以下是 invoice.payment_suceeded 的 JSON 结果:
"{
"created": 1326853478,
"livemode": false,
"id": "evt_00000000000000",
"type": "invoice.payment_succeeded",
"object": "event",
"request": null,
"pending_webhooks": 1,
"api_version": "2018-02-28",
"data": {
"object": {
"id": "in_00000000000000",
"object": "invoice",
"amount_due": 1000,
"amount_paid": 1000,
"amount_remaining": 0,
"application_fee": null,
"attempt_count": 1,
"attempted": true,
"billing": "charge_automatically",
"charge": "_00000000000000",
"closed": true,
"currency": "eur",
"customer": "cus_00000000000000",
"date": 1526455801,
"description": null,
"discount": null,
"due_date": null,
"ending_balance": 0,
"forgiven": false,
"lines": {
"data": [
{
"id": "sub_Cs4DUPJKcAJ7cg",
"object": "line_item",
"amount": 1000,
"currency": "eur",
"description": "1 standard-inv × Standard Investor (at €10.00 / month)",
"discountable": true,
"livemode": false,
"metadata": {
},
"period": {
"end": 1531726201,
"start": 1529134201
},
"plan": {
"id": "3",
"object": "plan",
"aggregate_usage": null,
"amount": 1000,
"billing_scheme": "per_unit",
"created": 1526375755,
"currency": "eur",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"nickname": "Standard Plan for Investors",
"product": "prod_CrihTVfgRHgImD",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"proration": false,
"quantity": 1,
"subscription": null,
"subscription_item": "si_Cs4DrvYN2FlCbS",
"type": "subscription"
}
],
"has_more": false,
"object": "list",
"url": "/v1/invoices/in_1CSK5FDsOByhb3e8m8Z1BooY/lines"
},
"livemode": false,
"metadata": {
},
"next_payment_attempt": null,
"number": "774C629-0001",
"paid": true,
"period_end": 1526455801,
"period_start": 1526455801,
"receipt_number": null,
"starting_balance": 0,
"statement_descriptor": null,
"subscription": "sub_00000000000000",
"subtotal": 1000,
"tax": null,
"tax_percent": null,
"total": 1000,
"webhooks_delivered_at": 1526455810
}
}
}"
最佳答案
Stripe 现在确实支持这个。通过 API 列出发票并访问发票的 invoice_pdf
属性可获得 PDF 链接。
以下是获取一系列发票及其 PDF 链接的方法:
const invoicesResponse = await stripe.invoices.list({ customer: customerStripeId });
const invoices = invoicesResponse.map(invoice => ({
invoiceId: invoice['id'],
pdf: invoice['invoice_pdf'],
}));
return invoices;
这是 API 文档: https://stripe.com/docs/api/invoices/object#invoice_object-invoice_pdf感谢@avelis 的建议。
关于php - Stripe,用户无法下载他们的发票,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50366702/
我正在构建发票系统。我的客户想在不登录 PayPal 帐户的情况下发送 PayPal 发票。 我设法使 CreateInvoice() 和 CreateAndSendInvoice() 函数正常工作(
有人知道用 C# 或 VB.NET 编写的用于在小型打印机中打印票据的类吗?打印机:EPSON TM-U220PD 感谢您的帮助。 最佳答案 如果您的发票是可以包含在 Stream 中的内容(例如文件
我的客户有一个基于 ubercart 的商店,运行良好。由于一些内部问题,他需要为每张发票手动添加一个字段。我想知道是否或者更确切地说如何向显示在所有发票上的订单添加自定义字段。 最佳答案 这是一个老
我正在为特许经营的 CRM 设计关系数据库的第二次主要迭代(进行了大量重构),我需要有关用于存储的最佳数据库设计实践的帮助 工作发票和 发票行用强审计跟踪 对每张发票所做的任何更改。 当前模式 Inv
我在让这段代码正常工作时遇到了一些麻烦。我们的员工可以访问我们网站上的后端系统。这是输入字段等的设置方式: query("SELECT faktura_materialer.id as materia
我想在我的 iOS 应用程序中创建一个 PDF 发票(在 Objective-C 或 Swift 中)。 我的主要问题是发票可能有几页,这很难通过 Apple 的现有 API(CoreGraphics
我正在设计一个具有以下场景的电子商务网站: 客户可以购买商品并创建订单。 订单可能有未知费用,将在客户之后添加支付项目的总金额。也就是说,客户支付一定数量的第一。该订单增加了一些费用并改变了总额。客户
令人惊讶的是,在 successfull checkout session 之后无法自动生成发票与 Stripe 。在 Stripe 系统中,发票必须始终先于付款。 我不得不通过一堆获取 Paymen
我目前正在做一个小项目,我需要对以下场景进行建模: 场景 客户打来电话,他想要一辆新车的报价。 销售代表。注册客户信息。 销售代表。在系统中创建报价,并将项目添加到报价(汽车)。 销售代表。通过电子邮
为了在用户选择“立即购买”时节省交易成本,系统会在新选项卡中打开 HTML 发票,其中包含他们的订单和我们的银行详细信息,供他们进行手动电子转帐。有什么我应该注意的安全问题吗?黑客可以将自己的银行详细
我有一个下表: Invoice| Colour | Type In_001 | Red | D In_001 | Red | D In_001 | Yellow | E In_002
我正在尝试将包含发票和表格的图像旋转到正确的方向。我试图找到角度,然后旋转图像。只有少数图像被正确旋转。下面是我试图以正确方向旋转的代码和图像,第一个图像旋转正确,其他图像旋转不正确 import n
基本要求是以以下格式创建订单号: (M)M-SSS 其中 MM 代表当前月份,SSSS 代表当月的订单顺序。例如,1-002 代表一月份提交的第二个订单。 使用 TRIGGER 我希望自动递增和插入透
使用 PayPal API,我想在买家在网络应用程序中完成购买后立即通过电子邮件发送一张标记为已付款的发票。 这可能吗? 如果不使用 API,您将无法为已付 发票手动发送电子邮件通知。是吗? 最佳答案
如果我需要在系统之间发送和接收业务文档(发票、采购订单、汇款通知书等),您会推荐什么标准以获得最佳互操作性?为什么?它可以是 XML 或其他形式。 最佳答案 UBL (通用商业语言)是这方面的最新尝试
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找书籍、工具、软件库、教程或其他场外资源的问题对于 Stack Overflow 来说是
我正在尝试创建手动 strip 发票,但不希望它从待处理的发票项目创建发票。例如,我有 3 个待处理的发票项目,我不想包含在这张手动发票中。 待定订单项: 第 1 项 第 2 项 新发票: 第 3 项
我正在从我的 API 取回发票,并且我注意到如果有 2 个整月的计费周期,一切都很好 - 但我总是得到一个开始/结束日期和创建日期相同的发票。 所以,我最终显示它并且它没有意义......即。 假设用
是否有任何方法 (API) 可以从未在 Azure 中运行的应用程序访问我的 Azure 发票信息? 我想获取此信息并每月自动将其添加到我的 ERP 中。 谢谢再见 最佳答案 正如 Andrew 所提
我想将一些发票导出到 Microsoft Excel/XML。标准格式效果不太好,因为我需要一些额外的列。 我的问题是:文件在哪里生成的?我在哪里设置这些特殊列? 提前致谢 最佳答案 当Invoice
我是一名优秀的程序员,十分优秀!