From cb9b5cd411c6f497c85dffcd3e9af4b45b661189 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Tue, 13 Dec 2022 14:01:51 -0600 Subject: [PATCH] Add WC Order Key to payment flow --- src/ZGoBackend.hs | 6 ++++-- test/Spec.hs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ZGoBackend.hs b/src/ZGoBackend.hs index 7d6f002..4261731 100644 --- a/src/ZGoBackend.hs +++ b/src/ZGoBackend.hs @@ -678,6 +678,7 @@ routes pipe config = do curr <- param "currency" amount <- param "amount" sUrl <- param "siteurl" + orderKey <- param "orderkey" res <- liftAndCatchIO $ run (findWooToken (read oid)) let c = cast' . Doc =<< res case c of @@ -733,7 +734,8 @@ routes pipe config = do amount ] False - (T.concat [T.pack sUrl, "-", ordId]) + (T.concat + [T.pack sUrl, "-", ordId, "-", orderKey]) "" newId <- liftAndCatchIO $ run (insertWooOrder newOrder) status ok200 @@ -1138,7 +1140,7 @@ scanPayments config pipe = do case wT of Nothing -> error "Failed to read WooCommerce token" Just wt -> do - let iReg = mkRegex "(.*)-(.*)" + let iReg = mkRegex "(.*)-(.*)-.*" let iResult = matchAllText iReg diff --git a/test/Spec.hs b/test/Spec.hs index f2c4494..6e6a943 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -304,6 +304,7 @@ main = do , ("currency", Just "usd") , ("amount", Just "100.0") , ("date", Just "2022-12-01") + , ("orderkey", Just "wc_order_m7qiJ1dNrGDYE") ] res <- httpJSON req getResponseStatus (res :: Response A.Value) `shouldBe` ok200