{-# LANGUAGE MultiWayIf #-} -- CHANGE WITH CAUTION: This is a generated code file generated by https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator. {-# LANGUAGE OverloadedStrings #-} -- | Contains the types generated from the schema Token module StripeAPI.Types.Token where import qualified Control.Monad.Fail import qualified Data.Aeson import qualified Data.Aeson as Data.Aeson.Encoding.Internal import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.Internal import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.ByteString.Char8 import qualified Data.ByteString.Char8 as Data.ByteString.Internal import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text import qualified Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified GHC.Base import qualified GHC.Classes import qualified GHC.Int import qualified GHC.Show import qualified GHC.Types import qualified StripeAPI.Common import StripeAPI.TypeAlias import {-# SOURCE #-} StripeAPI.Types.BankAccount import {-# SOURCE #-} StripeAPI.Types.Card import qualified Prelude as GHC.Integer.Type import qualified Prelude as GHC.Maybe -- | Defines the object schema located at @components.schemas.token@ in the specification. -- -- Tokenization is the process Stripe uses to collect sensitive card or bank -- account details, or personally identifiable information (PII), directly from -- your customers in a secure manner. A token representing this information is -- returned to your server to use. You should use our -- [recommended payments integrations](https:\/\/stripe.com\/docs\/payments) to perform this process -- client-side. This ensures that no sensitive card data touches your server, -- and allows your integration to operate in a PCI-compliant way. -- -- If you cannot use client-side tokenization, you can also create tokens using -- the API with either your publishable or secret API key. Keep in mind that if -- your integration uses this method, you are responsible for any PCI compliance -- that may be required, and you must keep your secret API key safe. Unlike with -- client-side tokenization, your customer\'s information is not sent directly to -- Stripe, so we cannot determine how it is handled or stored. -- -- Tokens cannot be stored or used more than once. To store card or bank account -- information for later use, you can create [Customer](https:\/\/stripe.com\/docs\/api\#customers) -- objects or [Custom accounts](https:\/\/stripe.com\/docs\/api\#external_accounts). Note that -- [Radar](https:\/\/stripe.com\/docs\/radar), our integrated solution for automatic fraud protection, -- performs best with integrations that use client-side tokenization. -- -- Related guide: [Accept a payment](https:\/\/stripe.com\/docs\/payments\/accept-a-payment-charges\#web-create-token) data Token = Token { -- | bank_account: These bank accounts are payment methods on \`Customer\` objects. -- -- On the other hand [External Accounts](https:\/\/stripe.com\/docs\/api\#external_accounts) are transfer -- destinations on \`Account\` objects for [Custom accounts](https:\/\/stripe.com\/docs\/connect\/custom-accounts). -- They can be bank accounts or debit cards as well, and are documented in the links above. -- -- Related guide: [Bank Debits and Transfers](https:\/\/stripe.com\/docs\/payments\/bank-debits-transfers). tokenBankAccount :: (GHC.Maybe.Maybe BankAccount), -- | card: You can store multiple cards on a customer in order to charge the customer -- later. You can also store multiple debit cards on a recipient in order to -- transfer to those cards later. -- -- Related guide: [Card Payments with Sources](https:\/\/stripe.com\/docs\/sources\/cards). tokenCard :: (GHC.Maybe.Maybe Card), -- | client_ip: IP address of the client that generated the token. -- -- Constraints: -- -- * Maximum length of 5000 tokenClientIp :: (GHC.Maybe.Maybe (StripeAPI.Common.Nullable Data.Text.Internal.Text)), -- | created: Time at which the object was created. Measured in seconds since the Unix epoch. tokenCreated :: GHC.Types.Int, -- | id: Unique identifier for the object. -- -- Constraints: -- -- * Maximum length of 5000 tokenId :: Data.Text.Internal.Text, -- | livemode: Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode. tokenLivemode :: GHC.Types.Bool, -- | type: Type of the token: \`account\`, \`bank_account\`, \`card\`, or \`pii\`. -- -- Constraints: -- -- * Maximum length of 5000 tokenType :: Data.Text.Internal.Text, -- | used: Whether this token has already been used (tokens can be used only once). tokenUsed :: GHC.Types.Bool } deriving ( GHC.Show.Show, GHC.Classes.Eq ) instance Data.Aeson.Types.ToJSON.ToJSON Token where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("bank_account" Data.Aeson.Types.ToJSON..=)) (tokenBankAccount obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("card" Data.Aeson.Types.ToJSON..=)) (tokenCard obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("client_ip" Data.Aeson.Types.ToJSON..=)) (tokenClientIp obj) : ["created" Data.Aeson.Types.ToJSON..= tokenCreated obj] : ["id" Data.Aeson.Types.ToJSON..= tokenId obj] : ["livemode" Data.Aeson.Types.ToJSON..= tokenLivemode obj] : ["type" Data.Aeson.Types.ToJSON..= tokenType obj] : ["used" Data.Aeson.Types.ToJSON..= tokenUsed obj] : ["object" Data.Aeson.Types.ToJSON..= Data.Aeson.Types.Internal.String "token"] : GHC.Base.mempty)) toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("bank_account" Data.Aeson.Types.ToJSON..=)) (tokenBankAccount obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("card" Data.Aeson.Types.ToJSON..=)) (tokenCard obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("client_ip" Data.Aeson.Types.ToJSON..=)) (tokenClientIp obj) : ["created" Data.Aeson.Types.ToJSON..= tokenCreated obj] : ["id" Data.Aeson.Types.ToJSON..= tokenId obj] : ["livemode" Data.Aeson.Types.ToJSON..= tokenLivemode obj] : ["type" Data.Aeson.Types.ToJSON..= tokenType obj] : ["used" Data.Aeson.Types.ToJSON..= tokenUsed obj] : ["object" Data.Aeson.Types.ToJSON..= Data.Aeson.Types.Internal.String "token"] : GHC.Base.mempty))) instance Data.Aeson.Types.FromJSON.FromJSON Token where parseJSON = Data.Aeson.Types.FromJSON.withObject "Token" (\obj -> (((((((GHC.Base.pure Token GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "bank_account")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "card")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "client_ip")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "created")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "livemode")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "type")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "used")) -- | Create a new 'Token' with all required fields. mkToken :: -- | 'tokenCreated' GHC.Types.Int -> -- | 'tokenId' Data.Text.Internal.Text -> -- | 'tokenLivemode' GHC.Types.Bool -> -- | 'tokenType' Data.Text.Internal.Text -> -- | 'tokenUsed' GHC.Types.Bool -> Token mkToken tokenCreated tokenId tokenLivemode tokenType tokenUsed = Token { tokenBankAccount = GHC.Maybe.Nothing, tokenCard = GHC.Maybe.Nothing, tokenClientIp = GHC.Maybe.Nothing, tokenCreated = tokenCreated, tokenId = tokenId, tokenLivemode = tokenLivemode, tokenType = tokenType, tokenUsed = tokenUsed }