OpenInvoice supports cryptocurrency payments via the XRP Ledger (XRPL). This allows customers to pay invoices using XRP.
# CoinGecko (for exchange rates)
COINGECKO_API_KEY=... # Optional
COINGECKO_API_URL=https://api.coingecko.com/api/v3
# Crypto Payment Settings
CRYPTO_TEST_MODE=false
CRYPTO_USE_TESTNET=false
Crypto payments are enabled by default. Configure in organization settings if needed.
When customer selects crypto payment:
import { Client, Wallet } from 'xrpl';
const client = new Client('wss://s1.ripple.com');
await client.connect();
// Generate address (handled internally)
const address = generatePaymentAddress();
// WebSocket connection to XRPL
const client = new Client('wss://s1.ripple.com');
await client.connect();
// Monitor for payments
client.on('transaction', (tx) => {
if (tx.TransactionType === 'Payment') {
// Verify payment
// Update invoice status
}
});
const response = await fetch(
`https://api.coingecko.com/api/v3/simple/price?ids=xrp&vs_currencies=usd`,
{
headers: {
'x-cg-api-key': process.env.COINGECKO_API_KEY,
},
}
);
const rate = response.data.xrp.usd;
Use XRPL testnet for testing:
CRYPTO_USE_TESTNET=true
Testnet features:
Simulate payments without blockchain:
CRYPTO_TEST_MODE=true