balanced / balanced-api

Balanced API specification.
221 stars 72 forks source link

documentation wrong for AVS success/failure #549

Closed jbrowning closed 10 years ago

jbrowning commented 10 years ago

API Version: 1.1

According to the documentation, an address verification check for postal codes can be simulated by supplying one of the following during tokenization:

Supplying any of these postal codes does not change the value of the avs_postal_match attribute in the response. Furthermore, the documentation incorrectly states that the card will have a postal_code_check attribute containing the result.

Expecting Success

$ curl https://api.balancedpayments.com/cards \
       -H "Accept: application/vnd.api+json;revision=1.1" \
       -u ak-test-XWwrkAngK60JtzWSvvKq4pjtm5ecCdjq: \
       -d "expiration_month=12" \
       -d "cvv=123" \
       -d "number=5105105105105100" \
       -d "expiration_year=2020" \
       -d "postal_code=94301"
{
  "cards": [
    {
      "cvv_match": "yes",
      "links": {
        "customer": null
      },
      "name": null,
      "expiration_year": 2020,
      "avs_street_match": null,
      "is_verified": true,
      "created_at": "2014-03-27T14:23:55.330215Z",
      "cvv_result": "Match",
      "brand": "MasterCard",
      "number": "xxxxxxxxxxxx5100",
      "updated_at": "2014-03-27T14:23:55.330220Z",
      "id": "CC3kMkkjOBMsnGaReS2YgMAM",
      "expiration_month": 12,
      "cvv": "xxx",
      "meta": {},
      "href": "/cards/CC3kMkkjOBMsnGaReS2YgMAM",
      "address": {
        "city": null,
        "line2": null,
        "line1": null,
        "state": null,
        "postal_code": null,
        "country_code": null
      },
      "fingerprint": "fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788",
      "avs_postal_match": null,
      "avs_result": null
    }
  ],
  "links": {
    "cards.card_holds": "/cards/{cards.id}/card_holds",
    "cards.customer": "/customers/{cards.customer}",
    "cards.debits": "/cards/{cards.id}/debits"
  }
}

Expecting Failure

$ curl https://api.balancedpayments.com/cards \
      -H "Accept: application/vnd.api+json;revision=1.1" \
      -u ak-test-XWwrkAngK60JtzWSvvKq4pjtm5ecCdjq: \
      -d "expiration_month=12" \
      -d "cvv=123" \
      -d "number=5105105105105100" \
      -d "expiration_year=2020" \
      -d "postal_code=90210"
{
  "cards": [
    {
      "cvv_match": "yes",
      "links": {
        "customer": null
      },
      "name": null,
      "expiration_year": 2020,
      "avs_street_match": null,
      "is_verified": true,
      "created_at": "2014-03-27T14:18:45.622596Z",
      "cvv_result": "Match",
      "brand": "MasterCard",
      "number": "xxxxxxxxxxxx5100",
      "updated_at": "2014-03-27T14:18:45.622600Z",
      "id": "CC5vvxJCw4aPUN3EvFrMa4oU",
      "expiration_month": 12,
      "cvv": "xxx",
      "meta": {},
      "href": "/cards/CC5vvxJCw4aPUN3EvFrMa4oU",
      "address": {
        "city": null,
        "line2": null,
        "line1": null,
        "state": null,
        "postal_code": null,
        "country_code": null
      },
      "fingerprint": "fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788",
      "avs_postal_match": null,
      "avs_result": null
    }
  ],
  "links": {
    "cards.card_holds": "/cards/{cards.id}/card_holds",
    "cards.customer": "/customers/{cards.customer}",
    "cards.debits": "/cards/{cards.id}/debits"
  }
}
matthewfl commented 10 years ago

@jbrowning sorry for taking so long to look into this further, however this appears to be an issue with the documentation not the api.

The address info is suppose to be passed as an address object, not top level attributes like in the old version of the api.

https://docs.balancedpayments.com/1.1/api/cards/#create-a-card-direct https://github.com/balanced/balanced-api/blob/master/fixtures/_models/card.json#L90-L92 https://github.com/balanced/balanced-api/blob/master/fixtures/_models/address.json#L34-L40

[0 14:14:42 matthew]% curl https://api.balancedpayments.com/cards \                                                                                                 ~
       -H "Accept: application/vnd.api+json;revision=1.1" \
       -u ak-test-XWwrkAngK60JtzWSvvKq4pjtm5ecCdjq: \
       -d "expiration_month=12" \
       -d "cvv=123" \
       -d "number=5105105105105100" \
       -d "expiration_year=2020" \
       -d "address[postal_code]=90211"
{
  "cards": [
    {
      "cvv_match": "yes",
      "links": {
        "customer": null
      },
      "name": null,
      "expiration_year": 2020,
      "avs_street_match": "yes",
      "is_verified": true,
      "created_at": "2014-04-10T21:14:46.105523Z",
      "cvv_result": "Match",
      "brand": "MasterCard",
      "number": "xxxxxxxxxxxx5100",
      "updated_at": "2014-04-10T21:14:46.105525Z",
      "id": "CCXUj8pebw2RwBSmw9mrFdj",
      "expiration_month": 12,
      "cvv": "xxx",
      "meta": {},
      "href": "/cards/CCXUj8pebw2RwBSmw9mrFdj",
      "address": {
        "city": "Balo Alto",
        "line2": null,
        "line1": null,
        "state": "CA",
        "postal_code": "90211",
        "country_code": null
      },
      "fingerprint": "fc4ccd5de54f42a5e75f76fbfde60948440c7a382ee7d21b2bc509ab9cfed788",
      "avs_postal_match": "unsupported",
      "avs_result": "Address not verified."
    }
  ],
  "links": {
    "cards.card_holds": "/cards/{cards.id}/card_holds",
    "cards.customer": "/customers/{cards.customer}",
    "cards.debits": "/cards/{cards.id}/debits"
  }
}%
[0 14:16:00 matthew]%   

@remear master of the docs, fyi ^

jbrowning commented 10 years ago

Thanks @matthewfl. Looks like the AVS docs were updated recently to clarify this: https://github.com/balanced/balanced-docs/commit/e751a0c2939d896ba1a4ceb5cf8428e78da604af.