2

我可以创建一张卡并使用该新卡创建一个帐户,但是当我尝试创建一个保留时,我收到一个 401 错误说Not permitted to perform create on holds

我正在使用balanced.js创建卡,然后将其发送card_uri到我的应用程序。

然后我通过POSTing创建一个帐户

{
"uri": card_uri,
"email_address":"xxx@yyy.com"
}

https://api.balancedpayments.com/v1/marketplaces/MYTESTMARKETURI/accounts?MYTESTMARKETSECRETKEY我收到这样的回复:

{
"holds_uri": "/v1/marketplaces/MYTESTMARKETURI/accounts/AC6uOkhFTsOMpvY8zAvjnBtu/holds",
"name": null,
"roles": [],
"created_at": ...,
"uri": ...,
"bank_accounts_uri": ...,
"refunds_uri": ...,
"meta": {},
"debits_uri": ..,
"transactions_uri": ...,
"email_address": "xxx@yyy.com",
"id": "AC6uOkhFTsOMpvY8zAvjnBtu",
"credits_uri": ...,
"cards_uri": ...
}

并且带有新卡的新帐户会显示在我在 balancepayments.com 上的仪表板

当我尝试通过POSTing创建保留时

{
"amount": 200
}

https://api.balancedpayments.com/v1/marketplaces/MYTESTMARKETURI/accounts/AC6uOkhFTsOMpvY8zAvjnBtu/holds?MYTESTMARKETSECRETKEY收到以下错误:

{
"status": "Unauthorized",
"category_code": "authentication-required",
"category_type": "permission",
"description": "Not permitted to perform create on holds. Your request id is OHMf82dbd8e10a811e29f5d026ba7d31e6f.",
"request_id": "OHMf82dbd8e10a811e29f5d026ba7d31e6f",
"status_code": 401
}

我究竟做错了什么?如何使用 BalancedPayments.com REST API 创建保留?

4

1 回答 1

4

401表示您在发出创建保留请求时未进行身份验证。

您需要使用基本身份验证标头,而不是在查询字符串中包含MYTESTMARKETSECRETKEY

我不确定您使用的是哪个平衡客户端(它们为您包含该标头,您只需告诉它您的MYTESTMARKETSECRETKEY)但对于 curl 请求将是:

curl -u MYTESTMARKETSECRETKEY:https://api.balancedpayments.com/v1/marketplaces
/MYTESTMARKETURI/accounts/AC6uOkhFTsOMpvY8zAvjnBtu/holds -x POST -d amount=200

响应如下:

{
  "account": {
    "holds_uri": "/v1/marketplaces/MKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/accounts/ACxxxxxxxxxxxxxxxxxxxxxx/holds", 
    "name": "xxxx",
    "roles": [
      "buyer"
    ], 
    "created_at": "2012-07-28T23:12:15.859231Z", 
    "uri": "/v1/marketplaces/MKxxxxxxxxxxxxxxxxxxxxxx/accounts/ACxxxxxxxxxxxxxxxxxxxxxx", 
    "bank_accounts_uri": "/v1/marketplaces/MKxxxxxxxxxxxxxxxxxxxxxx/accounts/ACxxxxxxxxxxxxxxxxxxxxxx/bank_accounts", 
    "refunds_uri": "/v1/marketplaces/MKxxxxxxxxxxxxxxxxxxxxxx/accounts/ACxxxxxxxxxxxxxxxxxxxxxx/refunds", 
    "meta": {}, 
    "debits_uri": "/v1/marketplaces/MKxxxxxxxxxxxxxxxxxxxxxx/accounts/ACxxxxxxxxxxxxxxxxxxxxxx/debits", 
    "transactions_uri": "/v1/marketplaces/MKxxxxxxxxxxxxxxxxxxxxxx/accounts/ACxxxxxxxxxxxxxxxxxxxxxx/transactions", 
    "email_address": "xxxxxxxx@xxxxxx.com", 
    "id": "ACxxxxxxxxxxxxxxxxxxxxxx", 
    "credits_uri": "/v1/marketplaces/MKxxxxxxxxxxxxxxxxxxxxxx/accounts/ACxxxxxxxxxxxxxxxxxxxxxx/credits", 
    "cards_uri": "/v1/marketplaces/MKxxxxxxxxxxxxxxxxxxxxxx/accounts/ACxxxxxxxxxxxxxxxxxxxxxx/cards"
  }, 
  "fee": 35, 
  "description": null, 
  "amount": 123, 
  "created_at": "2012-10-08T05:23:20.943961Z", 
  "uri": "/v1/marketplaces/MKxxxxxxxxxxxxxxxxxxxxxx/holds/HLxxxxxxxxxxxxxxxxxxxxxx", 
  "expires_at": "2012-10-15T05:23:20.876214Z", 
  "source": {
    "card_type": "xxxx"
    "hash": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 
    "country_code": "USA", 
    "expiration_year": xxxx, 
    "created_at": "2012-09-03T01:08:31.530261Z", 
    "brand": "xxxx",
    "uri": "/v1/marketplaces/MKxxxxxxxxxxxxxxxxxxxxxx/accounts/ACxxxxxxxxxxxxxxxxxxxxxx/cards/CCxxxxxxxxxxxxxxxxxxxxxx", 
    "expiration_month": x, 
    "is_valid": true, 
    "meta": {}, 
    "last_four": "xxxx", 
    "postal_code": "xxxxx", 
    "id": "CCxxxxxxxxxxxxxxxxxxxxxx", 
    "street_address": "xxxxxxxxxxx", 
    "name": "xxxxxxxxx"
  }, 
  "transaction_number": "HLxxx-xxx-xxxx", 
  "meta": {}, 
  "is_void": false, 
  "debit": null, 
  "id": "HLxxxxxxxxxxxxxxxxxxxxxx"
}
于 2012-10-08T05:32:48.330 回答