Billable,
amount,
messageText,
project,
)
data PaymentsConfig
= PaymentsConfig
{ _minAmt :: Zatoshi
}
makeLenses ''PaymentsConfig
type MemoGen m = Billable Zatoshi -> C.Day -> C.UTCTime -> AccountId -> m (Maybe Memo)
PT.PaymentOps
{ PT.newPaymentRequest = ((fmap PT.Zip321Request .) .) . zip321PaymentRequest cfg memoGen
}
-- TODO: Return a richer type that can include per-item uniqueness that can
-- be used for tracking payments. A payment request, though it's a request for
-- a single transaction, is really a request for multiple payments that we need
-- to be able to verify individually since they'll be independent notes.
--
-- However, this doesn't really become important until we start generating addresses
-- from Zcash IVKs, so it's not essential for right now.
do
let payoutTime = C.mkUTCTime billingDay (fromInteger 0)
billTotal = billable ^. amount
payoutFractions <- lift $ getProjectPayoutFractions payoutTime (billable ^. project)
payouts <- getPayouts payoutTime ZEC (MinPayout $ cfg ^. minAmt) billTotal payoutFractions
itemsMay <- lift $ nonEmpty <$> traverse toPaymentItem (assocs payouts)
PaymentRequest <$> tryJust PT.NoRecipients itemsMay
where
do
memo <- memoGen billable billingDay billTime aid
pure $
PaymentItem
{ _address = a,
_label = Nothing,
_message = billable ^. messageText,
_amount = z,
_memo = memo,
_other = []
}
(