Task
A bookshop needed to accept online orders and serve customers in different countries. Buyers must see the full price, including shipping and tax, before paying, while the shop must only sell copies it has in stock.
Existing orders must retain their terms when prices or exchange rates change. Cancelling must return books to stock and initiate a refund of any amount paid.
Solution
Separated the system into a Django REST API and a Vue interface. The API checks stock and creates an order in one transaction, locking the book rows. Each order stores a snapshot of titles, prices, currency, address and shipping costs at purchase time.
Payments use either Stripe Checkout or a separate demo provider. In Stripe mode, a signed webhook confirms payment. A payment arriving after cancellation leaves the order cancelled and triggers a refund. Each refund has its own record and idempotency key.
What was done
- Built a catalog with full-text search and typo tolerance
- Combined stock checks, order creation and book deduction in one transaction
- Calculated shipping by zone and weight, and tax by country, state or postal code
- Connected Stripe Checkout and a separate provider for test cards
- Stored prices, currency and address as an independent snapshot of every order
- Implemented cancellation with stock restoration, full refunds and partial refunds
- Translated the original shop and catalog into Russian, English, French and German
- Added currencies, shipping and tax to the admin, and exchange rate updates and refund retries to a scheduler
Result
Buyers can find a book, see the full cost, place an order and pay in one interface. Cancellation makes books available for sale again and starts the refund process for money already paid. Staff manage the catalog, orders and settings through the admin.
The embedded demo shows this journey using fictional books and addresses. Test payments, cancellation and two purchases of the same remaining stock share one local browser model.
Developer's note
What was hard
The main challenge was keeping orders, stock and payments consistent. An order may be cancelled while its buyer is paying; a successful payment must not restore a cancelled order or return its books twice. The API checks statuses under a lock and refunds late payments.
Repeated notifications and provider failures must not lead to duplicate refunds. Every refund has a separate record and a stable idempotency key sent to the provider. A scheduler retries unsuccessful attempts.
What came easy
A clear boundary between the API and the interface simplified catalog, cart and checkout work. Validation and calculations stay on the server, while Vue displays data and operation status. Screen changes do not require duplicating order rules.
Shipping, tax and currency settings fit the standard Django admin. Staff can maintain them without code changes, while existing orders retain their original terms.
Technologies
PythonDjango REST FrameworkVue 3TypeScriptPostgreSQLStripeDocker