balanced / balanced-api

Balanced API specification.
220 stars 72 forks source link

Crediting card number 4210101111111112 should 409 #610

Closed remear closed 10 years ago

remear commented 10 years ago
curl https://api.balancedpayments.com/cards \
     -H "Accept: application/vnd.api+json;revision=1.1" \
     -u ak-test-eyoGATiAg6YE5thvhSiWIi7NE0zg0l0U: \
     -d "expiration_month=12" \
     -d "name=Georg Telemann" \
     -d "number=4210101111111112" \
     -d "expiration_year=2016"
curl https://api.balancedpayments.com/cards/CC3drJ9E1oQltNpptsavvmqZ/credits \
     -H "Accept: application/vnd.api+json;revision=1.1" \
     -u ak-test-eyoGATiAg6YE5thvhSiWIi7NE0zg0l0U: \
     -d "amount=1234"

Should 409 and create a Credit with a status of failed but does not throw a 409 and creates a Credit with a status of succeeded.

{
  "credits": [
    {
      "status": "succeeded",
      "description": null,
      "links": {
        "customer": null,
        "destination": "CC3drJ9E1oQltNpptsavvmqZ",
        "order": null
      },
      "updated_at": "2014-05-14T17:30:44.315612Z",
      "created_at": "2014-05-14T17:30:44.066286Z",
      "transaction_number": "CR160-714-7090",
      "failure_reason": null,
      "currency": "USD",
      "amount": 1234,
      "failure_reason_code": null,
      "meta": {},
      "href": "/credits/CR3IQJgxYN5cWnQcoE4GgE3v",
      "appears_on_statement_as": "example.com",
      "id": "CR3IQJgxYN5cWnQcoE4GgE3v"
    }
  ],
  "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"
  }
}

Providing a destination card in the credit payload results in the same response:

curl https://api.balancedpayments.com/credits \
     -H "Accept: application/vnd.api+json;revision=1.1" \
     -u 8f7b42ba043211e3bd9e026ba7cd33d0: \
     -d "amount=1234" \
     -d "destination[name]=Georg Telemann" \
     -d "destination[number]=4210101111111112" \
     -d "destination[expiration_month]=12" \
     -d "destination[expiration_year]=2016"
cieplak commented 10 years ago

why should it fail?

cieplak commented 10 years ago

it's a debit card image

remear commented 10 years ago

Spec says this should fail. https://github.com/matin/balanced-api/blob/master/features/rest/push_to_card.feature#L73-L107

cieplak commented 10 years ago

spec is wrong

matin commented 10 years ago

@remear @cieplak Updated the card number to a credit card, which should fail and produce a 409.