Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
btcpay
Advanced tools
Readme
npm i btcpay
$ node -p "require('btcpay').crypto.generate_keypair().getPrivate('hex')"
XXXXXXXXXXXXXXXXXXXXX
Store the printed value in a safe place, e.g. environment variables
After generating your private key, you have to pair your client with your BTCPay store:
# Replace the BTCPAY_XXX envirnoment variables with your values and run:
$ [space] BTCPAY_URL=https://mydomain.com/ BTCPAY_KEY=... BTCPAY_PAIRCODE=... node -e "const btcpay=require('btcpay'); new btcpay.BTCPayClient(process.env.BTCPAY_URL, btcpay.crypto.load_keypair(Buffer.from(process.env.BTCPAY_KEY, 'hex'))).pair_client(process.env.BTCPAY_PAIRCODE).then(console.log).catch(console.error)"
# (prepend the line with a space to prevent BTCPAY_KEY from being saved to your bash history)
>>> { merchant: 'XXXXXX' }
Store the value of "merchant" in a safe place, e.g. environment variables
After pairing your client to the store, you can recreate the client as needed and use it in your code
const btcpay = require('btcpay')
const keypair = btcpay.crypto.load_keypair(new Buffer.from(<PRIVATEKEY>, 'hex'))
// Recreate client
const client = new btcpay.BTCPayClient(<BTCPAYURL>, keypair, {merchant: <MERCHANT>})
Fetches current rates from BitcoinAverage (using your BTCPayServer)
client.get_rates(['BTC_USD'], <STOREID>)
.then(rates => console.log(rates))
.catch(err => console.log(err))
The first argument accepts a comma-separated list of currency pair.
See BitPay Invoice API documentation
client.create_invoice({price: 20, currency: 'USD'})
.then(invoice => console.log(invoice.url))
.catch(err => console.log(err))
client.get_invoice(<invoice-id>)
.then(invoice => console.log(invoice.status))
.catch(err => console.log(err))
FAQs
A nodejs client implementation for BTCPay
The npm package btcpay receives a total of 171 weekly downloads. As such, btcpay popularity was classified as not popular.
We found that btcpay demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.