2013-09-27 147 views
0

嗨我目前在我的流星应用程序中使用平衡付款。我可以创建卡片和客户,并且我可以将卡片与客户联系得很好。尽管我尝试创建借记卡时遇到问题。以下是我编写的代码,几乎可以直接从平衡文档中获取。平衡付款API call.meteor.js

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的市场和客户的url,但我不知道为什么或者什么原因可能导致这种情况发生,因为就像我所说的那样,客户创建,卡片创建和卡片关联呼叫都是完美的。

任何意见,将不胜感激。

回答

0

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

的API模块中的网址,你正在使用的请求

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

当它应该是

/v1/customers/CU6jgv9FlavhPyYQ6ObZKDny/debits 

这也可能是因为它需要在那里marketplaces URI,但有ISN”在与这种类型的模式相匹配的文档中,加上'/ v1 /`表示它被不必要地附加到文档中

您还没有给出关于类型你正在使用的软件包,但问题在于创建请求URI的部分包中,或者它可能在你提供的参数中没有验证。

+0

我正在使用的包可以在这里看到https://github.com/ianserlin/meteor-balanced-payments这是一个由同一个人写的包的端口,可以在这里看到https:// github的.com/ianserlin/nbalanced。 –

+0

你可以在运行'.Create'之前查看'customerContext.Debits._action_uri'和'customerContext.Debits._account_uri'的内容吗?它有单个值还是像目录路径?当发生这种情况的同时,你是否也在运行其中的很多功能? – Akshat

+0

我得到未定义的customerContext.Debits._account_uri和我得到/ v1/customers/CU6jgv9FlavhPyYQ6ObZKDny /借方为customorContext.Debit._action_uri。不,我一次只能在生产服务器上运行其中的一个。也感谢你的帮助。 –