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
<*> (field >>= (either fail pure . runGet decodeMessage))
<*> (toThyme <$> field)
<*> (toThyme <$> field)
PaymentRequest <$> fmap B.SubscriptionId field
<*> ((either fail pure . runGet decodeMessage) =<< field)
<*> fmap PaymentKey field
<*> fmap toThyme field
<*> fmap toThyme field
storeEvent (CreatePaymentRequest uid req) =
Just $ storeEventJSON uid "create_payment_request" (paymentRequestJSON req)
storeEvent (CreatePaymentRequest req) =
Just $ storeEventJSON Nothing "create_payment_request" (paymentRequestJSON req)
headMay <$> pquery paymentRequestParser
"SELECT subscription_id, request_data, request_time, billing_date \
headMay <$> pquery ((,) <$> idParser PaymentRequestId <*> paymentRequestParser)
"SELECT id, subscription_id, request_data, url_key, request_time, billing_date \
import qualified Network.Bippy.Proto as P
import Network.Bippy.Types (expiryTime, getExpires, getPaymentDetails)
import qualified Network.Bippy.Proto as P
import Network.Bippy.Types (expiryTime, getExpires,
getPaymentDetails)
{ memoGen :: Subscription' UserId Billable -> m (Maybe Text) -- ^ generator user memo
, uriGen :: Subscription' UserId Billable -> m (Maybe URI) -- ^ generator for payment response URL
, payloadGen :: Subscription' UserId Billable -> m (Maybe ByteString) -- ^ generator for merchant payload
{ -- | generator for user memo
memoGen :: Subscription' UserId Billable -> T.Day -> C.UTCTime -> m (Maybe Text)
-- | generator for payment response URL
, uriGen :: PaymentKey -> m (Maybe URI)
-- | generator for merchant payload
, payloadGen :: Subscription' UserId Billable -> T.Day -> C.UTCTime -> m (Maybe ByteString)
memo <- memoGen ops sub
uri <- uriGen ops sub
payload <- payloadGen ops sub
-- TODO: maybe
pkey <- PaymentKey . decodeUtf8 . encodeBase58Check <$> getRandomBytes 32
memo <- memoGen ops sub bday now
uri <- uriGen ops pkey
payload <- payloadGen ops sub bday now
import Control.Lens (view)
import Data.Thyme.Clock as C
import Network.Bippy.Proto as P
import Control.Lens (view, _1, _2)
import Data.ProtocolBuffers (decodeMessage)
import Data.Serialize.Get (runGetLazy)
import Data.Thyme.Clock as C
import qualified Network.Bippy.Proto as P
getPaymentRequestHandler = do
pkBytes <- requireParam "paymentRequestKey"
pkey <- maybe
(snapError 400 $ "parameter paymentRequestKey is formatted incorrectly.") pure
getPaymentRequestHandler =
view (_2 . paymentRequest) <$> getPaymentRequestHandler'
paymentResponseHandler :: S.Handler App App PaymentId
paymentResponseHandler = do
requestBody <- readRequestBody 4096
preq <- getPaymentRequestHandler'
pmnt <- either
(\msg -> snapError 400 $ "Could not decode payment response: " <> tshow msg)
pure
(runGetLazy decodeMessage requestBody)
now <- liftIO $ C.getCurrentTime
snapEval . liftdb . CreatePayment $ Payment (view _1 preq) pmnt now
getPaymentRequestHandler' :: S.Handler App App (PaymentRequestId, PaymentRequest)
getPaymentRequestHandler' = do
pkBytes <- requireParam "paymentRequestKey"
pkey <- maybe
(snapError 400 $ "parameter paymentRequestKey is formatted incorrectly.") pure
(pure . view paymentRequest)
prMay
pure prMay