Designing Bitcoin SDKs for E-Commerce Platforms
Research status: Theoretical SDK design. Examples are illustrative and have not been built or tested against the live engine.
Commerce contract
A commerce SDK should translate a server-authorized order into a payment intent, not accept a price or destination chosen by the browser. Snapshot the order currency, integer satoshi quote, expiry, catalog version and merchant wallet scope. If pricing starts in fiat, the application supplies a timestamped exchange quote and rounding rule; the engine is not a pricing oracle. Persist the order before registering WATCH. Store the returned watch identifier and address against the order. An uncertain registration response requires reconciliation, not blind creation of another invoice.
Conceptual TypeScript interface
interface CheckoutSDK {
createIntent(orderId: string, operationId: string): Promise<PaymentIntent>;
reconcile(intentId: string): Promise<SettlementEvidence>;
}These are application abstractions, not engine endpoints. Resolve the amount and wallet on the server. Keep order state, payment evidence and fulfillment state independent. A WATCH observation is not necessarily confirmed settlement. Check transaction evidence and apply a merchant-defined confirmation threshold. An expired invoice can still receive Bitcoin; route late payments to review instead of silently discarding them.
Durable fulfillment
Allocate each verified output once using network, transaction ID and output index. If the available response lacks output detail, use an authorized Bitcoin evidence source or hold the payment for review. Commit the accepted payment and an outbox event in one database transaction. A fulfillment worker uses the order identifier as its deduplication key. Reorganizations require explicit accounting corrections and a merchant risk policy. Refunds are separate authorized sends under the wallet's birth fee law; never assume the original amount can be returned without costs.
Acceptance plan
Simulate stale quotes, duplicate checkout requests, late deposits, partial payments, repeated worker delivery and reorganization. Later register a Testnet invoice and pay from a separate wallet; compare the expected amount, actual output and confirmation evidence. Restart the worker and verify exactly one entitlement is granted. Do not describe Testnet purchases as commercial revenue.
Primary reference
https://thamer.org/api
Related reading
https://thamer.org/docs/wab-sdk-api-engine-application-boundaries
https://thamer.org/docs/wab-sdk-authentication-credential-management
https://thamer.org/docs/wab-sdk-watch-payment-monitoring
https://thamer.org/docs/wab-sdk-invoice-abstractions
https://thamer.org/docs/wab-sdk-confirmation-settlement-states
https://thamer.org/docs/wab-sdk-payment-reconciliation
https://thamer.org/docs/wab-sdk-immutable-fee-policy
