One script tag. Any website. Bitcoin payments.
Add a single
<script>
tag to your checkout page. The
pay.js
script reads the
data-*
attributes, renders a styled "Pay with Bitcoin" button, and handles the full checkout flow — no backend needed.
POST /api/v1/checkout_sessions
using your publishable key
Two modes: Cart checkout (pass amount + customer data from your own checkout) or Product button (create a product in your dashboard, reference it by slug — price is fetched automatically).
SatsRail supports two integration patterns depending on whether you have your own checkout process or want SatsRail to handle everything.
Your site already has a cart or checkout page where you collect customer details. Pass the order amount and any customer data to SatsRail — the hosted checkout page skips the info form and goes straight to the payment QR code.
<script src="https://satsrail.com/js/pay.js"
data-key="pk_live_..."
data-amount="2500"
data-currency="usd"
data-customer-email="buyer@example.com"
data-customer-name="Alice Smith"
data-success-url="https://mystore.com/thanks"
data-mode="iframe">
</script>
curl -X POST https://satsrail.com/api/v1/checkout_sessions \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"checkout_session": {
"amount_cents": 2500,
"currency": "usd",
"customer_email": "buyer@example.com",
"customer_name": "Alice Smith",
"metadata": { "order_id": "ORD-42", "plan": "pro" },
"success_url": "https://mystore.com/thanks",
"cancel_url": "https://mystore.com/cart"
}
}'
customer_email
is provided, the checkout page shows the payment QR immediately — no extra form step.
No checkout page on your site? Create a Product in your SatsRail dashboard and configure which customer fields to collect in your merchant Settings (email, name, phone, shipping address). SatsRail will show a form with the selected fields before the payment QR code.
<script src="https://satsrail.com/js/pay.js"
data-product="prod_abc123def456"
data-key="pk_live_..."
data-mode="iframe">
</script>
https://satsrail.com/pay/prod_abc123def456
Click the button below to see the full payment experience — from your website to the checkout page and back.
Your website
$25.00
Click the button to see the checkout flow
Instead of hardcoding amounts, create a Product in your SatsRail dashboard (with name and price), then reference it by slug. The button fetches the price automatically and displays it.
<script src="https://satsrail.com/js/pay.js"
data-product="prod_abc123def456"
data-key="pk_live_..."
data-mode="iframe">
</script>
The button will show
"Pay $25.00 with Bitcoin"
(or whatever the product price is). Override the label with
data-label
if needed.
Need something even simpler? Every product has a shareable payment link — a URL you can paste anywhere. No code, no API keys, no website required.
https://satsrail.com/pay/prod_abc123def456
Share via email, WhatsApp, social media, or print as a QR code. When someone opens the link, a checkout session is created automatically and they see the payment page with QR code and countdown timer.
| Attribute | Required | Description |
|---|---|---|
data-key |
Yes | Publishable key (pk_live_ or pk_test_) |
data-product |
No* | Product slug (e.g. prod_abc123). If set, amount and currency are fetched automatically from the product. |
data-amount |
No* | Amount in cents (e.g. 5000 = $50.00). Required if data-product is not set. |
data-currency |
No | Currency code, default "usd" |
data-success-url |
No | Redirect URL after payment |
data-cancel-url |
No | Redirect URL on cancel |
data-label |
No | Button text, default Pay with Bitcoin ⚡ |
data-mode |
No | iframe (embedded overlay), new_tab, or redirect. If omitted, uses your merchant Settings. |
data-customer-email |
No | Pre-fill customer email. Skips the info collection form on the checkout page. |
data-customer-name |
No | Pre-fill customer name. |
data-customer-phone |
No | Pre-fill customer phone number. |
data-customer-address |
No | Pre-fill customer shipping address. |
Hardcode the price directly in the script tag:
<!DOCTYPE html>
<html>
<body>
<h1>Buy Coffee Beans — $25.00</h1>
<!-- The button is rendered automatically -->
<script src="https://satsrail.com/js/pay.js"
data-key="pk_live_..."
data-amount="2500"
data-currency="usd"
data-success-url="https://mystore.com/thanks"
data-cancel-url="https://mystore.com/cart"
data-mode="iframe">
</script>
</body>
</html>
Reference a product — price is fetched automatically:
<!DOCTYPE html>
<html>
<body>
<h1>Buy Coffee Beans</h1>
<!-- Button shows "Pay $25.00 with Bitcoin" automatically -->
<script src="https://satsrail.com/js/pay.js"
data-product="prod_abc123def456"
data-key="pk_live_..."
data-mode="iframe">
</script>
</body>
</html>
The script auto-creates a
<button>
element with the
.satsrail-pay-btn
class and a built-in orange gradient style. Override it with your own CSS:
.satsrail-pay-btn {
background: #333 !important;
border-radius: 0 !important;
font-family: monospace !important;
}
<button> element — target .satsrail-pay-btn to restyle
When
data-mode="iframe"
is set (or your merchant checkout mode is set to Embedded), the checkout page opens in an overlay iframe on your page (500×700 on desktop, full-screen on mobile). The customer never leaves your site. No popup blockers.
If the checkout session fails to create (network error, invalid key, etc.), the button text changes to show the error message for 3 seconds, then reverts to the original label.
Paste the script tag in your theme's
header.php
or use a plugin like "Insert Headers and Footers." Then add the button HTML in any post or page using a Custom HTML block.
Add the script tag to your theme's
theme.liquid
layout. Use the button HTML in product descriptions or a custom page template.
Just paste both the script tag and button HTML into your page. That's it.
The
/api/v1/checkout_sessions
endpoint allows wildcard CORS origins, so the embed script works from any domain without additional configuration.
Copy the code above, swap in your publishable key, and you're live.
Get Your API Key →