Sending instant Bitcoin payments on Vercel
Learn how to send Bitcoin using Vercel Edge Functions.
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.
yarn create next-app <project-name>
cd <project-name>
2. Write an Edge Function
Create a new file in the 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.
Run function locally:
npx next dev
Opening your browser to the following URL: http://localhost:3000/api/send
should return a JSON response with the payment sent message.
You can also test this using curl command:
curl http://localhost:3000/api/send
You’re looking for the status
of completed
to know that the payment settled successfully.
processing
. This is expected — use the callbackUrl
property to receive updates about your payments.4. Send payment in production
Deploy your project to Vercel:
vercel
Opening your browser to the following URL: https://project-name.vercel.app/api/send
should now return this in production.
You can also test this using curl command:
curl https://project-name.vercel.app/api/send
5. Try it yourself
You can now begin sending instant Bitcoin payments on the edge with Vercel + ZBD!
Was this page helpful?