DA10: Capstone: three automations for Sharma Textiles

Lesson 2 of 5 · reading 15–25 minutes; practice and project time is on the module page

Project 1: the payment workflow

🎯You'll be able to

Build the payment workflow end to end and prove it with all ten acceptance tests, including duplicates and recovery.

🏠The everyday picture

At a shop counter, the cashier takes payment, writes the bill, updates the register and tells the packer. The payment workflow does the same chain, automatically and in seconds.

📘What it really is

📝A worked example

A learner's test results:

Test Expected Result (illustrative)
1. Normal payment ₹2,400 1 invoice, deal won, IST time right ✓
2. Advance ₹70,800 of ₹2,36,000 Invoice part-paid; deal part-paid ✓
3. Same event × 3 in a row 1 invoice ✓
4. Same event × 5 at once 1 invoice ✗ first: 2 invoices
5. Fake signature 401; nothing created ✓
6. Gateway says failed No invoice ✓
7. Accounts 503 then OK Retried; 1 invoice ✓
8. Accounts 401 1 to 3 alerts naming the order and an owner ✗ first: alert had no order ID
9. CRM down after the reply Alert, then recovery completes it once ✓
10. Whole run Every invoice matches a captured payment ✓ after fixes

Test 4 failed because two parallel runs both read "not processed yet" before either wrote. Claiming the event with a database update that only one run can win fixed it. Test 8 showed the alert template read the order ID from the wrong node. After both fixes, all ten tests were rerun together and passed.

🌍Where it's used

📝Case scenario

In the demo, the reviewer asks what happens if the CRM is down when a payment arrives. The learner shows that the invoice step is idempotent, the CRM step retries with backoff, and if it still fails, the alert reaches Priya and the run can be retried without a second invoice. Because "processed" is recorded last, the retry completes the CRM update.

🖱️Try it

Build the payment workflow against the practice simulator and run the ten acceptance tests. Record each result, and rerun all of them after any fix.

⚠️Common mistakes

🛠️For your project

This is Project 1. Run node tests/payment.js from the starter kit and save the output as your test evidence.

✅Quick check

Why record the payment as processed only after every step succeeds?

Show the answer

So a retried run can finish the steps that failed, while the duplicate check still stops a full second run.

Which two checks stop a fake payment event from creating an invoice?

Show the answer

The signature check, and confirming the payment through the gateway's API.

← PreviousPlanning the capstone
ProLearners Assist