Quickbooks PHP API 在提交订单时生成发票

Quickbooks PHP API Generating Invoices On Order Submission

我有一个客户想通过在线表格接受订单,其想法是可以通过我的应用程序提交订单并将其存储在数据库中,同时在 QuickBooks 中提交时生成发票。

当输入订单的人不是客户而是客户的客户时,如何在 PHP 中执行此操作? Quickbooks 似乎使用 Oauth 令牌和 javascript 库来生成它们以将公司连接到应用程序,但我只是在为一家公司编写后端,并希望该后端在保存订单时创建发票。我怎么看这个?

我对任何必须点击显示 "connect to quickbooks" 按钮的人不感兴趣,尤其是填写订单的人,因为同样,那个人是客户,不需要了解客户的发票系统。

我真的很想使用会计 API 生成发票。有没有办法直接在 Quickbooks SDK 配置中直接 link 我的后端到我的一个公司并实现这一点,或者他们是否需要使用 javascript 库来获取令牌。我不清楚我应该朝哪个方向前进,如果我不需要它来执行后端逻辑,我不想在客户端库上浪费时间。

这里有一些示例代码可以完全满足您的需求:

连同快速入门指南:

另请参阅下面关于您的评论的注释——您走在正确的轨道上,您只是误解了 OAuth 的工作方式:

It seems like Quickbooks uses Oauth tokens and a javascript library to generate them to connect a company to an app, but I'm simply writing a backend for one company and want that backend to create invoices when saving an order.

正确,Intuit 使用 OAuth 和一些 Javascript 东西来启动 OAuth 流程。

I'm not interested in anyone having to hit a button that says "connect to quickbooks"

有人需要按下此按钮...但只有一个人需要按下按钮一次,永远,然后再也不会。

公司的所有者(例如您的老板)需要单击按钮一次,这会将 OAuth 信用(和领域 ID)提供给您。一旦你的老板完成了一次,那么你就拥有了对所有实际客户永远使用的信誉。

您的客户(例如实际检查 out/placing 订单的人)不要点击任何按钮,他们也不会看到或根本不知道您在使用 QuickBooks。

just really want to use the Accounting API to generate invoices.

太棒了,你完全可以做到!

Is there no way to simply link my backend to my one company directly in > the Quickbooks SDK configuration and achieve this, or do they need to use a javascript library to get tokens.

按照上面的快速入门。您应该需要大约 15 分钟才能建立有效的 OAuth 连接,然后您就再也不需要使用客户端的东西了。

You only need to authenticate every 180 days btw.

如果您使用重新连接脚本,您只需验证一次,并且可以每 180 天自动更新令牌,无需用户交互。

Well with the realm_id for example, I don't understand how that relates to ouath.

领域 ID 只是您尝试连接的特定 QuickBooks Online 公司的唯一标识符。是的,你需要存储它。如果您使用我们的库,这会自动为您完成。

I guess I don't understand if I'm developing for one client why can't I just get their realm_id from them and then keep using it rather than making them do some form of authentication?

同样,他们只需验证一次。这是 Intuit 为您提供连接所需的领域 ID 和凭据的方式。一旦你完成了一次,你就永远不需要再做一次。整个过程大约需要 30 秒。

如果他们在没有任何身份验证的情况下只给你 OAuth 证书,那将是一个巨大的安全漏洞。如果您阅读有关 OAuth 的维基百科文章,它会深入讨论这一点以及 OAuth 的目标。

Okay I think I get it, so they have to authenticate once every 180 days?

每 180 天一次,除非您使用重新连接脚本,在这种情况下,他们只需验证一次,然后就再也不用担心了。

So I can store the token and the realm_id in a database before it expires and just use that?

是的。

In this way my client can authenticate and then my scripts can generate invoices for them when their customers visit our website?

是的!