【问题标题】:Retrieving line items from Braintree Transactions从 Braintree 交易中检索行项目
【发布时间】:2018-02-04 12:40:10
【问题描述】:

Braintree Transaction API has a field for lineItems,但是我该如何使用它呢? Transaction response 不返回订单项,控制面板中也没有用于交易的订单项。

看起来订单项实际上并未存储在任何地方。我对吗?如果是这样,它们的意义何在?

我想向客户展示交易的明细收据(这是一个非常明显的用例,对吧?)。有没有办法让 Braintree 在交易中生成这个?

我使用的是 Braintree Node.js SDK 2.5 版。

【问题讨论】:

    标签: node.js transactions braintree


    【解决方案1】:

    我不确定一个月前你问这个问题时是否是这种情况,但似乎交易响应确实返回了订单项:

    https://developers.braintreepayments.com/reference/response/transaction/node#line_items

    【讨论】:

      【解决方案2】:

      更新答案

      As of version 2.6.0 of the Braintree Node SDK, lineItemsTransaction 响应对象的一个​​属性。请参阅 Braintree 的相关文档 here

      原始答案

      您可以使用gateway.transactionLineItem.findAll(someTransactionId, function(err, response) {}) 检索与交易关联的行项目。这是documented in the tests of the SDK

      specHelper.defaultGateway.transactionLineItem.findAll(response.transaction.id, function (err, response) {
          assert.equal(response.length, 1);
          let lineItem = response[0];
      
          assert.equal(lineItem.quantity, '1.0232');
          assert.equal(lineItem.name, 'Name #1');
          assert.equal(lineItem.kind, 'debit');
          assert.equal(lineItem.unitAmount, '45.1232');
          assert.equal(lineItem.totalAmount, '45.15');
          done();
      });
      

      我们正在更新我们的developer docsControl Panel 以反映这种行为。

      【讨论】:

      • 在交易中声明您的订单项的对象是什么样的?
      • @Tank12 基于dev docs lineItems 是一个可以包含在transaction.sale() 中的对象数组。
      • @Shea 我不得不说,Braintree 的文档确实有一些不足之处。至少在撰写本文时,没有关于如何使用 lineItems 或任何东西的示例。不必查看 SDK 中的测试来弄清楚这一点。我并不是要成为一个混蛋,但这让我们的团队感到沮丧。
      猜你喜欢
      • 1970-01-01
      • 2018-09-21
      • 1970-01-01
      • 1970-01-01
      • 2016-03-09
      • 1970-01-01
      • 2021-12-02
      • 1970-01-01
      • 2018-11-22
      相关资源
      最近更新 更多