Question 1 Report
The canteen ordering program stores each order in a queue before it is sent to the kitchen. During a busy lunch break, a network connection fails after the customer has paid but before the displayed confirmation appears. The customer presses the Pay button again. The programmer must make the program robust so that it does not create duplicate orders or lose a paid order. A transaction log is available, and each payment provider message includes a unique payment reference.
(a) Explain why the payment reference should be checked before a new order is added. [2]
(b) When the network fails, describe one message that should be displayed to the customer. [1]
(c) Explain one use of a transaction log during recovery. [2]
(d) When the program receives the same payment reference twice, state what it should do. [1]
(a) Check whether the unique payment reference has already been processed before adding an order. This prevents a second request from creating a duplicate order or causing a duplicate charge. [2]
(b) A suitable message is: Payment is being checked. Do not submit again. [1]
(c) A transaction log records the stage or status of each order. During recovery, the program can use it to identify a paid order that was not completed and recover it rather than losing it or creating it twice. [2]
(d) If the same payment reference arrives twice, do not create another order. Ignore or flag the duplicate request. [1]
Everything you need to excel in your exams