mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-10 20:08:34 +00:00
core: refactor badge types (#7387)
Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
co-authored by
Evgeny @ SimpleX Chat
parent
78332d0c73
commit
1c7bc1aed4
@@ -5,6 +5,7 @@
|
||||
module Simplex.Chat.PaymentService.Types
|
||||
( CurrencyAmount (..),
|
||||
InvoiceId (..),
|
||||
PaymentId (..),
|
||||
PaymentProvider (..),
|
||||
CardProvider (..),
|
||||
CryptoCurrency (..),
|
||||
@@ -12,8 +13,13 @@ module Simplex.Chat.PaymentService.Types
|
||||
ServicePaymentDestination (..),
|
||||
InvoiceStatus (..),
|
||||
StoredInvoice (..),
|
||||
StoredPayment (..),
|
||||
PaymentFunding (..),
|
||||
PaymentTerm (..),
|
||||
PaymentStatus (..),
|
||||
) where
|
||||
|
||||
import Data.ByteString.Char8 (ByteString)
|
||||
import Data.Text (Text)
|
||||
import Data.Time.Clock (UTCTime)
|
||||
import Data.Word (Word32)
|
||||
@@ -26,6 +32,10 @@ newtype CurrencyAmount = CurrencyAmount Word32
|
||||
newtype InvoiceId = InvoiceId Text
|
||||
deriving newtype (Eq, Show)
|
||||
|
||||
-- confirmed
|
||||
newtype PaymentId = PaymentId Text
|
||||
deriving newtype (Eq, Show)
|
||||
|
||||
-- confirmed
|
||||
data PaymentProvider = PPApple | PPGoogle | PPStripe | PPCrypto | PPCode | PPReceipt
|
||||
deriving (Eq, Show)
|
||||
@@ -72,3 +82,53 @@ data StoredInvoice = StoredInvoice
|
||||
updatedAt :: UTCTime
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
-- to review
|
||||
data StoredPayment = StoredPayment
|
||||
{ paymentId :: PaymentId,
|
||||
funding :: PaymentFunding,
|
||||
term :: PaymentTerm,
|
||||
status :: PaymentStatus,
|
||||
createdAt :: UTCTime,
|
||||
updatedAt :: UTCTime
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
-- to review
|
||||
data PaymentFunding
|
||||
= PFInvoice
|
||||
{ invoiceId :: InvoiceId,
|
||||
providerRef :: Text,
|
||||
amount :: CurrencyAmount,
|
||||
currency :: Text,
|
||||
receiptCode :: Maybe Text -- client; the service holds its hash
|
||||
}
|
||||
| PFApple
|
||||
{ providerRef :: Text,
|
||||
amount :: CurrencyAmount,
|
||||
currency :: Text,
|
||||
evidence :: Maybe ByteString -- client only
|
||||
}
|
||||
| PFGoogle
|
||||
{ providerRef :: Text,
|
||||
amount :: CurrencyAmount,
|
||||
currency :: Text,
|
||||
evidence :: Maybe ByteString -- client only
|
||||
}
|
||||
| PFCode
|
||||
| PFReceipt
|
||||
deriving (Show)
|
||||
|
||||
-- to review
|
||||
data PaymentTerm
|
||||
= PTOneOff
|
||||
| PTSubscription
|
||||
{ renewsAt :: UTCTime,
|
||||
graceUntil :: Maybe UTCTime,
|
||||
cancelled :: Bool
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
-- to review
|
||||
data PaymentStatus = PSPending | PSSettled | PSFailed {exception :: Text}
|
||||
deriving (Show)
|
||||
|
||||
Reference in New Issue
Block a user