To add a buy button to a website you need two things: a checkout page that takes the payment, and a way to open it from your site. There are four ways to do the second part: a plain link, an overlay button snippet, an inline embedded checkout, or a web component. The right one depends on what your site lets you paste in.
Below is the actual code for each method, what each one asks of your site, and a table of which website builders support which.
Pick a method by what your site lets you paste
| Method | What the buyer sees | What your site must allow |
|---|---|---|
| 1. Plain link | Your checkout opens as a full page | A button or text link with a URL field. Nothing else |
| 2. Overlay button | The checkout opens on top of your page | HTML and a script tag that run in the page itself |
| 3. Inline checkout | The checkout sits inside your page | An HTML or embed block, even one that shows code in a frame |
| 4. Web component | A button that opens the overlay | A script tag and support for custom elements |
The quick rule: if you can only set a URL, use the link. If you can paste HTML that runs in the page, use the overlay. If your builder puts custom code inside a frame, use the inline checkout. If you build with components, use the web component.
The examples use Chargedeck, a checkout page builder that runs on your own Stripe, PayPal or Square account. In each one, swap your-page-slug for the last part of your checkout link, or copy finished code from the embed code generator.
Method 1: a plain link, no code
Every hosted checkout page has a web address. Put that address on a button and you have a buy button. In HTML it is an ordinary link:
<a href="https://chargedeck.app/p/your-page-slug">Buy now</a>
In a website builder you never type that tag. You select a button, open its link setting and paste the address. The buyer taps it, lands on your branded checkout and pays. A hosted checkout link from any other provider works the same way.
This works on every builder and every plan, and the same address works in an email, a bio or a direct message, which is why it is also called a payment link. Choose it when you cannot add code, or when you want the simplest thing that works. Our guide to payment links, checkout pages and invoices explains how the three differ.
Method 2: an HTML buy now button that opens an overlay
An overlay keeps the buyer on your site: the checkout opens on top of the page they were reading. You need two lines. The first is the button. The second loads the script that makes it work.
<a data-chargedeck="your-page-slug">Buy now</a>
<script src="https://chargedeck.app/embed.js" defer></script>
- Paste both lines where the button should appear.
- Replace
your-page-slugwith your own. - For more buttons on the same page, repeat only the first line, each with its own slug. The script is needed once per page, so many sites put it in the footer.
- Publish, then click the button on the live page to test it.
Two details worth knowing. The defer attribute tells the browser to run the script after the page has been read, so it does not hold up your content. And if you have already styled your own button, add data-cdk-raw="1" to the link to keep your styling as it is.
Worked example: one product on a small site
Say you sell a $38 sewing pattern as a PDF from a three-page site. You build one checkout page, add the delivery link buyers get after paying, and paste those two lines under the product photo. Now the cost, for a month with 20 sales:
- Sales: 20 x $38 = $760.
- Card fees, using Stripe's standard US online rate of 2.9% + 30 cents as of November 2026: 2.9% of $760 is $22.04, plus 20 x $0.30 = $6.00, so $28.04. This goes to your processor, not to Chargedeck.
- Chargedeck Starter: $9.99 for the month. It is a flat fee and takes 0% of your sales.
- Total cost: $38.03, which leaves you $721.97.
This is arithmetic on made-up sales, not a forecast. The useful part is the shape: the card fee grows with sales, and the checkout fee stays at $9.99 whether you sell 20 patterns or 200.
A whole shelf, not one button
The same script can show a mini shop: your products as a grid, with a basket so buyers can add several items and pay once. Replace the button line with this one and use your storefront handle:
<div data-chargedeck-shop="your-handle"></div>
Method 3: embed the checkout inside the page
The inline method places the checkout itself in your page, inside a frame. It needs no script:
<iframe src="https://chargedeck.app/p/your-page-slug?embed=1" title="Secure checkout" allow="payment *" style="width:100%;max-width:460px;height:760px;border:0"></iframe>
There are two reasons to pick it. The first is design: on a sales page you may want the form visible without a click. The second is technical. Some builders, such as Google Sites and GoDaddy, show any custom code inside a frame of their own. An overlay button cannot open from inside that frame, so the inline checkout is the one to use there. Give it a space about 460 pixels wide and 760 pixels tall.
Method 4: the web component and the JavaScript call
If your site is built from components, or your builder accepts custom elements, there is a ready-made button element. Load its script, then use the tag wherever you want a button:
<script src="https://chargedeck.app/chargedeck-button.js" defer></script>
<chargedeck-button slug="your-page-slug" label="Buy now"></chargedeck-button>
Developers who want to open the checkout from their own code, for example at the end of a quiz or after a form, can call it from JavaScript once the Chargedeck script has loaded:
Chargedeck.buy('your-page-slug')
To run something after the buyer has paid, such as showing a thank-you message, set a function:
Chargedeck.onSuccess = function (order) { }
If your site has its own cart and you need to charge an exact total, the REST API creates a hosted checkout for that amount and confirms the order with a signed webhook.
Which method your website builder supports
Every builder below has a button you can link (Method 1). The table shows where that button lives and what the code route looks like.
| Builder | No-code route | Code route | Full steps |
|---|---|---|---|
| WordPress | Buttons block with the link | Custom HTML block for the overlay button, or the free plugin's block and shortcode | WordPress guide |
| Wix | Button with a web address link | The Chargedeck app for an overlay button, or Embed HTML for the inline checkout | Wix guide |
| Squarespace | Button block | Code Block for the overlay button. Squarespace limits JavaScript in Code Blocks to some plans | Squarespace guide |
| Webflow | Any button or link block | A data-chargedeck custom attribute plus the script in Footer code. Custom code needs a paid site plan or workspace | Webflow guide |
| GoDaddy | Button linked to a website URL | HTML section holding the inline checkout | GoDaddy guide |
| Framer | Button or text link | Embed set to HTML, holding the inline checkout | Framer guide |
| Carrd | Buttons element | Embed element set to Code for the overlay button, on Carrd's paid plans | Carrd guide |
| Ghost | Button card | HTML card with the overlay button | Ghost guide |
| Google Sites | Insert, Button | Embed code holding the inline checkout | Google Sites guide |
Writing your own HTML, or using a builder that is not listed? All four methods are open to you, and the HTML checkout guide keeps every snippet on one page.
Why card details never touch your page
In all four methods, the form where the buyer types their card number is not part of your website. With a link it is a separate page. With the overlay, the inline embed and the web component, the checkout runs in a frame served by Chargedeck, and the card details go from that frame to your payment processor. Your page holds a button or a frame and nothing more. It does not see, handle or store card numbers.
That is why a buy button suits even a simple static site: there is no payment code of your own to write or keep up to date. The money takes a direct path too. It goes straight into your own Stripe, PayPal or Square account, and that processor pays you out on its normal schedule. Chargedeck never holds it.
When a buy button is the wrong tool
A button and a checkout page cover one product, a service or a small range. Look elsewhere in these cases:
- A large catalog. If you need shipping rules, stock across many products and a full cart, use a store platform such as WooCommerce or your builder's own commerce plan.
- Subscriptions. Chargedeck does not do subscriptions or recurring billing.
- Tax handled for you. Chargedeck does not calculate sales tax or VAT, so set tax-inclusive prices or handle it in your accounting. If you want a platform to be the legal seller and deal with sales tax, a merchant of record such as Gumroad or Lemon Squeezy does that job.
- Discount codes. Chargedeck does not have them.
