Integrate BTCPay Server in Your Website for Bitcoin and Lightning Payments ⚡

💡 Introduction

Want to accept Bitcoin and Lightning payments on your website—for products, subscriptions, or donations? This guide shows you how to install and integrate BTCPay Server using an AWS EC2 instance, even if you run a self-hosted node.

You’ll learn to:

  • Deploy BTCPay Server on AWS
  • Enable Bitcoin + Lightning support
  • Set up a store and payment button
  • Handle API authentication and webhooks
  • Resolve inbound liquidity issues
  • Withdraw Lightning funds

🚀 Why Use BTCPay Server?

BTCPay Server is a free, open-source payment processor:

  • Supports Bitcoin (on-chain) and Lightning (off-chain)
  • Works without third parties (non-custodial)
  • Integrates with your node or an internal hot wallet
  • Ideal for privacy-conscious businesses and developers

Flyyer uses this method to accept Lightning payments.

🛠️ Install BTCPay Server on AWS EC2

Recommended Adjustments

Step 4: Storage Size

  • Use 500–600 GB, not 250 GB as some guides suggest
  • Bitcoin node size in 2024 exceeds 420 GB

Enable pruning if needed:

bash

CopyEdit

export BTCPAYGEN_ADDITIONAL_FRAGMENTS=”opt-more-memory;opt-save-storage”

Step 6: Security Groups

Open the following ports in your instance’s Security Group:

  • 8333 for Bitcoin
  • 9735 for Lightning

Pre-Setup Environment Variables

bash

CopyEdit

export BTCPAY_HOST=”your-btcpay.hostname.com”
export NBITCOIN_NETWORK=”mainnet”
export BTCPAYGEN_CRYPTO1=”btc”
export BTCPAYGEN_REVERSEPROXY=”nginx”
export BTCPAYGEN_LIGHTNING=”lnd”
export LIGHTNING_ALIAS=”your-lightning-node-alias”
export BTCPAYGEN_ADDITIONAL_FRAGMENTS=”opt-more-memory”
. ./btcpay-setup.sh -i

🏪 Configure Your Store

After blockchain sync (3–5 days):

  1. Create a store
  2. Enable Bitcoin and/or Lightning
  3. Allow invoice creation
  4. (Optional) Use a watch-only or hot wallet

🔄 Webhooks: Automate Actions After Payments

Go to: Store → Webhooks → Create New

Set to send all events (e.g. InvoiceSettled), and configure a POST URL in your backend to handle confirmations.

Sample payload:

json

CopyEdit

{
  “type”: “InvoiceSettled”,
  “invoiceId”: “123XYZ”,
  “storeId”: “ABCStore123”
}

🔐 Authenticate With BTCPay API

You need:

  • Private API key
  • Store ID

Use the following libraries:

API lets you fetch invoices, track payments, and link to user accounts.

💳 Create a Payment Button

Here’s a sample Bitcoin + Lightning payment form:

html

CopyEdit

<form method=”POST” action=”https://your-btcpay.hostname.com/api/v1/invoices”>
  <input type=”hidden” name=”storeId” value=”Store123″ />
  <input type=”hidden” name=”orderId” value=”Order001″ />
  <input type=”hidden” name=”price” value=”15″ />
  <input type=”hidden” name=”currency” value=”USD” />
  <input type=”hidden” name=”redirectURL” value=”https://yourdomain.com/thanks” />
  <button type=”submit”>Pay with Bitcoin ⚡</button>
</form>

ℹ️ Customer info (email, name) is collected via BTCPay’s hosted checkout page.

⚡ Fix Inbound Liquidity (Lightning Payments)

To receive Lightning payments:

  • Open channels with inbound liquidity
  • Share your public node info (under Lightning tab)
  • Connect to other nodes or use services like Bitrefill or Voltage

📌 Consider connecting your own node if liquidity exists there.

💰 Manage Your Lightning Wallet (RTL)

Go to: Server Settings → Services → Ride The Lightning

From here, you can:

  • Send/receive payments
  • Withdraw funds to another wallet
  • Monitor channels and balances

To withdraw, create an invoice from your mobile Lightning wallet and pay it using RTL.

🔗 Open a Lightning Channel With Flyyer

Steps via Ride The Lightning:

  1. Go to: Lightning → Peers
  2. Add this peer:
  • Set channel size (150k–2M sats)
  • Spend unconfirmed outputs ✅
  • Click Open Channel

✅ Summary

TaskStatus
EC2 Setup✅ Completed
Bitcoin + Lightning Enabled✅ Active
Store + Webhook Configured✅ Ready
API + Payment Button Added✅ Working
Inbound Liquidity Managed✅ Confirmed
Lightning Wallet Access✅ Enabled

🧭 Next Steps

  • Configure variables with @flyyer/variables for dynamic previews
  • Monitor invoices via API and webhooks
  • Deploy templates on Flyyer Community

📚 Resources

  • 🔗 BTCPay Docs
  • 📘 Flyyer Docs
  • 💬 Flyyer Discord
  • 🐦 Follow Flyyer on Twitter

✉️ Need Help?

Contact Flyyer or post questions in our Discord community.
 Start accepting Bitcoin & Lightning today.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *