A simple way to integrate cryptocurrency payments into your webshop
Add these lines to your HTML file:
<link rel="stylesheet" href="https://bitrequest.github.io/assets_styles_lib_bitrequest.css"/>
<script src="https://bitrequest.github.io/assets_js_lib_bitrequest_checkout.js"></script>
For assistance visit https://www.bitrequest.io/request-url/
Example implementation:
const payment = "nano";
const uoa = "usd";
const amount = 0.05;
const address = "nano_13kx8gfrse6q6z6djznkhj83cshih8akmjr3e3wmoabb38p6immo4mho8359";
const d = btoa(JSON.stringify({
"t": "Example request title",
"n": "Example request name",
"c": 0,
"pid": "paymentid"
}));
// Create request URL (optional: add &contactform=true for shipping details)
const request_url = "https://bitrequest.github.io/?payment=" + payment + "&uoa=" + uoa + "&amount=" + amount + "&address=" + address + "&d=" + d;
Add this HTML to trigger the payment request popup:
<a href="{$request_url}" class="br_checkout">Check out</a>
When the websocket in the bitrequest App detects an incoming transaction, the transaction data will be posted to the parent of the iframe.
post data:
{
"result": {
"txdata": {
"currencyname": "United States Dollar",
"requestid": "1826050966",
"cmcid": "1567",
"payment": "nano",
"ccsymbol": "nano",
"iscrypto": "true",
"amount": "0.026",
"receivedamount": "0.026",
"receivedcc": "0.026",
"status": "paid",
"txhash": "txhash",
"receiver": "nano_13kx8gfrse6q6z6djznkhj83cshih8akmjr3e3wmoabb38p6immo4mho8359",
"confirmations": "false",
"transactiontime": "1588660654471",
"pending": "polling"
},
"data": {
"t": "Example request title",
"n": "Example request name",
"c": 0,
"pid": "paymentid"
},
"meta": null
}
}
Handle the transaction data with a callback:
function result_callback(post_data) {
console.log(post_data);
// Add your custom handling logic here
}
💡 Check the repository for an example PHP backend template.
To handle Lightning Network payments, you'll need to set up a proxy server connected to your Lightning node.
Add these parameters to your data object:
const payment = "bitcoin";
const uoa = "usd";
const amount = 0.05;
const address = "lnurl"; // or btc-address for hybrid
const d = btoa(JSON.stringify({
"t": "Example request title",
"n": "Example request name",
"c": 1,
"pid": "{$random payment-id}", // required
"imp": "lnd", // or "eclair" / "c-lightning" / "lnbits"
"proxy": "{$proxy host}", // url or lnurl (required)
"pw": "{$your proxy api key}" // optional
}));
⚠️ Configure your callback URL in the proxy config file for backend updates.