1

我正在尝试使用以下示例使用 Node.js 进行帐户信用请求。但即使我使用示例代码而没有任何更改,它也会失败。 https://docs.balancedpayments.com/current/overview.html?language=node#charge-a-credit-card

balanced.Accounts.get("/v1/marketplaces/TEST-MP60c88vnFHzgzEyzGcbMKic/accounts/AC1a77avbmVTUt8pciwDlMJW/debits", function(err, result) {
var user = balanced.Accounts.nbalanced(result);
user.Debits.create({ amount: 1000 }, function(err, result) {
/* . . . */
});

});

执行此语句后它失败...

var user = balanced.Accounts.nbalanced(result);

我得到的错误信息是......

以下属性是必需的,并且缺少或为空 (id)。

这是完整的堆栈跟踪...

C:\Users\Nabeel\GroupFund\node\node_modules\balanced-official\lib\nbalanced\validate.js:112
if (!callback) throw error;
                     ^
The following properties are required and are missing or null (id).
4

2 回答 2

3

是的,最初的问题是该示例提供了帐户借记 URI,而它本应是帐户 URI。

这些示例已在 Balanced 文档中更新,现在可以使用 Customer 资源。它们现在也应该是独立的可运行示例。请参阅https://docs.balancedpayments.com/current/?language=node#charge-a-credit-card

于 2013-08-24T03:35:31.157 回答
1

I found the mistake in the sample code given in the documentation. All I had to do was omit the /debits from the uri in balanced.Accounts.getcall...

The following code works...

    balanced.Accounts.get("/v1/marketplaces/TEST-MP60c88vnFHzgzEyzGcbMKic/accounts/AC1a77avbmVTUt8pciwDlMJW", function(err, result) {
    var user = balanced.Accounts.nbalanced(result);
    user.Debits.create({ amount: 1000 }, function(err, result) {
    /* . . . */
    });
});
于 2013-08-23T19:17:30.743 回答