square / square-nodejs-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Breaking bug: Cards/ListCards model incorrect

fringefilmsoz opened this issue · comments

Square have documented their response to a list cards request incorrectly. This is causing failures to parse when response is received.

Correct model is in the API explorer (Note [card] is not nestled within [cards], there is no [card] object:

{
  "cards": [
    {
      "id": "ccof:xxxx",
      "card_brand": "VISA",
      "last_4": "1111",
      "exp_month": 11,
      "exp_year": 2033,
      "billing_address": {
        "postal_code": "666"
      },
      "fingerprint": "xxx",
      "customer_id": "xxx",
      "enabled": true,
      "bin": "411111",
      "created_at": "2021-06-13T23:21:29Z"
    },
    {
      "id": "ccof:xxxx",
      "card_brand": "VISA",
      "last_4": "1111",
      "exp_month": 2,
      "exp_year": 2023,
      "billing_address": {
        "postal_code": "777"
      },
      "fingerprint": "xxxxx",
      "customer_id": "xxxx",
      "enabled": true,
      "bin": "411111",
      "created_at": "2021-06-14T11:43:49Z"
    },
    {
      "id": "ccof:xxxx",
      "card_brand": "AMERICAN_EXPRESS",
      "last_4": "6550",
      "exp_month": 6,
      "exp_year": 2023,
      "billing_address": {
        "postal_code": "94103"
      },
      "fingerprint": "sq-1-xxxxx",
      "customer_id": "xxxxx",
      "enabled": true,
      "bin": "371263",
      "created_at": "2021-06-23T11:19:54Z"
    }
  ]
}

Incorrect model listed in their API docs.

{
  "cards": [
    {
      "card": {
        "id": "ccof:uIbfJXhXETSP197M3GB",
        "billing_address": {
          "address_line_1": "500 Electric Ave",
          "address_line_2": "Suite 600",
          "locality": "New York",
          "administrative_district_level_1": "NY",
          "postal_code": "10003",
          "country": "US"
        },
        "fingerprint": "ex-p-cs80EK9Flz7LsCMv-szbptQ_ssAGrhemzSTsPFgt9nzyE6t7okiLIQc-qw_quqKX4Q",
        "bin": "411111",
        "card_brand": "VISA",
        "card_type": "CREDIT",
        "cardholder_name": "Amelia Earhart",
        "customer_id": "VDKXEEKPJN48QDG3BGGFAK05P8",
        "enabled": true,
        "exp_month": 11,
        "exp_year": 2022,
        "last_4": "1111",
        "prepaid_type": "NOT_PREPAID",
        "reference_id": "user-id-1",
        "version": 1
      }
    }
  ]

hey @fringefilmsoz,

Thanks for opening this issue, and reporting it! I have put in the request to get our examples updated.

Cheers!