All Blog Posts

How Nodana Accepts Bitcoin Payments

Nodana Image
Sep 26, 2024

Introduction

Accepting Bitcoin payments on your app or website is a fantastic way to stack sats and boost the Bitcoin circular economy. Let me tell you how Nodana accepts payments on the website so you can go and do something similar for your project.

Lightning Node

Nodana accepts Bticoin payments over the Lightning network meaning fast and cheap payments. You will need a Lightning node to do this and there are a few to choose from. However, Phoenixd is a good choice for those just starting out as it's very easy to set up and maintain. And it's a Phoenixd node that Nodana uses so we're in luck.

Phoenxid nodes take care of inbound liquidity and channel management automatically so you don't have to. You can host your own Phoenixd node on Nodana for $10 per month or if you bundle it with Alby Hub or LNbits it's only $5.

A great way to test the connection to your node is using a simple command in the terminal:

If you see information about your node then you know that the node is accepting connections.

Payment Flow

When the Nodana API first starts it establishes a websocket connection to the node to be able to listen for payments. If you for some reason can't use a websocket connection then Phoenixd also supports webhook delivery. You could also even poll the node for a specific payment and check whether it's paid.

Did you know, there's a npm PhoenixdJS client library from Nodana available that makes requests to your node easier. Check it out here.

If you've not used Nodana before then it's useful to know that users create invoices on the website and then they can pay these invoices using a standard Lightning wallet or webln provider such as the Alby browser extension. Here's an example of how to create an invoice using the client library:

If successful, you will get a JSON response that looks a bit like this:

Nodana then uses the serialized value in the response as the value in a QR code display.

When the user makes the payment then the node will send an event back to the API over the websocket connection. The API informs the front-end via another websocket connection and the front-end can show a "Payment Success" message to the user. The balance will also be updated and this happens without any refreshing of the page.

Withdrawing Sats

Nodana has an automated process that runs regularly that will transfer the sats in the node's wallet to a personal wallet which can then be used elsewhere. There's a convenient paylnaddress endpoint provided by Phoenixd which you can use to transfer sats to any wallet that supports Lightning Addresses. There is a small fee to pay but to me it's worth it. More info on the fees can be found here.

That's about it. Of course there's quite a bit going on behind the scenes but this should give you an idea of how Nodana does it and give you a basis for your own approach. Feel free to DM on Nostr with any questions or comments and I'll do my best to help.

Check out Phoenixd here: https://phoenix.acinq.co/server