Bitcoin payment protocol overview
The Bitcoin payment protocol specification is presented in the BIP 70 (https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki), BIP 71(https://github.com/bitcoin/bips/blob/master/bip-0071.mediawiki), BIP 72(https://github.com/bitcoin/bips/blob/master/bip-0072.mediawiki) and BIP 73(https://github.com/bitcoin/bips/blob/master/bip-0073.mediawiki) documents. It was designed to introduce additional features to bitcoin by replacing the use of a bitcoin address with direct payment flow between the sender and recipient of funds using a graphical wallet to offer a seamless checkout process. The main goal of BIP 70 is to provide a bitcoin payment solution, improving the customer experience and securing the online payments.
If you are familiar with C++, you can examine paymentserver.cpp and paymentrequestplus.cpp located in the Bitcoin GitHub repository at https://github.com/bitcoin/bitcoin/blob/master/src/qt/.
The user does not have to deal with bitcoin's underlying mechanisms, they only have to simply open their wallet with a payment request and proceed with the payment. The following sequence diagram shows how the customer's and merchant's wallets interact with each other and with the bitcoin network to process the payment operation using BIP 70 protocol:
When the customer initiates the checkout process, the merchant launches a payment request to the user's wallet signed with its certificate. Once received, the latter parses and validates the request details, and then authorizes the payment by sending the payment transaction back to the merchant or directly to the network. When the payment is settled, the merchant sends a payment acknowledgment to the user with potential invoice details.