DPP consists of three messages exchanged between the sender and the receiver:
- Payment Terms
- Payment ACK (acknowledgement)
Prerequisite: An invoice should be created. The schema for the invoice is kept open as it is left to the receiver's discretion.
Payment terms (GET) provide the sender the required information for making the payment to the receiver (payment host).
Submit the following payment GET request.
Returns the information for the sender to make the payment to the receiver.
"description": "payment reference w6zwZzn"
"memo": "invoice w6zwZzn",
"address": "1 Athens Avenue",
"likes": "Stoicism & placeholder data",
The returned payment information contains required details such as:
- url (payment url)
- a list of outputs (see below)
- expiry date
- other meta data that may be used by the receiver to identify the PaymentRequest.
The payment url specified in the PaymentRequest will remain valid at least until the PaymentRequest expirationTimestamp (or as long as possible if the PaymentRequest does not expire).
Note: This is irrespective of any state change in the underlying payment request; for example, cancellation of an order should not invalidate the paymentUrl, as it is important that the receiver's server can record mis-payments in order to refund the payment.
When a Bitcoin wallet application receives a payment request, it must authorize the payment by doing the following:
- Validate the receiver's identity and signature using the PKI system. The PKI system is assumed to occur in a wrapper layer (such as HTTPS) and if no PKI system is available, then the wallet can choose whether or not to display the payment request. The PKI system is usually HTTPS, and if the payment request is retrieved over HTTPS then the domain name should be displayed as the receiver.
- Verify that the sender's system unix time (UTC) is before PaymentRequest.expirationTimestamp. If it is not, the payment request must be rejected.
- Display the receiver's identity and check if the sender would like to submit a payment (for example, display the "Common Name" in the first X.509 certificate).
Outputs are used in PaymentRequest messages to specify where a payment (or part of a payment) should be sent. They are also used in Payment messages to specify where a refund should be sent.
A payment (POST) is based on a payment id (the identifier for a payment above) and is sent to the receiver when the sender authorises a payment:
- 1.Creates and signs a transaction that satisfies (pay in full) PaymentRequest.outputs. It may add additional outputs if needed.
- 2.Verifies that the sender's system unix time (UTC) is before PaymentDetails.expirationTimestamp. If it is not, the payment should be cancelled.
- 3.Posts a Payment message to the paymentUrl URL. The Payment message is serialized and sent as the body of the POST request.
- 4.May optionally broadcast the transaction themselves to the Bitcoin network, but they are not required to do so as the receiver is expected to broadcast the transaction. If the receiver did not broadcast the transaction, the client can recover their funds within two months.
Errors communicating with the paymentUrl server should be communicated to the user. When the receiver's server receives multiple identical Payment messages for an individual PaymentRequest, it must acknowledge each. The second and further PaymentACK messages sent from the receiver's server may vary by memo field to indicate the current state of the payment (for example, the number of confirmations seen on the network). This is required in order to ensure that in case of a transport level failure during transmission, recovery is made possible by the Bitcoin client re-sending the payment message.
PaymentDetails.paymentUrl should be made secure against man-in-the-middle attacks that might alter Payment.refundTo because the wallet and receiver are using HTTPS or some other secure transit layer.
Wallet software sending payment messages via HTTPS must set appropriate Content-Type and Accept headers, as specified in BIP 271:
When the receiver's server receives the payment message, it must determine whether the transaction satisfies payment conditions. If and only if they do, should it broadcast the transaction to the Bitcoin Peer network.
Payment messages larger than 10 MB should be rejected by the receiver's server, to mitigate denial-of-service attacks.
Payment Acknowledgement (Payment ACK) is the final message in the payment protocol. It is sent from the receiver's server to the bitcoin wallet in response to a payment message.
Note: This is a reference implementation and is provided as an open source code for application developers to either use it as is, or to customise it to suit their requirements.