balanced / balanced-api

Balanced API specification.
221 stars 72 forks source link

Show a status other than "paid" for reversed credits #650

Closed trenton42 closed 10 years ago

trenton42 commented 10 years ago

When a credit is successfully reversed, the status changes to paid The only way to tell if a "paid" credit was not in fact paid is to hit the reversals_uri and check if anything is there.

mjallday commented 10 years ago

What happens here is that the original credit does not change. A reversal is a separate movement of money in the opposite direction. The original credit is still PAID. What state would be used to represent a partial reversal of funds?

Checking the reversals_uri is the correct way to see if there have been any reversals created that are associated to the original credit.

trenton42 commented 10 years ago

Ah, that makes sense, but what about when a credit is reversed before it is paid, and money does not move at all?

Scratch all that, I was looking at the 1.0 documentation :frowning:

mjallday commented 10 years ago

That's a bit more tricky. In that case I could understand if the transaction moved into a CANCELED state or something similar if the funds have yet to impact the escrow.

The way Balanced works, generally speaking, is that a movement of money is never undone. There would be a second movement in the opposite direction in order to cancel out the original movement. Think of it as an append only ledger, we never rewrite history.

In the case of a debit, where the funds never move until the transaction reaches a SUCCEEDED state, then canceling the debit could move it into a CANCELED state. Doing so would not rewrite the history of the escrow balance. However, for a credit we optimistically move the money out of the escrow (otherwise you, the marketplace, could double spend the money). Because the money actually moves we wouldn't change the state of the original credit, we'd create a transaction in the opposite direction.

trenton42 commented 10 years ago

Yes, true. I only noticed because we mistakenly issued a credit twice, and I noticed that as soon as I reversed the credit, the money was immediately returned to our escrowed balance.