从Braintree Transaction.search()

时间:2018-05-14 06:53:48

标签: javascript node.js braintree

使用Transaction.search()方法搜索交易时是否可以获得Braintree费用金额?我特意用 Braintree Node.js SDK API,所以当我调用方法时:

const gateway = braintree.connect({
    environment: braintree.Environment.Production,
    merchantId : process.env.BRAINTREE_merchantId,
    publicKey  : process.env.BRAINTREE_publicKey,
    privateKey : process.env.BRAINTREE_privateKey,
});

// start and end are well formatted dates, irrelevant here
const stream = gateway.transaction.search((search) => {
    search.createdAt().between(start, end)
});

let result = [];

stream.on("data", (transaction) => {
    result.push(transaction);
});
stream.on("end", () => {

    console.log(result[0]);

});
stream.on("error", reject);
stream.resume();

我的console.log(result[0])显示了相当大的(160行代码)单transaction个对象,其中transaction.serviceFeeAmount: null

console.log({
  "id": "1egncjr5",
  "status": "settled",
  "type": "sale",
  "currencyIsoCode": "EUR",
  "amount": "799.00",
  "merchantAccountId": "mycompanyEUR",
  "subMerchantAccountId": null,
  "masterMerchantAccountId": null,
  "orderId": "54144",
  "createdAt": "2018-03-07T08:55:09Z",
  "updatedAt": "2018-03-07T19:41:10Z",
  "customer": {
    "id": null,
    "firstName": null,
    "lastName": null,
    "company": "Kunlabora NV",
    "email": "client@email.com",
    "website": null,
    "phone": null,
    "fax": null
  },
  "billing": {
    "id": null,
    "firstName": null,
    "lastName": null,
    "company": "Kunlabora NV",
    "streetAddress": "Veldkant 33 A",
    "extendedAddress": null,
    "locality": "Kontich",
    "region": null,
    "postalCode": "2550",
    "countryName": "Belgium",
    "countryCodeAlpha2": "BE",
    "countryCodeAlpha3": "BEL",
    "countryCodeNumeric": "056"
  },
  "refundId": null,
  "refundIds": [],
  "refundedTransactionId": null,
  "partialSettlementTransactionIds": [],
  "authorizedTransactionId": null,
  "settlementBatchId": "2018-03-08_mycompanyEUR_ecwhvhcf",
  "shipping": {
    "id": null,
    "firstName": null,
    "lastName": null,
    "company": null,
    "streetAddress": null,
    "extendedAddress": null,
    "locality": null,
    "region": null,
    "postalCode": null,
    "countryName": null,
    "countryCodeAlpha2": null,
    "countryCodeAlpha3": null,
    "countryCodeNumeric": null
  },
  "customFields": "",
  "avsErrorResponseCode": null,
  "avsPostalCodeResponseCode": "U",
  "avsStreetAddressResponseCode": "U",
  "cvvResponseCode": "M",
  "gatewayRejectionReason": null,
  "processorAuthorizationCode": "735709",
  "processorResponseCode": "1000",
  "processorResponseText": "Approved",
  "additionalProcessorResponse": null,
  "voiceReferralNumber": "",
  "purchaseOrderNumber": null,
  "taxAmount": "0.00",
  "taxExempt": false,
  "creditCard": {
    "token": null,
    "bin": "CENSORED",
    "last4": "CENSODER",
    "cardType": "MasterCard",
    "expirationMonth": "CENSORED",
    "expirationYear": "CENSORED",
    "customerLocation": "CENSORED",
    "cardholderName": "",
    "imageUrl": "https://assets.braintreegateway.com/payment_method_logo/mastercard.png?environment=production",
    "prepaid": "No",
    "healthcare": "No",
    "debit": "No",
    "durbinRegulated": "No",
    "commercial": "No",
    "payroll": "No",
    "issuingBank": "BNP PARIBAS FORTIS",
    "countryOfIssuance": "BEL",
    "productId": "MCB",
    "uniqueNumberIdentifier": null,
    "venmoSdk": false,
    "maskedNumber": "CENSORED",
    "expirationDate": "04/2020"
  },
  "statusHistory": [
    {
      "timestamp": "2018-03-07T08:55:10Z",
      "status": "authorized",
      "amount": "799.00",
      "user": "office@mycompany.com",
      "transactionSource": "api"
    },
    {
      "timestamp": "2018-03-07T08:55:10Z",
      "status": "submitted_for_settlement",
      "amount": "799.00",
      "user": "office@mycompany.com",
      "transactionSource": "api"
    },
    {
      "timestamp": "2018-03-07T19:41:10Z",
      "status": "settled",
      "amount": "799.00",
      "user": null,
      "transactionSource": ""
    }
  ],
  "planId": null,
  "subscriptionId": null,
  "subscription": {
    "billingPeriodEndDate": null,
    "billingPeriodStartDate": null
  },
  "addOns": [],
  "discounts": [],
  "descriptor": {
    "name": null,
    "phone": null,
    "url": null
  },
  "recurring": false,
  "channel": "woocommerce_bt",
  "serviceFeeAmount": null,
  "escrowStatus": null,
  "disbursementDetails": {
    "disbursementDate": null,
    "settlementAmount": null,
    "settlementCurrencyIsoCode": null,
    "settlementCurrencyExchangeRate": null,
    "fundsHeld": null,
    "success": null
  },
  "disputes": [],
  "authorizationAdjustments": [],
  "paymentInstrumentType": "credit_card",
  "processorSettlementResponseCode": "",
  "processorSettlementResponseText": "",
  "threeDSecureInfo": null,
  "shipsFromPostalCode": null,
  "shippingAmount": null,
  "discountAmount": null,
  "paypalAccount": {},
  "coinbaseAccount": {},
  "applePayCard": {},
  "androidPayCard": {},
  "visaCheckoutCard": {},
  "masterpassCard": {}
})

问题:我如何在此处获得交易费用?

2 个答案:

答案 0 :(得分:0)

您可以在transactionFeeAmount字段中找到它

答案 1 :(得分:0)

这是我从Braintree支持团队收到的答案:

<小时/> 很遗憾没有目前无法使用API​​ 搜索Braintree费用金额(意为14/05/2018 )。

您可以通过执行高级交易搜索来计算单笔交易的费用。

  1. 登录Control Panel
  2. 在“高级搜索”下,单击“交易”
  3. 取消选中“创建日期范围”
  4. 旁边的复选框
  5. 选中已支付日期范围
  6. 旁边的复选框
  7. 选择所需的日期范围
  8. 点击搜索
  9. 在结果页面上,单击“下载”
  10. 在您选择的电子表格程序中打开CSV文件
  11. 从这里,您可以为交易费用创建其他列。要查找特定的交易费用,请查看您的对帐单上的定价时间表。确保向下舍入,然后将费用应用于您的个人交易。

    所以看起来我要实现一些PhantomJS模块才能做到这一点。