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