commit e28129903772b99ad63613ba203c2d0dd20937c9
parent cf7e099367137923b2764f38fd32aa0fd1e7c2ab
Author: Florian Dold <florian@dold.me>
Date: Sun, 8 Aug 2021 18:33:12 +0200
comments
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/merchant-spec/public-orders-get.ts b/merchant-spec/public-orders-get.ts
@@ -16,6 +16,7 @@ interface MerchantOrderInfo {
lastPaidSessionId?: string;
}
+// Data from the client's request to /orders/{id}
interface Req {
orderId: string;
contractHash?: string;
@@ -24,15 +25,19 @@ interface Req {
accept: "json" | "html";
}
+// (Abstract) response to /orders/{id}
interface Resp {
httpStatus: string;
+ // Schema type of the response
responseType: string;
// Additional details about response
response?: any;
}
+// Abstracted merchant database
type MerchantOrderStore = { [orderId: string]: MerchantOrderInfo };
+// Logic for /orders/{id}
function handlePublicOrdersGet(mos: MerchantOrderStore, req: Req): Resp {
const ord = mos[req.orderId];
if (!ord) {
@@ -132,6 +137,7 @@ function handlePublicOrdersGet(mos: MerchantOrderStore, req: Req): Resp {
};
}
+// Helper to find an already paid order ID.
function findAlreadyPaid(
mos: MerchantOrderStore,
sessionId: string