Skip to main content

Overview

Mavapay allows your users to buy Bitcoin on-chain using Nigerian Naira (NGN). This guide covers two methods for on-chain Bitcoin purchases: Quote Requests and Payment Links.
On-Chain vs Lightning:
  • On-Chain: Bitcoin is sent to a standard Bitcoin address. Transactions require block confirmations (slower, higher fees, but works with any Bitcoin wallet).
  • Lightning: Bitcoin is sent via Lightning Network invoice or address (faster, lower fees). See Buying Bitcoin (Lightning) for Lightning integration.
Minimum Amount: The minimum amount for on-chain transactions is 6000 SATs.

Method 1: Using Quote Request

Generate a quote to buy Bitcoin on-chain. This method allows you to lock in an exchange rate before the user makes payment.

Key Concepts

Create a Quote

Request a quote specifying the on-chain address as the beneficiary:

Quote Response

The response includes the amount to pay and bank details for the transfer:

Response Fields

Display Payment Instructions

Show the user the bank account details:

Payment Links simplify the checkout process by creating a hosted payment page. Users can complete payments without your application handling the bank transfer details directly.

Payment Link API Reference

View the complete API reference for creating and managing payment links.

Speed Options

The speed parameter determines the on-chain transaction fee and confirmation time:
Retrieve details about a payment link for rendering a custom UI:

Details Response


Testing & Simulation (Staging Only)

Test the on-chain flow in staging without real funds.
Simulation is only available in the staging environment: https://staging.api.mavapay.co/api/v1

Step 1: Get the Order ID

For Payment Links, retrieve the order ID from the payment link orders endpoint:
The response includes the payment link details and all associated orders:
Order Expiration: When an order expires, a new order is automatically created for the payment link. Use the orderId from the order with status: "PENDING" for simulation.

Step 2: Simulate Payment

Use the order ID to simulate a bank transfer:
The amount is in the lowest denomination (kobo for NGN).

Webhooks

After a successful payment, your registered webhook endpoint receives events tracking the transaction through completion.

Event Flow

  1. payment.received - Fiat payment received from user
  2. payment.sent - Bitcoin sent on-chain (status: PENDING until 3 confirmations)
  3. payment_link.settled - Payment link transaction fully settled
On-chain withdrawals remain in PENDING status until there are 3 block confirmations, after which a success event is sent.
Sent when a Payment Link transaction is fully settled:

payment.sent (On-Chain Withdrawal)

Indicates the on-chain withdrawal has been processed:

On-Chain Specific Fields

payment.received (Fiat Deposit)

Indicates the fiat deposit has been received:

Implementation Example

Complete On-Chain Purchase Flow


Important Considerations

Minimum Amount

On-chain transactions require a minimum of 6000 SATs due to network dust limits and fees.

Confirmation Time

On-chain transactions require blockchain confirmations:
  • slow: ~60+ minutes (1+ blocks)
  • medium: ~30-60 minutes
  • fast: ~10-30 minutes

Network Fees

The estimatedRoutingFee field shows the expected on-chain fee. Actual fees may vary based on network congestion.

Address Validation

Always validate Bitcoin addresses before creating quotes. Use a proper library like bitcoinjs-lib to validate addresses with checksum verification:
Avoid regex-based validation as it doesn’t verify checksums and can accept invalid addresses. Always use a library that performs proper checksum validation.