1
- {-# OPTIONS_GHC -cpp -pgmPcpphs -optP--cpp #-}
2
1
{-# LANGUAGE CPP #-}
2
+ {-# OPTIONS_GHC -cpp -pgmPcpphs -optP--cpp #-}
3
+
3
4
module Stripe.Client
4
5
( -- * Basics
5
- ApiKey , StripeClient , makeStripeClient , ClientError (.. )
6
+ ApiKey ,
7
+ StripeClient ,
8
+ makeStripeClient ,
9
+ ClientError (.. ),
10
+
6
11
-- * Helper types
7
- , TimeStamp (.. ), StripeList (.. )
12
+ TimeStamp (.. ),
13
+ StripeList (.. ),
14
+
8
15
-- * Customers
9
- , createCustomer , retrieveCustomer , updateCustomer , listCustomers
10
- , CustomerId (.. ), Customer (.. ), CustomerCreate (.. ), CustomerUpdate (.. )
16
+ createCustomer ,
17
+ retrieveCustomer ,
18
+ updateCustomer ,
19
+ listCustomers ,
20
+ CustomerId (.. ),
21
+ Customer (.. ),
22
+ CustomerCreate (.. ),
23
+ CustomerUpdate (.. ),
24
+
11
25
-- * Product catalog
12
- , ProductId (.. ), PriceId (.. ), Product (.. ), Price (.. ), PriceRecurring (.. )
13
- , ProductCreate (.. ), PriceCreate (.. ), PriceCreateRecurring (.. )
14
- , createProduct , retrieveProduct
15
- , createPrice , retrievePrice , listPrices
26
+ ProductId (.. ),
27
+ PriceId (.. ),
28
+ Product (.. ),
29
+ Price (.. ),
30
+ PriceRecurring (.. ),
31
+ ProductCreate (.. ),
32
+ PriceCreate (.. ),
33
+ PriceCreateRecurring (.. ),
34
+ createProduct ,
35
+ retrieveProduct ,
36
+ createPrice ,
37
+ retrievePrice ,
38
+ listPrices ,
39
+
16
40
-- * Subscriptions
17
- , SubscriptionId (.. ), SubscriptionItemId (.. ), Subscription (.. ), SubscriptionItem (.. ), SubscriptionCreate (.. ), SubscriptionCreateItem (.. )
18
- , createSubscription , retrieveSubscription , listSubscriptions
41
+ SubscriptionId (.. ),
42
+ SubscriptionItemId (.. ),
43
+ Subscription (.. ),
44
+ SubscriptionItem (.. ),
45
+ SubscriptionCreate (.. ),
46
+ SubscriptionCreateItem (.. ),
47
+ createSubscription ,
48
+ retrieveSubscription ,
49
+ listSubscriptions ,
50
+
19
51
-- * Customer Portal
20
- , CustomerPortalId (.. ), CustomerPortal (.. ), CustomerPortalCreate (.. )
21
- , createCustomerPortal
52
+ CustomerPortalId (.. ),
53
+ CustomerPortal (.. ),
54
+ CustomerPortalCreate (.. ),
55
+ createCustomerPortal ,
56
+
22
57
-- * Checkout
23
- , CheckoutSessionId (.. ), CheckoutSession (.. ), CheckoutSessionCreate (.. ), CheckoutSessionCreateLineItem (.. )
24
- , createCheckoutSession , retrieveCheckoutSession
58
+ CheckoutSessionId (.. ),
59
+ CheckoutSessionStatus (.. ),
60
+ CheckoutSession (.. ),
61
+ CheckoutSessionCreate (.. ),
62
+ CheckoutSessionCreateLineItem (.. ),
63
+ createCheckoutSession ,
64
+ retrieveCheckoutSession ,
65
+
25
66
-- * Events
26
- , retrieveEvent , listEvents
27
- , EventId (.. ), Event (.. ), EventData (.. )
67
+ retrieveEvent ,
68
+ listEvents ,
69
+ EventId (.. ),
70
+ Event (.. ),
71
+ EventData (.. ),
28
72
)
29
73
where
30
74
31
- import Stripe.Api
32
- import Stripe.Resources
33
- import Stripe.Client.Internal.Helpers
34
-
35
75
import Data.Proxy
36
- import Servant.API
37
- import Servant.Client
38
- import Network.HTTP.Client (Manager )
39
76
import qualified Data.Text as T
40
77
import qualified Data.Text.Encoding as T
78
+ import Network.HTTP.Client (Manager )
79
+ import Servant.API
80
+ import Servant.Client
81
+ import Stripe.Api
82
+ import Stripe.Client.Internal.Helpers
83
+ import Stripe.Resources
41
84
42
85
-- | Your Stripe API key. Can be obtained from the Stripe dashboard. Format: @sk_<mode>_<redacted>@
43
86
type ApiKey = T. Text
44
87
45
88
-- | Holds a 'Manager' and your API key.
46
- data StripeClient
47
- = StripeClient
48
- { scBasicAuthData :: BasicAuthData
49
- , scManager :: Manager
50
- , scMaxRetries :: Int
89
+ data StripeClient = StripeClient
90
+ { scBasicAuthData :: BasicAuthData ,
91
+ scManager :: Manager ,
92
+ scMaxRetries :: Int
51
93
}
52
94
53
95
-- | Construct a 'StripeClient'. Note that the passed 'Manager' must support https (e.g. via @http-client-tls@)
54
96
makeStripeClient ::
55
- ApiKey
56
- -> Manager
57
- -> Int
58
- -- ^ Number of automatic retries the library should attempt. See also <https://stripe.com/docs/error-handling#safely-retrying-requests-with-idempotency Stripe Error Handling >
59
- -> StripeClient
97
+ ApiKey ->
98
+ Manager ->
99
+ -- | Number of automatic retries the library should attempt. See also <https://stripe.com/docs/error-handling#safely-retrying-requests-with-idempotency Stripe Error Handling>
100
+ Int - >
101
+ StripeClient
60
102
makeStripeClient k = StripeClient (BasicAuthData (T. encodeUtf8 k) " " )
61
103
62
104
api :: Proxy StripeApi
@@ -80,35 +122,35 @@ stripeBaseUrl = BaseUrl Https "api.stripe.com" 443 ""
80
122
N :: StripeClient -> ARG -> ARG2 -> ARG3 -> IO (Either ClientError R );\
81
123
N sc a b c = runRequest (scMaxRetries sc) 0 $ runClientM (N ## ' (scBasicAuthData sc) a b c) (mkClientEnv (scManager sc) stripeBaseUrl)
82
124
83
- EP (createCustomer, CustomerCreate , Customer )
84
- EP (retrieveCustomer, CustomerId , Customer )
85
- EP2 (updateCustomer, CustomerId , CustomerUpdate , Customer )
86
- EP (listCustomers, Maybe CustomerId , (StripeList Customer ))
125
+ EP (createCustomer, CustomerCreate , Customer )
126
+ EP (retrieveCustomer, CustomerId , Customer )
127
+ EP2 (updateCustomer, CustomerId , CustomerUpdate , Customer )
128
+ EP (listCustomers, Maybe CustomerId , (StripeList Customer ))
87
129
88
- EP (createProduct, ProductCreate , Product )
89
- EP (retrieveProduct, ProductId , Product )
130
+ EP (createProduct, ProductCreate , Product )
131
+ EP (retrieveProduct, ProductId , Product )
90
132
91
- EP (createPrice, PriceCreate , Price )
92
- EP (retrievePrice, PriceId , Price )
93
- EP (listPrices, Maybe T. Text , (StripeList Price ))
133
+ EP (createPrice, PriceCreate , Price )
134
+ EP (retrievePrice, PriceId , Price )
135
+ EP (listPrices, Maybe T. Text , (StripeList Price ))
94
136
95
- EP (createSubscription, SubscriptionCreate , Subscription )
96
- EP (retrieveSubscription, SubscriptionId , Subscription )
97
- EP (listSubscriptions, Maybe CustomerId , (StripeList Subscription ))
137
+ EP (createSubscription, SubscriptionCreate , Subscription )
138
+ EP (retrieveSubscription, SubscriptionId , Subscription )
139
+ EP (listSubscriptions, Maybe CustomerId , (StripeList Subscription ))
98
140
99
- EP (createCheckoutSession, CheckoutSessionCreate , CheckoutSession )
100
- EP (retrieveCheckoutSession, CheckoutSessionId , CheckoutSession )
141
+ EP (createCheckoutSession, CheckoutSessionCreate , CheckoutSession )
142
+ EP (retrieveCheckoutSession, CheckoutSessionId , CheckoutSession )
101
143
102
- EP (createCustomerPortal, CustomerPortalCreate , CustomerPortal )
144
+ EP (createCustomerPortal, CustomerPortalCreate , CustomerPortal )
103
145
104
- EP (retrieveEvent, EventId , Event )
105
- EP (listEvents, Maybe EventId , (StripeList Event ))
146
+ EP (retrieveEvent, EventId , Event )
147
+ EP (listEvents, Maybe EventId , (StripeList Event ))
106
148
107
149
(createCustomer' :<|> retrieveCustomer' :<|> updateCustomer' :<|> listCustomers')
108
150
:<|> (createProduct' :<|> retrieveProduct')
109
151
:<|> (createPrice' :<|> retrievePrice' :<|> listPrices')
110
152
:<|> (createSubscription' :<|> retrieveSubscription' :<|> listSubscriptions')
111
153
:<|> (createCheckoutSession' :<|> retrieveCheckoutSession')
112
154
:<|> (createCustomerPortal')
113
- :<|> (retrieveEvent' :<|> listEvents')
114
- = client api
155
+ :<|> (retrieveEvent' :<|> listEvents') =
156
+ client api
0 commit comments