htmlhost.co
Back to Guides
Platform Features

How to Accept Payments on Your Website

Sell a product, take a booking deposit or accept donations from any htmlhost site with Stripe. You save your keys once, choose the price, and ask AI to build the page. Your secret key never reaches a visitor, and the checkout uses the price you approved.

What you need

  • A site on Pro. Site keys and secure calls are part of Pro: up to 50 keys and 20 secure calls per site.
  • A Stripe account. In your Stripe Dashboard, under Developers → API keys, you'll find a publishable key and a secret key.
  • A product and price in Stripe. Create them in the Stripe Dashboard and copy the price ID (it starts with price_).

How it stays safe

Everything in a web page can be read by anyone who visits it, so a page can't hold a secret key. On htmlhost a page never has to. The steps that need your secret key (starting a checkout and confirming it was paid) are secure calls: htmlhost makes them for your page, using exactly the address, key and price you set. A visitor can only trigger those calls, and only fill in the fields you chose.

Step 1: Save your secret key

  1. Open your dashboard, open the site and select Keys, then Add key.
  2. Add your Stripe secret key as STRIPE_SECRET_KEY. It's saved as Secret: after saving, only its last four characters are shown.

Start with your Stripe test key (sk_test_…). You'll swap in the live one at the end.

Step 2: Ask AI for the checkout and pages

Open the site in AI Edit, or ask your connected AI tool to work on it. Give it your Stripe price ID and the addresses of your shop and thank-you pages. Use a test-mode price with your test key. Replace the bracketed details in this prompt:

“Add Stripe Checkout using my saved STRIPE_SECRET_KEY and price [my Stripe price ID]. Add a Buy now button, return successful checkouts to [my thank-you page URL], and cancelled checkouts to [my shop page URL]. Reuse suitable secure calls or prepare start-checkout and confirm-payment. Keep the price fixed. On the thank-you page, verify the checkout with Stripe and check its paid status, amount and currency before showing “Payment received”.”

AI prepares two calls: one starts checkout, and one checks the result with Stripe. AI Edit and connected tools can create these after you confirm the service and key. You can also ask for definitions to review and add yourself, using the next step.

Step 3: Review the calls, or paste their definitions

If your AI tool cannot create calls directly, or you prefer to add them in the dashboard, send:

“Give me start-checkout and confirm-payment as separate htmlhost secure-call JSON definitions, following https://htmlhost.co/agents.md. Use STRIPE_SECRET_KEY by name, never its value. Return each definition as one JSON object without Markdown code fences, ready for Paste a definition.”
  1. Open Dashboard → your site → Keys → Secure calls and select Paste a definition.
  2. Paste the first definition and select Review call. Check that it goes to Stripe, uses STRIPE_SECRET_KEY, and has your fixed price ID and page addresses.
  3. Select Edit details if you need a correction, review again, then select Add call. Repeat for the second definition.
  4. Tell AI the calls are saved and ask it to finish the pages using those call names. If AI already created the calls, use those existing calls instead of adding duplicates.

If a call shows Needs key, add that key above. If it is Off, select its switch, check the review and choose Enable call. Enabled means switched on, not tested. See the full paste-and-review walkthrough for help.

Step 4: Publish, test, then go live

  1. Publish the site. Secure calls run only on the published site, not in the editor preview.
  2. Pay with Stripe's test card 4242 4242 4242 4242 (any future date and any CVC) and check that the thanks page confirms it.
  3. Back in Keys, edit STRIPE_SECRET_KEY and paste your live key. Create the price in live mode too and update its ID in the call. Nothing else changes.

Each secure call shows its run count and the service's last status. These help troubleshoot requests; they are not proof of payment. Check completed payments in your Stripe Dashboard.

Prefer a template?

In Keys → Secure calls → Use a template, choose Stripe: start a checkout or Stripe: confirm a payment. The template fills the form. For checkout, replace price_REPLACE_ME with your price ID and set your success and cancellation page addresses before adding the call. Create manually opens a blank form. These are optional alternatives to asking AI for a definition.

Using another payment provider

The same approach can work with another provider whose public HTTPS API fits secure calls. Ask AI to create the call. If your tool cannot create it directly, choose Paste a definition to review its JSON, or Create manually to configure it yourself.

Related

Frequently asked questions

Can a visitor change the price?

No. You set the Stripe price in the secure call. The page only sends what you marked as a visitor's field, so the price stays exactly as you set it.

Will my secret key be visible in the page?

No. A secret key is never written into a page and never sent to a visitor's browser. htmlhost uses it when it makes the call for your page.

Does htmlhost take a cut of my sales?

No. Payments go straight to your own Stripe account. Only Stripe's own fees apply.

Does it work on my custom domain?

Yes, on your site's htmlhost.co address and every custom domain connected to it.

Can I test before taking real money?

Yes. Save your Stripe test keys first, publish, and pay with Stripe's test card 4242 4242 4242 4242. When everything works, replace the secret key with its live version and update the call with the matching live-mode price ID.

Can I use another payment provider?

Other providers can work if their public HTTPS API fits secure calls. Ask AI to check the service and prepare a definition, then use “Paste a definition” to review and add it. Connected tools can also create the call after confirmation.

Why doesn't payment work in the editor preview?

Secure calls only run on your published site. Publish, then test on the live page.

Start taking payments

Open your site in the dashboard, then Keys.

Go to your sites