All payments are initiated by the customer.
Suppose a customer wishes to purchase a good or service from the merchant using their zkChannel with channel identifier channel_id
. We denote the good or service by x
in the description below and the cost is an amount amt
.
- The customer's status for the channel with identifier
channel_id
must beReady
. - The implementation should ensure that the channel has sufficient balance for the payment in question before establishing a session with the merchant (i.e., before sending the first message to the merchant).
-
The customer sends a payment request message containing the tuple
(x, amt)
to the merchant. -
The merchant checks the payment request message and decides whether to accept or reject. If the former, they send
accept
; if the latter, they sendreject
and abort. -
Upon receipt of
reject
, the customer aborts the session. Upon receipt ofaccept
, the customer and merchant runzkAbacus.Pay()
for amountamt
on the channel with identifierchannel_id
. The customer must have statusReady
and must use the current channel state data to process the payment. The merchant must have read and write access to their revocation databaserevocation_DB
and their blind signing key.During execution of
zkAbacus.Pay()
, the customer transitions their status fromReady
toStarted
toLocked
and finally toReady
. For more details on this functionality, see Section 3.3.2 of the zkChannels Private Payments Protocol. -
The merchant receives a success indicator from
zkAbacus.Pay()
, which can be used to decide whether or not the requested service should be provided:-
If the merchant receives a failure indicator, no good or service should be provided.
-
If the merchant receives
revocation-incomplete
, then ifamt
represents a negative value (i.e., the payment request is for a refund), the merchant should consider the payment complete. This is because, in this case, the customer has a way to close on their updated state, in which the refund has been successfully applied. Ifamt
represents a positive value, the merchant should consider the payment incomplete and no service should be provided. -
If the merchant receives
revocation-complete
, then the merchant should consider the payment complete. In this case, the customer can no longer close on the previous state. In this case, the merchant should provide the requested service.
-
-
The customer also receives a success indicator from
zkAbacus.Pay()
and does the following:- If the customer receives
revocation-incomplete
, the channel with identifierchannel_id
has a channel status ofStarted
. The customer should initiate a unilateral customer close on their current state, i.e., with balances that do not reflect the attempted payment. - If the customer receives
revocation-complete
, the channel with identifierchannel_id
has a status ofLocked
. The customer should initiate a unilateral customer close on the updated state, the balances of which reflect a payment of amountamt
. - If the customer receives
state-updated
, the channel with identifierchannel_id
has a status ofReady
. They should expect to receive the requested good or service and may continue to make additional payments on the channel.
- If the customer receives