balanced / balanced-api

Balanced API specification.
220 stars 72 forks source link

Crediting above limit throws 400 #611

Closed remear closed 10 years ago

remear commented 10 years ago

Spec says this should 409. Instead, it throws 400.

curl https://api.balancedpayments.com/credits \
     -H "Accept: application/vnd.api+json;revision=1.1" \
     -u 8f7b42ba043211e3bd9e026ba7cd33d0: \
     -d "amount=250001" \
     -d "destination[name]=Georg Telemann" \
     -d "destination[number]=4210101111111112" \
     -d "destination[expiration_month]=12" \
     -d "destination[expiration_year]=2016"
{
  "credits": [
    {
      "status": "failed",
      "description": null,
      "links": {
        "customer": null,
        "destination": "CCYImqueyLVvlCxZn6YlxwZ",
        "order": null
      },
      "updated_at": "2014-05-14T17:49:41.546966Z",
      "created_at": "2014-05-14T17:49:41.310234Z",
      "transaction_number": "CR412-156-9139",
      "failure_reason": "Transaction amount exceeds threshold amount.",
      "currency": "USD",
      "amount": 250001,
      "failure_reason_code": "amount-exceeds-limit",
      "meta": {},
      "href": "/credits/CRYJ35U2uvtIXdZjIl4DmAx",
      "appears_on_statement_as": "myawesomesite.com",
      "id": "CRYJ35U2uvtIXdZjIl4DmAx"
    }
  ],
  "errors": [
    {
      "status": "Bad Request",
      "category_code": "amount-exceeds-limit",
      "additional": null,
      "status_code": 400,
      "category_type": "request",
      "extras": {},
      "request_id": "OHM20102144db9011e3b0f902b12035401b",
      "description": "Transaction amount exceeds threshold amount. Your request id is OHM20102144db9011e3b0f902b12035401b."
    }
  ],
  "links": {
    "credits.order": "/orders/{credits.order}",
    "credits.customer": "/customers/{credits.customer}",
    "credits.destination": "/resources/{credits.destination}",
    "credits.reversals": "/credits/{credits.id}/reversals",
    "credits.events": "/credits/{credits.id}/events"
  }
}
remear commented 10 years ago

This has been fixed.

{
  "credits": [
    {
      "status": "failed",
      "description": null,
      "links": {
        "customer": null,
        "destination": "CC4qCBEGm0wYpbaSwV3BhrWB",
        "order": null
      },
      "updated_at": "2014-05-15T21:40:46.215339Z",
      "created_at": "2014-05-15T21:40:44.715083Z",
      "transaction_number": "CR184-650-7239",
      "failure_reason": "Transaction amount exceeds threshold amount.",
      "currency": "USD",
      "amount": 250001,
      "failure_reason_code": "amount-exceeds-limit",
      "meta": {},
      "href": "/credits/CR4rbuVJWc2qVWpJmS4jESz3",
      "appears_on_statement_as": "myawesomesite.com",
      "id": "CR4rbuVJWc2qVWpJmS4jESz3"
    }
  ],
  "errors": [
    {
      "status": "Conflict",
      "category_code": "amount-exceeds-limit",
      "additional": null,
      "status_code": 409,
      "category_type": "logical",
      "extras": {},
      "request_id": "OHM9108d58cdc7911e39ae806429171ffad",
      "description": "Transaction amount exceeds threshold amount. Your request id is OHM9108d58cdc7911e39ae806429171ffad."
    }
  ],
  "links": {
    "credits.order": "/orders/{credits.order}",
    "credits.customer": "/customers/{credits.customer}",
    "credits.destination": "/resources/{credits.destination}",
    "credits.reversals": "/credits/{credits.id}/reversals",
    "credits.events": "/credits/{credits.id}/events"
  }
}