Question

Hi I am currently using balanced payments in my meteor application. I can create cards and customers just fine and I can associate the cards to the customers just fine. I run into a problem though when I try to create a debit. Here is the code that I have written which is pretty much taken directly from the balanced docs.

var customer = balanced.Customers.get(user.customer.uri, function (err, customer) {
      console.error(err);
      console.log(customer);

      var customerContext = balanced.Customers.nbalanced(customer);

      var debitInfo = {
          amount: amount,
          appears_on_statement_as: "Statement text",
          description: "Some descriptive text for the debit in the dashboard"
      };

      customerContext.Debits.create(debitInfo, function(err, result) {
          console.error(err);
          console.log(result);
      });
  });  

I get the error "The requested URL was not found on the server" whenever the above code runs. I found the problem but I'm not entirely sure how to solve it. I went to the balanced dashboard to check the logs and what I found was this.

Date: Fri, 27 Sep 2013, 6:46 AM
Method: POST
URI:  /v1/marketplaces/TEST-MPFj4MYWjZc9xt2IjTIni7/v1/customers/CU6jgv9FlavhPyYQ6ObZKDny/debits
Status: 404 NOT FOUND

The request body is here:

{
  "appears_on_statement_as": "Statement text",
  "amount": 1200,
  "description": "Some descriptive text for the debit in the dashboard"
}

Here is the response body:

{
  "status": "Not Found",
  "category_code": "not-found",
  "description": "<p>The requested URL was not found on the server.</p><p>If you entered the URL manually please check your spelling and try again.</p> Your request id is OHM38291020277b11e38b38026ba7cac9da.",
  "status_code": 404,
  "category_type": "request",
  "_uris": {},
  "request_id": "OHM38291020277b11e38b38026ba7cac9da"
}

I see that the URI has the marketplace and customer url but I don't know why or what could have caused that to happen because like I said the customer creation, card creation and card association calls all work perfectly.

Any advice would be appreciated.

Was it helpful?

Solution

The balanced api documentation over at https://docs.balancedpayments.com/current/api#create-a-new-debit suggests there is an issue with the requested URL.

The URL in the api module you're using requests

/v1/marketplaces/TEST-MPFj4MYWjZc9xt2IjTIni7/v1/customers/CU6jgv9FlavhPyYQ6ObZKDny/debits

when it should be

/v1/customers/CU6jgv9FlavhPyYQ6ObZKDny/debits

It could also be that it needs the marketplaces uri in there, but there isn't a specification in the docs that matches this type of pattern, plus the '/v1/` suggests its being appended unnecessarily

You haven't given details on the type of package you're using but the issue for this lies in the package in the portion that creates the request URI, or if its not validated perhaps in one of the parameters you've provided.

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