balanced / balanced-api

Balanced API specification.
220 stars 72 forks source link

Defaults for card type and category #607

Closed matin closed 10 years ago

matin commented 10 years ago
curl https://api.balancedpayments.com/cards \
    -u ak-test-2qEM0Znvd8LIVbZ01LbFHvHgab4fkNr3c: \
    -d number=4111111111111111 \
    -d name="Johannes Bach" \
    -d expiration_month=05 \
    -d expiration_year=2017

returns the following for the card:

{
    "bank": "JPMORGAN CHASE BANK, N.A.",
    "brand": "Visa",
    "type": "",
    "category": null,
    "can_debit": true,
    "can_credit": false,
    ...
}

Even if we're not certain of the values

/cc @cieplak

mjallday commented 10 years ago

@matin category should default to other or unknown? it's possible that we haven't backfilled the information so "other" feels less correct than "unknown".

matin commented 10 years ago

My reasoning:

  1. If we don't know that it's a prepaid card, then it's something else => other
  2. If we don't know it's a debit card, then there's only one other possibility => credit
matin commented 10 years ago

To explain in more detail, the main purpose of returning this information is to give marketplaces the ability to communicate to their customer that the card they've entered is not a debit card or is a prepaid card. Having an "unknown" or null option just makes their lives more difficult by requiring they check against more outcomes and provide an appropriate message to the cardholder.

If we were building a BIN lookup service, then it's more important to be accurate. Our goal is to just provide more detail as to why can_credit is true or false.

matin commented 10 years ago

Works now:

curl https://api.balancedpayments.com/cards \
     -u ak-test-2qEM0Znvd8LIVbZ01LbFHvHgab4fkNr3c: \
     -d number=4111111111111111 \
     -d name="Johannes Bach" \
     -d expiration_month=05 \
     -d expiration_year=2017
{
  "cards": [
      "number": "xxxxxxxxxxxx1111",
      "expiration_month": 5,
      "id": "CC2rgNyHu32kDeGubho6Fnv",
      "category": "other",
      "type": "credit",
      "bank_name": "JPMORGAN CHASE BANK, N.A.",
      "brand": "Visa",
      "can_debit": true,
      "name": "Johannes Bach",
      "expiration_year": 2017,
      "can_credit": false,
      "created_at": "2014-05-15T05:58:58.143693Z",
      ...
    }
  ]
}