balanced / balanced-api

Balanced API specification.
220 stars 72 forks source link

Card token is not being associated with a marketplace in a particular case #572

Closed matin closed 10 years ago

matin commented 10 years ago

Expected behavior:

  1. Create a card using balanced.js
  2. Fetch the card server side
  3. Card is associated with marketplace

Currently, the card is not being associated with the marketplace.

I suspect that this bug does not manifest when associating the card with a customer, which is why it hasn't been reported sooner.

/cc @remear @mjallday

remear commented 10 years ago

https://github.com/PoundPay/balanced/issues/453

mjallday commented 10 years ago

curl https://api.balancedpayments.com/cards -H "Accept: application/vnd.api+json;revision=1.1" -d "expiration_month=12" -d "cvv=123" -d "number=5105105105105100" -d "expiration_year=2020"

{
  "cards": [
    {
      "href": "/cards/CC7xw7R9HskTNLGL6DxOodbA",
      "id": "CC7xw7R9HskTNLGL6DxOodbA",
      "links": {}
    }
  ],
  "links": {}
}

curl https://api.balancedpayments.com/cards/CC77YGRkkMQyFp5BaqYABBGj -H "Accept: application/vnd.api+json;revision=1.1" -u ak-test-1PPfI4CmXSaOHFgIYzWdA5fpdkYe9mvLL:

{
  "cards": [
    {
      "cvv_match": "yes",
      "links": {
        "customer": null
      },
      "name": null,
      "expiration_year": 2020,
      "avs_street_match": null,
      "is_verified": true,
      "created_at": "2014-04-21T22:55:27.930895Z",
      "cvv_result": "Match",
      "brand": "MasterCard",
      "number": "xxxxxxxxxxxx5100",
      "updated_at": "2014-04-21T22:55:27.930897Z",
      "id": "CC7xw7R9HskTNLGL6DxOodbA",
      "expiration_month": 12,
      "cvv": "xxx",
      "meta": {},
      "href": "/cards/CC7xw7R9HskTNLGL6DxOodbA",
      "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"
  }
}
mahmoudimus commented 10 years ago

@steveklabnik We must write a spec to prevent regressions. /cc @remear

steveklabnik commented 10 years ago

So, I'm writing a regression spec to make sure we have this behavior working properly. How should I test the association? Is it that without the fix, the GET would be wrong?

mjallday commented 10 years ago

@steveklabnik the GET would work, but a subsequent GET on the cards.index endpoint would not show the card because it was not persisted.

steveklabnik commented 10 years ago

Okay. Hmmm.

matin commented 10 years ago

@mjallday I think you mean to say that cards.index endpoint should show the card, but it previously (incorrectly) was not.

/cc @steveklabnik

mjallday commented 10 years ago

yes, i was agreeing with steve that the GET would be wrong. you're correct, that was confusing ;)

when the card is correctly associated, it will be returned when indexing the cards endpoint. if the card fails to associate to the marketplace it will not be returned.

steveklabnik commented 10 years ago

At least I read it correctly, even if it was wrong. :sweat_smile: