Question

I am trying to do an account credit request with Node.js using the following example. But it fails even when I use the sample code without any change. 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) {
/* . . . */
});

});

It fails after this statement is executed...

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

The error message I get is...

The following properties are required and are missing or null (id).

Here is the full stack trace...

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).
Was it helpful?

Solution 2

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) {
    /* . . . */
    });
});

OTHER TIPS

The original issue, yes, was that the example supplied the account debits URI when it should have been the account URI.

These examples have been updated in the Balanced documentation to now use the Customer resource. They should also now be self-contained runnable examples. See https://docs.balancedpayments.com/current/?language=node#charge-a-credit-card

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top