Prerequisites
To complete this guide, you will need the following:1. Create a Next.js Project
Follow the prompts on the create-next-app CLI to create a new project, and then change into the directory of your project.2. Write an Edge Function
For this guide we will be making use of the App Router inside of Next.js.
app/api/send/route.ts
that makes a payment to a Lightning Address (e.g. andre@zbd.gg) with the following code:
3. Send payment locally
In order to successfully send payments through the API, you must have an active balance in the ZBD Project you are using. Learn more about depositing funds into a ZBD Project wallet.If you do not have funds in the ZBD Project you are using, you will receive a 4xx error from the API.
http://localhost:3000/api/send
should return a JSON response with the payment sent message.
You can also test this using curl command:
status
of completed
to know that the payment settled successfully.
Payments in the Lightning Network are asynchronous so you may see a response stating the payment is
processing
. This is expected — use the callbackUrl
property to receive updates about your payments.4. Send payment in production
Deploy your project to Vercel:https://project-name.vercel.app/api/send
should now return this in production.
You can also test this using curl command: