Node-RED nodes to interact with BTCPay Server.
Run the following command in the root directory of your Node-RED instance:
npm install --save node-red-contrib-btcpay
This set provides 2 nodes:
btcpay-api
- a BTCPay API client node. It makes API requests by sendingmsg.payload
data to the specified API endpoint and outputs the response data asmsg.payload
.btcpay-ipn
- a BTCPay IPN listener node. It listens to BTCPay Instant Payment Notifications and outputs the invoice object as themsg.payload
.
You first need to create a new BTCPay store:
- Log in to your BTCPay Server instance
- Go to Stores menu
- Click on
Create a new store
- Enter a name
- Push
Create
Now you need to pair the client with your BTCPay store:
- Navigate to
Stores > Settings > Access Tokens
on your BTCPay Server - Create a new token
- Leave PublicKey blank
- Request pairing
- Copy pairing code
- Open your Node-RED instance
- Drag & drop the
btcpay api
node from the palette to the workspace and double-click on it, to open the node editor - In the
Client
dropdown menu pick theAdd New btcpay-api-config
option and press the pencil button at the right to add a new API configuration - Enter the https URL to your BTCPay Server instance
- Paste the pairing code you copied on step 5
- Click the
Pair client
button - the private key and token fields will be automatically filled with your api credentials - Push
Update
To make requests using the btcpay-api
node, set the http method and the url path to the API endpoint the node will call. These can be either specified in the node settings, or provided in msg.method
(if the method is "via msg.method") and in msg.path
(if the path is empty). The request body is the data in msg.payload
.
After executing a request the node returns a message with the response data set to msg.payload
.
To receive Instant Payment Notifications with the btcpay-ipn
node, set the url path the IPN listener will listen to notifications on.
When BTCPay Server sends a notification to the IPN listener url, it will trigger the node output with the invoice object set to msg.payload
. Note: as the incoming data cannot be trusted, the node fetches the invoice data via API before the output.
This example enables to create an invoice with params specified in the "Invoice params" node by clicking the inject button. The "Invoice URL" node outputs the url of the new invoice to Debug window.
Flow json for Node-RED: btcpay-invoice-creator.json
This example implements a simple IPN handler which outputs the data of confirmed and complete invoices to Debug window.
Flow json for Node-RED: btcpay-ipn-handler.json
More ready-made flows are available here.
BTCPay implements the same API as Bitpay for creating and managing invoices. The API Reference: https://bitpay.com/api/#rest-api-resources
[Donate] Thank you for your support! 🙌
Build & Test in Watch mode:
yarn dev
Read Node-RED docs on how to install the dev-version of the node into your local Node-RED runtime.
MIT © Alex Kaul