From f0786753bb0f3265f61eaf96a813e1ba4dbfd290 Mon Sep 17 00:00:00 2001 From: Jonatan Witoszek Date: Mon, 7 Aug 2023 17:36:11 +0200 Subject: [PATCH] Use action from Saleor --- main.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index 9245e55..9f9ae6d 100644 --- a/main.ts +++ b/main.ts @@ -124,9 +124,10 @@ const routes = [ console.log("transaction initialize", json); console.log("headers", req.headers); const amount = json.action.amount; + const action = json.action.actionType ?? "CHARGE"; return Response.OK({ pspReference: "initialize-test", - result: json?.data?.final ? "CHARGE_SUCCESS" : "CHARGE_REQUEST", + result: json?.data?.final ? `${action}_SUCCESS` : `${action}_REQUEST`, amount, }); }), @@ -135,9 +136,10 @@ const routes = [ console.log("transaction process", json); console.log("headers", req.headers); const amount = json.action.amount; + const action = json.action.actionType ?? "CHARGE"; return Response.OK({ pspReference: "initialize-test", - result: json?.data?.final ? "CHARGE_SUCCESS" : "CHARGE_REQUEST", + result: json?.data?.final ? `${action}_SUCCESS` : `${action}_REQUEST`, amount, }); }),