Building a Checkout for Crypto Payments

This guide outlines the process for incorporating crypto payments into your workflow with Layer1 via API, allowing for the customization of your own payments page as desired.

Lets jump in by first understanding the payment flow.

Payment In Sequence Diagram

The sequence diagram for a crypto payment in followed in this guide.

The sequence diagram for a crypto payment in followed in this guide.

The happy path will be discussed, with exception scenarios discussed later on in the guide:

  1. The end user will request to make a deposit on your system, where you will need to collect the amount for the deposit, the cryptocurrency they want to pay with, and protocol if applicable.
  2. This information will then be forward onto us in the form of a Create Payment request.
  3. The Create Payment endpoint will return a crypto address matching the blockchain selected, along with other useful data in the API response. End user can then be shown this address, as well as the total amount of crypto required to complete the payment.
  4. The end user makes a payment to this address, which will then cause multiple related webhooks to be sent to your webhook listener as the payment goes through its lifecycle.
  5. Once you receive the final COMPLETEwebhook you can poll the Get Payment endpoint to confirm the status and final paid amount, or take the information from the webhook.
  6. Update the end users account accordingly with the confirmed payment amount.

Payment Lifecycle

A payment undergoes several status changes throughout its lifecycle, detailed as follows:

StatusImmutable?Description
PendingNoThe initial status of your payment. It remains in this state until the payment either expires or a transaction linked to this payment is detected on the blockchain.
ProcessingNoThis status indicates that the customer's payment has been detected on the blockchain. The payment remains in this state until funds are credited to your wallet.
Note: Payments can still expire in this state if the transaction lacks sufficient gas or if the blockchain does not confirm the transaction within the expiry time.
CompleteYesThis status means that the funds have been received and credited to the merchant account in the chosen currency.
UnderpaidYesIndicates that the funds have been received and credited to the merchant account in the chosen currency, but the amount sent by the customer was less than the requested amount.
ExpiredYesThe payment expired before the customer sent the funds.

Steps to Follow

This guide covers the integration of payment links into your platform to accept crypto payments, detailing the following steps:

  1. Initiating a payment request and handling the response.
  2. Guiding the end user to complete the payment.
  3. Setting up a webhook listener for payment notifications.
  4. Managing payment exceptions and errors.