{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
module Web.Stripe.Charge
(
CreateCharge
, createCharge
, GetCharge
, getCharge
, GetCharges
, getCharges
, UpdateCharge
, updateCharge
, CaptureCharge
, captureCharge
, Amount (..)
, ApplicationFeeAmount(..)
, CardNumber (..)
, Capture (..)
, Charge (..)
, ChargeId (..)
, Created (..)
, Currency (..)
, CustomerId (..)
, Customer (..)
, CVC (..)
, Description (..)
, Email (..)
, EndingBefore (..)
, ExpandParams (..)
, ExpMonth (..)
, ExpYear (..)
, Limit (..)
, MetaData (..)
, NewCard (..)
, ReceiptEmail (..)
, StartingAfter (..)
, StatementDescription (..)
, StripeList (..)
, TokenId (..)
) where
import Web.Stripe.StripeRequest (Method (GET, POST),
StripeHasParam, ToStripeParam(..),
StripeRequest (..), StripeReturn,
mkStripeRequest)
import Web.Stripe.Util ((</>))
import Web.Stripe.Types (Amount(..), ApplicationFeeAmount(..),
CVC (..),
Capture(..),
CardNumber (..), Charge (..),
ChargeId (..), Created(..),
Currency (..), Customer(..),
CustomerId (..), Description(..),
EndingBefore(..), ExpMonth (..),
ExpYear (..), Limit(..), MetaData(..),
NewCard(..), Email (..),
StartingAfter(..),
ReceiptEmail(..),
StatementDescription(..),
ExpandParams(..),
StripeList (..), TokenId (..))
import Web.Stripe.Types.Util (getChargeId)
createCharge
:: Amount
-> Currency
-> StripeRequest CreateCharge
createCharge
amount
currency = request
where request = mkStripeRequest POST url params
url = "charges"
params = toStripeParam amount $
toStripeParam currency $
[]
data CreateCharge
type instance StripeReturn CreateCharge = Charge
instance StripeHasParam CreateCharge ExpandParams
instance StripeHasParam CreateCharge CustomerId
instance StripeHasParam CreateCharge NewCard
instance StripeHasParam CreateCharge TokenId
instance StripeHasParam CreateCharge Description
instance StripeHasParam CreateCharge MetaData
instance StripeHasParam CreateCharge Capture
instance StripeHasParam CreateCharge StatementDescription
instance StripeHasParam CreateCharge ReceiptEmail
instance StripeHasParam CreateCharge ApplicationFeeAmount
getCharge
:: ChargeId
-> StripeRequest GetCharge
getCharge
chargeid = request
where request = mkStripeRequest GET url params
url = "charges" </> getChargeId chargeid
params = []
data GetCharge
type instance StripeReturn GetCharge = Charge
instance StripeHasParam GetCharge ExpandParams
updateCharge
:: ChargeId
-> StripeRequest UpdateCharge
updateCharge
chargeid = request
where request = mkStripeRequest POST url params
url = "charges" </> getChargeId chargeid
params = []
data UpdateCharge
type instance StripeReturn UpdateCharge = Charge
instance StripeHasParam UpdateCharge Description
instance StripeHasParam UpdateCharge MetaData
captureCharge
:: ChargeId
-> StripeRequest CaptureCharge
captureCharge
chargeid = request
where request = mkStripeRequest POST url params
url = "charges" </> getChargeId chargeid </> "capture"
params = []
data CaptureCharge
type instance StripeReturn CaptureCharge = Charge
instance StripeHasParam CaptureCharge Amount
instance StripeHasParam CaptureCharge ReceiptEmail
getCharges
:: StripeRequest GetCharges
getCharges = request
where request = mkStripeRequest GET url params
url = "charges"
params = []
data GetCharges
type instance StripeReturn GetCharges = StripeList Charge
instance StripeHasParam GetCharges ExpandParams
instance StripeHasParam GetCharges Created
instance StripeHasParam GetCharges CustomerId
instance StripeHasParam GetCharges (EndingBefore ChargeId)
instance StripeHasParam GetCharges Limit
instance StripeHasParam GetCharges (StartingAfter ChargeId)