Add voucher state information to voucher list interface
For debugging, reporting, UX purposes it would be useful to know what the current state of each voucher known by the client side of the plugin is.
Here's my conception of the possible states of a voucher are:
- Known but unredeemed. This is the starting state of a voucher.
- Redemption in progress. This is a transient state that exists as long as there is an in-flight API request to the issuer to redeem the voucher for ZKAPs. Some care needs to be taken with this state as it does not persist across process restarts.
- Redemption failed for non-payment. If a request to the issuer received a "payment required" response then the voucher has not been redeemed and redemption will not succeed until payment is made.
- Redemption failed for double-spend protection. If a request to the issuer received an "already redeemed" response then the voucher was already redeemed, either earlier by this client or by another one entirely. Redemption won't ever succeed.
- Redemption failed for another reason. Other errors from the issuer might be transient, related to bugs in the client or server, or due to externalities like network conditions. The redemption has not yet succeed and a retry will be made at some point.
- Redemption succeeded. The voucher has been redeemed for ZKAPs and the ZKAPs have been added to the local database.
This this is not set in stone and the point here is to reflect implementation states to make it easier for people to understand what is happening in the system.
Since we expose a JSON-based HTTP API the states of a voucher can be represented as a short, simple string. For example, "failed-for-non-payment". We should document the specific meaning of each such string we invent. This could be included in the response in a "description" field or some such.