Billable,
Billable',
BillableId,
requestExpiryPeriod,
)
( (^.),
makeLenses,
makePrisms,
)
newtype PaymentRequestId = PaymentRequestId UUID
makePrisms ''PaymentRequestId
newtype PaymentId = PaymentId UUID
makePrisms ''PaymentId
data NativeRequest currency where
Bip70Request :: B.PaymentRequest -> NativeRequest Satoshi
Zip321Request :: Z.PaymentRequest -> NativeRequest Zatoshi
\case
Bip70Request r -> Just r
_ -> Nothing
\case
Zip321Request r -> Just r
_ -> Nothing
data NativePayment currency where
BitcoinPayment :: B.Payment -> NativePayment Satoshi
ZcashPayment :: Z.Payment -> NativePayment Zatoshi
data PaymentOps currency m
= PaymentOps
{ newPaymentRequest ::
Billable currency -> -- billing information
C.Day -> -- payout date (billing date)
C.UTCTime -> -- timestamp of payment request creation
m (NativeRequest currency)
}
data PaymentRequest' (billable :: * -> *) currency
= PaymentRequest
{ _billable :: billable currency,
PaymentRequest currency = PaymentRequest' (Const BillableId) currency
type PaymentRequestDetail currency = PaymentRequest' (Billable' ProjectId UserId) currency
data SomePaymentRequest (b :: * -> *) = forall c. SomePaymentRequest (PaymentRequest' b c)
type SomePaymentRequestDetail = SomePaymentRequest (Billable' ProjectId UserId)
case _nativeRequest pr of
Bip70Request _ -> Currency' BTC
Zip321Request _ -> Currency' ZEC
let expiresAt = (req ^. createdAt) .+^ (req ^. (billable . requestExpiryPeriod))
in now >= expiresAt
data Payment' (paymentRequest :: * -> *) currency
= Payment
{ _paymentRequest :: paymentRequest currency,
PaymentRequestError
= AmountInvalid
| NoRecipients
type Payment currency = Payment' (Const PaymentRequestId) currency
type PaymentDetail currency = Payment' (PaymentRequest' (Billable' ProjectId UserId)) currency
(