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.
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:Method 2: Using Payment Links
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.
Key Constraints for On-Chain Payment Links
Speed Options
Thespeed parameter determines the on-chain transaction fee and confirmation time:
Create a Payment Link
Payment Link Response
Get Payment Link Details
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.Step 1: Get the Order ID
For Payment Links, retrieve the order ID from the payment link orders endpoint: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
payment.received- Fiat payment received from userpayment.sent- Bitcoin sent on-chain (status: PENDING until 3 confirmations)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.payment_link.settled
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 minutesfast: ~10-30 minutes
Network Fees
TheestimatedRoutingFee 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 likebitcoinjs-lib to validate addresses with checksum verification:
Related Resources
- Buying Bitcoin (Lightning) - Lightning Network integration
- Create Quote API - API reference
- Create Payment Link API - Payment Link API reference
- Beneficiary Formats - All beneficiary object formats
- Webhook Examples - Complete webhook payloads
- Payment Simulation - Testing in staging
