4FDQGIXN3Z4J55DILCSI5EOLIIA7R5CADTGFMW5X7N7MH6JIMBWAC
AL37SVTCKRSG4HG2PCYK5Z7QSIZZH5JHH4Q2VLMXFAXSAQRFFG4QC
HMDM3B557TO5RYP2IGFFC2C2VN6HYZTDQ47CJY2O37BW55DSMFZAC
64C6AWH66FDKU6UE6Z6JPX2J2GBM2JOPTH2GL6LHKAIUBGNGDZ5AC
NEDDHXUK3GNFMOFO3KLU7NRIHCTYNWBT3D6HTKZAOXFDE6HMDZ6AC
Q5X5RYQLP5K7REYD6VLHOKC4W36ZELJYA45V6YFKTD5S6MPN3NDQC
IZEVQF627FA7VV25KJAWYWGGC35LZUUBBQRPN5ZAINTQLPEDRTEAC
DFOBMSAODB3NKW37B272ZXA2ML5HMIH3N3C4GT2DPEQS7ZFK4SNAC
2XQD6KKKD6QVHFHAEMVE3XXY7X2T7BLTLL7XIILZAXNJJH2YONUQC
Y3LIJ5USPMYBG7HKCIQBE7MWVGLQJPJSQD3KPZCTKXP22GOB535QC
SEWTRB6S5PO5MQBLCPVBD7XT2BDYNZUE2RO6Z2XENZRIOCN6OZJAC
JFOEOFGA4CQR2LW43IVQGDZSPVJAD4KDN2DZMZXGM2QDIUD7AVCAC
W35DDBFYF6Z4ZPCFEO5RPAONZLYCSNTXUSTS6FIUUVZHCI6Q7GHAC
BROSTG5KP3NUNLSYPVQID254TE47E5RKQAKLPIY7PGWETE6JNMTAC
ADMKQQGCGVSHHIMVQ4XFRDCG544SBJCYALSKZV45CQQBZ4ACUH2AC
HALRDT2F22DAQ54M334YSKD2XJCAXDXEZPDKGMOWKH7XELBAS6MAC
parsePaymentKey :: ByteString -> Maybe PaymentKey
parsePaymentKey bs = (PaymentKey . decodeUtf8) <$> decodeBase58Check bs
uid <- requireUserId
sid <- requireId "subscriptionId" SubscriptionId
rid <- requireId "paymentRequestId" PaymentRequestId
now <- liftIO $ C.getCurrentTime
requests <- snapEval $ findPayableRequests uid sid now
let prMay = fmap (view (_2 . paymentRequest)) . headMay $ filter ((==) rid . view _1) requests
maybe (snapError 404 $ "Outstanding payment request not found for id " <> tshow rid) pure prMay
pkBytes <- requireParam "paymentRequestKey"
pkey <- maybe
(snapError 400 $ "parameter paymentRequestKey is formatted incorrectly.") pure
(parsePaymentKey pkBytes)
prMay <- snapEval $ findPaymentRequest pkey
maybe (snapError 404 $ "Outstanding payment request not found for key " <> (view _PaymentKey pkey))
(pure . view paymentRequest)
prMay
maybeBytes <- getParam (encodeUtf8 name)
case maybeBytes of
Nothing -> snapError 400 $ "Parameter "<> tshow name <>" is required"
Just bytes -> either
(const . snapError 400 $ "Value of parameter "<> tshow name <>" could not be parsed to a valid value.")
pure
(parseOnly parser bytes)
bytes <- requireParam name
either
(const . snapError 400 $ "Value of parameter "<> tshow name <>" could not be parsed to a valid value.")
pure
(parseOnly parser bytes)