Prerequisites
To complete this guide, you will need the following:1. Create a Node.js project
Start with a brand new empty directory calledexpress-example and run the following command to initiate a Node.js project:
2. Install Express.js
Inside your project directory, run the following command to install Express.js:3. Install @zbdpay/payments-sdk Node.js SDK
Inside your Express.js4. Send and receive Bitcoin
Create a new file calledindex.js and add the following code:
https://example.com/request should return a JSON response with a payment request.
You can also test this using curl command:
data.invoice.request property in the JSON response. It starts with lnbc1 and is the payment request anyone in the Bitcoin Lightning Network can use to pay you.
Opening your browser to the following URL:
https://example.com/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.3. Try it yourself
You can now send and receive instant Bitcoin payments using Express.js + ZBD!Express.js Example
See the full source code.