THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

How to Accept Bitcoin Payments in an Online Store

permalink THAMER
#bitcoin#e-commerce#payments#python

Keep prices in integer satoshis and calculate totals from a server-owned catalog. Never accept a browser-supplied price. The resulting order total is not payment evidence. Freeze the catalog version and order total before requesting an invoice.

Source code

Python · 15 lines
1def total(catalog, cart):
2    if not cart: raise ValueError("empty cart")
3    result = 0
4    for sku, qty in cart.items():
5        price = catalog[sku]
6        if type(qty) is not int or type(price) is not int or not 1 <= qty <= 100 or price <= 0:
7            raise ValueError("invalid item")
8        result += price * qty
9    return result
10
11if __name__ == "__main__":
12    assert total({"book": 1200}, {"book": 2}) == 2400
13    try: total({"book": 1200}, {"book": -1})
14    except ValueError: pass
15    else: raise AssertionError("negative quantity accepted")

Local validation

Run stage24-store-payments.py with Python 3. The example uses synthetic data and does not execute live wallet operations. Production deployment requires authenticated access, durable storage, trusted chain evidence and integration testing.

Related documentation

https://thamer.org/api

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects