Developer Guide

Receiving

15min

Receiving Payments

This guide explains how to receive Lightning Network payments using the Voltage API.

Prerequisites

  • A Voltage account with an active wallet
  • An API key (get this from the "API Keys" page in your dashboard)

Creating and Retrieving a Payment Request

Receiving a payment is a two-step process:

  1. Create a payment request
  2. Retrieve the payment details

Step 1: Create Payment Request

Endpoint

Text


Headers

Text


Request Body

JSON


Required Fields

  • id: A unique identifier for the payment
  • wallet_id: The ID of the wallet receiving the payment
  • amount_msats: Amount to receive in millisatoshis
  • currency: Currently only "btc" is supported
  • payment_kind: Currently only "bolt11" is supported
  • description: Description that will be included in the invoice

Step 2: Retrieve Payment Details

Endpoint

Text


Headers

Text


Response

JSON


The payment_request in the response contains the BOLT11 invoice that should be provided to the payer.

Complete Example Implementation

Bash


Monitoring Payment Status

After creating a payment request, monitor its status using the same GET endpoint:

The payment will transition through these states:

  • receiving: Waiting for payment
  • completed: Payment received successfully
  • failed: Payment failed (check error field for details)

Error Handling

Common HTTP status codes:

  • 200: Success
  • 201: Payment request created
  • 400: Invalid request (check error message)
  • 403: Authentication error
  • 404: Payment not found
  • 500: Server error

Best Practices

  1. Generate unique payment IDs for each request
  2. Always retrieve the payment details after creation to get the BOLT11 invoice
  3. Store the payment ID to track the payment status
  4. Provide clear descriptions for better record keeping
  5. Monitor payment status changes to update your application accordingly
  6. Consider implementing webhook notifications for real-time updates