Balanced Payments API call.meteor.js

时间:2013-09-27 14:06:35

标签: node.js meteor balanced-payments

您好我目前在我的流星应用程序中使用平衡付款。我可以很好地创建卡片和顾客,我可以很好地将卡片与顾客联系起来。当我尝试创建借记时,我遇到了一个问题。这是我编写的代码,它几乎直接来自均衡的文档。

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);
      });
  });  

每当上面的代码运行时,我收到错误“在服务器上找不到请求的URL”。我发现了问题,但我不完全确定如何解决它。我去平衡的仪表板检查日志,我发现了这个。

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

请求正文在这里:

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

以下是回复正文:

{
  "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"
}

我看到URI有市场和客户网址,但我不知道为什么或可能导致这种情况发生的原因,因为我说客户创建,卡片创建和卡片关联调用都完美无缺。

任何建议都将受到赞赏。

1 个答案:

答案 0 :(得分:0)

https://docs.balancedpayments.com/current/api#create-a-new-debit处的平衡api文档表明请求的网址存在问题。

您正在使用请求的api模块中的网址

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

什么时候应该

/v1/customers/CU6jgv9FlavhPyYQ6ObZKDny/debits

也可能是它需要marketplaces uri,但文档中没有与此类模式匹配的规范,加上'/ v1 /`表示它被不必要地附加< / p>

您尚未提供有关您正在使用的软件包类型的详细信息,但问题在于创建请求URI的部分中的软件包,或者如果未在其中一个参数中验证它提供。