Pay Lightning Network Charges
Pay Lightning Network Charges
In order to make a payment against a Lightning Network Payment Request (a.k.a Lightning Invoices, or Charges), you simply have to use the Send Payment API endpoint. A Payment accepts the following attributes:
Property | Status | Description |
---|---|---|
invoice | String | The Lightning payment request, or invoice, that is meant to be paid. |
description | String | The Payment description (only used for internal record-keeping). |
internalId | String | An optional free-use attribute. Usually used by setting the Player/User ID of your Game/Application in order to link specific Payments to specific users. |
callbackUrl | String | The URL ZEBEDEE services will make a POST HTTP request to with information about the Payment's status updates. |
To perform the Payment, use the API (or leverage one of our SDKs) by passing the correct attributes:
- Node.js (@zbd/node)
- cURL
// Using ZEBEDEE's NodeJS SDK
import { zbd } from '@zbd/node';
// Instantiate the client
const ZBD = new zbd('API_KEY_HERE');
// Set the payload
const payload = {
description: 'My Payment Description',
callbackUrl: 'https://myapp.com/zbd-callback',
internalId: '11af01d09a6b8304b8',
invoice: 'lnbc450n1p0yeytspp55yrs0j42wnkw0qutr8e0tgsf2yplxs9986t5gqmfpn7mfd0ckc8sdzq2pshjmt9de6zqen0wgsrgdfqwp5hsetvwvsxzapqwdshgmmndp5hxtnsd3skxefwxqzjccqp2sp5pyccqt6apxelz62d2ndrt0ssahndpcua4wklea80glaczx80t3wqrzjqfn4cln8jwe4dh4dmscddrmd6sdw6hzkn702l6ghwvr8lhad0ez5vzt8vyqqf2sqqqqqqqlgqqqqqqgq9q9qy9qsqqeft09gryr80aaghm7rmh7eeqfl7hxlcynp99730yk7qh534d9nyfwp0nc628rp8hpgp23fxzj5l2aet4y6sc4t79uj3wyjxffejmvgqrmxkvr',
};
// Make Payment
try {
const response = await ZBD.sendPayment(payload);
} catch(error) {
console.log({ error });
}
curl --location --request POST 'https://api.zebedee.io/v0/payments' \
--header 'Content-Type: application/json' \
--header 'apikey: API_KEY' \
--data-raw '{
"invoice": "lnbc450n1p0yeytspp55yrs0j42wnkw0qutr8e0tgsf2yplxs9986t5gqmfpn7mfd0ckc8sdzq2pshjmt9de6zqen0wgsrgdfqwp5hsetvwvsxzapqwdshgmmndp5hxtnsd3skxefwxqzjccqp2sp5pyccqt6apxelz62d2ndrt0ssahndpcua4wklea80glaczx80t3wqrzjqfn4cln8jwe4dh4dmscddrmd6sdw6hzkn702l6ghwvr8lhad0ez5vzt8vyqqf2sqqqqqqqlgqqqqqqgq9q9qy9qsqqeft09gryr80aaghm7rmh7eeqfl7hxlcynp99730yk7qh534d9nyfwp0nc628rp8hpgp23fxzj5l2aet4y6sc4t79uj3wyjxffejmvgqrmxkvr",
"description": "My Payment Description",
"callbackUrl": "https://myapp.com/zbd-callback",
"internalId": "11af01d0cb33faa6b8304b8"
}'
If the submitted request suceeds, you can expect a JSON API response that resembles the following:
{
"message": "Successfully made Payment.",
"data": {
"id": "31d60de1-efe0-4e55-9942-910934efe7a3",
"fee": "1000",
"unit": "msats",
"amount": "10000",
"status": "completed",
"description": "My Payment Description",
"processedAt": "2020-01-01T19:34:42.794Z",
"invoice": "lnbc450n1p0yeytspp55yrs0j42wnkw0qutr8e0tgsf2yplxs9986t5gqmfpn7mfd0ckc8sdzq2pshjmt9de6zqen0wgsrgdfqwp5hsetvwvsxzapqwdshgmmndp5hxtnsd3skxefwxqzjccqp2sp5pyccqt6apxelz62d2ndrt0ssahndpcua4wklea80glaczx80t3wqrzjqfn4cln8jwe4dh4dmscddrmd6sdw6hzkn702l6ghwvr8lhad0ez5vzt8vyqqf2sqqqqqqqlgqqqqqqgq9q9qy9qsqqeft09gryr80aaghm7rmh7eeqfl7hxlcynp99730yk7qh534d9nyfwp0nc628rp8hpgp23fxzj5l2aet4y6sc4t79uj3wyjxffejmvgqrmxkvr"
}
}
Payment Updates
There are cases where Lightning Payments can get stuck
in transit (e.g. a network node on the path to the payment's destination suddenly goes offline). ZEBEDEE aims to provide cutting edge Lightning Network infrastructure with high availability and liquidity. That said, due to the possibility of running into stuck payment cases, the recommended method of getting Payment updates is through the callbackUrl
attribute. By providing a callbackUrl
when making the Payment, the ZEBEDEE API is able to make a POST request to that URL and pass along Payment updates as they happen.