balanced / balanced-api

Balanced API specification.
220 stars 72 forks source link

Return links to unsettled credits links from /accounts/{accounts.id}/credits #730

Open kyungmin opened 9 years ago

kyungmin commented 9 years ago

The accounts endpoint currently returns links to all credits and settlements for the account. It makes it difficult to filter out only unsettled credits from the credits list.

mjallday commented 9 years ago

the accounts endpoint should only return accounts. can you please expand on what you mean?

kyungmin commented 9 years ago
  "links": {
    "accounts.credits": "/accounts/{accounts.id}/credits",
    "accounts.reversals": "/accounts/{accounts.id}/reversals",
    "accounts.customer": "/customers/{accounts.customer}",
    "accounts.debits": "/accounts/{accounts.id}/debits",
    "accounts.settlements": "/accounts/{accounts.id}/settlements",
    "accounts.refunds": "/accounts/{accounts.id}/refunds"
  }
mjallday commented 9 years ago

this is a little more tricky than it first appears. i'm not sure that we currently do any filtering by null or not null so we need to figure out how that would work. we also need to resolve how to deal with the fact that a credit can be associated to more than one settlement.

i think we need some more thought around how this works! @balanced/spec-ialz any thoughts about how to filter based off of relationships?

a quicker way may be to create a link /unsettled_credits and make it do the magic we want

matin commented 9 years ago

@mjallday

we also need to resolve how to deal with the fact that a credit can be associated to more than one settlement.

when?

mjallday commented 9 years ago

create a settlement, settlement fails, create a subsequent settlement to retry.

matin commented 9 years ago

I see. A credit can only be associated to one successful settlement. I think that's what @kyungmin is trying to solve.

mjallday commented 9 years ago

one successful unfailed settlement. agreed that's what we want but still unsure how best to express that via the api.

kyungmin commented 9 years ago

Yes. I like the idea of having the /unsettled_credits provide the magic that we want.

kyungmin commented 9 years ago

@balanced/spec-ialz Any other thoughts on this?

kyungmin commented 9 years ago

My response to @remear's comment from chat:

for starters, /accounts/{accounts.id}/credits already returns credits to the account. i also feel it's not critical to finishing Account and Settlement and for now it seems this can be accomplished by checking if a credit or reversal has a settlement and check that settlement's status.

Agreed that this can wait until we have more traction on this feature. However, for the record, this would allow us to implement the following mocks, providing an easier way to view outstanding credits:

settlements tab customer page

remear commented 9 years ago

If an outstanding credit or reversal is defined as one that has not been settled or one that failed to settle, this should already be achievable by displaying as outstanding any credits and reversals without a settlement link. Is pending considered outstanding?

kyungmin commented 9 years ago

By outstanding, I meant unsettled. Users would need to know which credits made to payable accounts need to be settled.

remear commented 9 years ago

If there's a settlement link the credit is either settled or being settled and does not need to be settled. Would you agree?

kyungmin commented 9 years ago

Yes. We are currently loading all credits for the account and filtering out settled ones on the Account page, but it's too expensive to do this for the entire marketplace.