Flow

Flow

731

Step by Step

  1. Decode the invoice using a library in your favourite language or calling /invoice/decode

JavaScript: https://github.com/bitcoinjs/bolt11
Golang: https://github.com/nbd-wtf/ln-decodepay

If amount == 0 :
Ask to the user the amount he wishes to send.

  1. (Optional) Estimate fees with the amount if needed: /estimate-fee. And show it to the user.

  2. Call invoice/pay.

    3.1. If the response is a 200, check the payment status in the response body payment status.

    3.2 If invoice/pay returns an error, get the payment informations: /payment/from-bolt11

  3. If the payment is IN_FLIGHT, wait for the webhook to inform you if the payment was SUCCEEDED or FAILED

Payment Status

ID

Name

Description

0

UNKNOWN

Unknown state

1

IN_FLIGHT

Payment is still in flight.

2

SUCCEEDED

Payment completed successfully.

3

FAILED

Payment failed to settle

Payment Failure Reason

❗️

Payment failed

If the payment fails, you can use them to get more details, if you encounter one of those (except 0), you can contact [email protected].

ID

Name

Description

0

FAILURE_REASON_NONE

Payment isnt failed (yet).

1

FAILURE_REASON_TIMEOUT

There are more routes to try, but the payment timeout was exceeded.

2

FAILURE_REASON_NO_ROUTE

All possible routes were tried and failed permanently. Or were no routes to the destination at all.

3

FAILURE_REASON_ERROR

A non-recoverable error has occured.

4

FAILURE_REASON_INCORRECT_PAYMENT_DETAILS

Payment details incorrect (unknown hash, invalid amt or invalid final cltv delta)

5

FAILURE_REASON_INSUFFICIENT_BALANCE

Insufficient local balance.