Correct order payment logic
This commit is contained in:
parent
a8d4329e7d
commit
9f13cbf302
3 changed files with 15 additions and 7 deletions
|
@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.5.0]
|
||||
## [1.5.1]
|
||||
|
||||
### Changed
|
||||
|
||||
- Modified the process to mark paid orders to ensure only payments to the shop's wallet get marked as paid
|
||||
|
||||
## [1.5.0] - 2023-05-15
|
||||
|
||||
### Added
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: zgo-backend
|
||||
version: 1.5.0
|
||||
version: 1.5.1
|
||||
git: "https://git.vergara.tech/Vergara_Tech/zgo-backend"
|
||||
license: BOSL
|
||||
author: "Rene Vergara"
|
||||
|
|
|
@ -1307,8 +1307,7 @@ scanPayments config pipe = do
|
|||
let r = mkRegex ".*ZGo Order::([0-9a-fA-F]{24}).*"
|
||||
let k = filter (isRelevant r) txs
|
||||
let j = map (getOrderId r) k
|
||||
mapM_ (recordPayment p (c_dbName config)) j
|
||||
mapM_ (access p master (c_dbName config) . markOrderPaid) j
|
||||
mapM_ (recordPayment p (c_dbName config) z) j
|
||||
Left e -> print e
|
||||
getOrderId :: Text.Regex.Regex -> ZcashTx -> (String, Double)
|
||||
getOrderId re t = do
|
||||
|
@ -1316,8 +1315,8 @@ scanPayments config pipe = do
|
|||
if not (null reg)
|
||||
then (fst $ head reg ! 1, zamount t)
|
||||
else ("", 0)
|
||||
recordPayment :: Pipe -> T.Text -> (String, Double) -> IO ()
|
||||
recordPayment p dbName x = do
|
||||
recordPayment :: Pipe -> T.Text -> ZcashAddress -> (String, Double) -> IO ()
|
||||
recordPayment p dbName z x = do
|
||||
o <- access p master dbName $ findOrderById (fst x)
|
||||
let xOrder = o >>= (cast' . Doc)
|
||||
case xOrder of
|
||||
|
@ -1325,7 +1324,8 @@ scanPayments config pipe = do
|
|||
Just xO ->
|
||||
when
|
||||
(not (qpaid xO) &&
|
||||
qexternalInvoice xO /= "" && qtotalZec xO == snd x) $ do
|
||||
qexternalInvoice xO /= "" &&
|
||||
qtotalZec xO == snd x && addy z == qaddress xO) $ do
|
||||
let sReg = mkRegex "(.*)-([a-fA-f0-9]{24})"
|
||||
let sResult = matchAllText sReg (T.unpack $ qsession xO)
|
||||
if not (null sResult)
|
||||
|
@ -1344,6 +1344,7 @@ scanPayments config pipe = do
|
|||
(qaddress xO)
|
||||
(qtotal xO)
|
||||
(qtotalZec xO)
|
||||
liftIO $ access p master dbName $ markOrderPaid x
|
||||
"WC" -> do
|
||||
let wOwner = fst $ head sResult ! 2
|
||||
wooT <-
|
||||
|
@ -1371,6 +1372,7 @@ scanPayments config pipe = do
|
|||
(C.pack . T.unpack $ w_token wt)
|
||||
(C.pack . show $ qprice xO)
|
||||
(C.pack . show $ qtotalZec xO)
|
||||
liftIO $ access p master dbName $ markOrderPaid x
|
||||
else error
|
||||
"Couldn't parse externalInvoice for WooCommerce"
|
||||
_ -> putStrLn "Not an integration order"
|
||||
|
|
Loading…
Reference in a new issue