Closed trenton42 closed 10 years ago
This seems like it should be controlled via the API, rather than logic in the dashboard. The API knows its capabilities better than anything else.
@msherry I wasn't sure about that. I only added it to the existing logic because it already checks if the credit failed or if the reversible amount is greater than zero.
@trenton42 this is awesome :) Thank you for contributing code! This makes me super happy!
@mahmoudimus It's not much, but hopefully we can contribute more in the future!
This seems like it should be controlled via the API, rather than logic in the dashboard. The API knows its capabilities better than anything else.
I think @msherry is correct. The better way to implement this fix is to check for the presence of a reversals collection on the funding instrument.
I looked at the FundingInstrument
model in the app and it doesn't seem to have any properties to make this easy however. IMO I should be able to write if (funding_instrument.reversals) { /* I can assume that because of this property I can access reversals*/ }
. Given that this does not exist we should merge this patch but open a subsequent issue to make the models easier to work with. They should have properties I can inspect to find out what operations the instruct accepts.
If I GET a card from the API:
curl https://api.balancedpayments.com/cards/CC4B2H8ApAiCrIqvfLJcjlpr \
-H "Accept: application/vnd.api+json;revision=1.1" \
-u ak-test-2KyZLwTSMm3yhgbLxU6lWFSMoJd4bGLq:
I get the following response (I've removed the body of majority of the response for clarity):
{
"cards": [
{
"href": "/cards/CC4B2H8ApAiCrIqvfLJcjlpr",
"id": "CC4B2H8ApAiCrIqvfLJcjlpr",
"links": {
"customer": null
},
"type": "credit"
}
],
"links": {
"cards.card_holds": "/cards/{cards.id}/card_holds",
"cards.customer": "/customers/{cards.customer}",
"cards.debits": "/cards/{cards.id}/debits",
"cards.disputes": "/cards/{cards.id}/disputes"
}
}
I believe the correct way to resolve this issue would be to look at the links
collection for a "*.reversals" collection. If that existed then we could infer that the card has a collection of reversals and that they could be created by POSTing to that endpoint.
I do note however that if you were returning a collection of cards and one out of the collection supported reversals then the link would appear in the collection but there would be no way of telling which card supported reversals.
Closes balanced/balanced-dashboard#1477