summaryrefslogtreecommitdiff
path: root/merchant-spec
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-08-08 18:33:12 +0200
committerFlorian Dold <florian@dold.me>2021-08-08 18:33:12 +0200
commite28129903772b99ad63613ba203c2d0dd20937c9 (patch)
tree7e1da146e3a1d619f4c01e960f7d4eca44538abf /merchant-spec
parentcf7e099367137923b2764f38fd32aa0fd1e7c2ab (diff)
downloaddocs-e28129903772b99ad63613ba203c2d0dd20937c9.tar.gz
docs-e28129903772b99ad63613ba203c2d0dd20937c9.tar.bz2
docs-e28129903772b99ad63613ba203c2d0dd20937c9.zip
comments
Diffstat (limited to 'merchant-spec')
-rw-r--r--merchant-spec/public-orders-get.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/merchant-spec/public-orders-get.ts b/merchant-spec/public-orders-get.ts
index d46475f1..20b893a6 100644
--- 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