Copyright | (c) David Johnson 2014 |
---|---|
Maintainer | djohnson.m@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
https://stripe.com/docs/api#subscriptions
{-# LANGUAGE OverloadedStrings #-} import Web.Stripe import Web.Stripe.Subscription import Web.Stripe.Customer import Web.Stripe.Plan main :: IO () main = do let config = StripeConfig (StripeKey "secret_key") result <- stripe config $ createCustomer case result of (Left stripeError) -> print stripeError (Right (Customer { customerId = cid })) -> do result <- stripe config $ createPlan (PlanId "free plan") (Amount 0) USD Month (PlanName "sample plan") case result of (Left stripeError) -> print stripeError (Right (Plan { planId = pid })) -> do result <- stripe config $ createSubscription cid pid case result of (Left stripeError) -> print stripeError (Right subscription) -> print subscription
- data CreateSubscription
- createSubscription :: CustomerId -> PlanId -> StripeRequest CreateSubscription
- data GetSubscription
- getSubscription :: CustomerId -> SubscriptionId -> StripeRequest GetSubscription
- data UpdateSubscription
- updateSubscription :: CustomerId -> SubscriptionId -> StripeRequest UpdateSubscription
- data CancelSubscription
- cancelSubscription :: CustomerId -> SubscriptionId -> StripeRequest CancelSubscription
- data GetSubscriptions
- getSubscriptions :: CustomerId -> StripeRequest GetSubscriptions
- newtype ApplicationFeePercent = ApplicationFeePercent Double
- newtype AtPeriodEnd = AtPeriodEnd Bool
- newtype CustomerId = CustomerId Text
- newtype CouponId = CouponId Text
- data Coupon = Coupon {
- couponId :: CouponId
- couponCreated :: UTCTime
- couponPercentOff :: Maybe Int
- couponAmountOff :: Maybe Int
- couponCurrency :: Maybe Currency
- couponLiveMode :: Bool
- couponDuration :: Duration
- couponRedeemBy :: Maybe UTCTime
- couponMaxRedemptions :: Maybe Int
- couponTimesRedeemed :: Maybe Int
- couponDurationInMonths :: Maybe Int
- couponValid :: Bool
- couponMetaData :: MetaData
- newtype EndingBefore a = EndingBefore a
- newtype ExpandParams = ExpandParams {
- getExpandParams :: [Text]
- newtype Limit = Limit Int
- newtype MetaData = MetaData [(Text, Text)]
- newtype PlanId = PlanId Text
- newtype Prorate = Prorate Bool
- newtype Quantity = Quantity Int
- newtype StartingAfter a = StartingAfter a
- data StripeList a = StripeList {}
- data Subscription = Subscription {
- subscriptionId :: SubscriptionId
- subscriptionPlan :: Plan
- subscriptionObject :: Text
- subscriptionStart :: UTCTime
- subscriptionStatus :: SubscriptionStatus
- subscriptionCustomerId :: Expandable CustomerId
- subscriptionCancelAtPeriodEnd :: Bool
- subscriptionCurrentPeriodStart :: UTCTime
- subscriptionCurrentPeriodEnd :: UTCTime
- subscriptionEndedAt :: Maybe UTCTime
- subscriptionTrialStart :: Maybe UTCTime
- subscriptionTrialEnd :: Maybe UTCTime
- subscriptionCanceledAt :: Maybe UTCTime
- subscriptionQuantity :: Quantity
- subscriptionApplicationFeePercent :: Maybe Double
- subscriptionDiscount :: Maybe Discount
- subscriptionMetaData :: MetaData
- subscriptionTaxPercent :: Maybe Double
- newtype SubscriptionId = SubscriptionId {}
- data SubscriptionStatus
- newtype TaxPercent = TaxPercent Double
- newtype TrialEnd = TrialEnd UTCTime
API
data CreateSubscription Source #
:: CustomerId | The |
-> PlanId | The |
-> StripeRequest CreateSubscription |
Create a Subscription
by CustomerId
and PlanId
data GetSubscription Source #
:: CustomerId | The |
-> SubscriptionId | The |
-> StripeRequest GetSubscription |
Retrieve a Subscription
by CustomerId
and SubscriptionId
data UpdateSubscription Source #
:: CustomerId | The |
-> SubscriptionId | The |
-> StripeRequest UpdateSubscription |
Update a Subscription
by CustomerId
and SubscriptionId
data CancelSubscription Source #
:: CustomerId | The |
-> SubscriptionId | The |
-> StripeRequest CancelSubscription |
Delete a Subscription
by CustomerId
and SubscriptionId
data GetSubscriptions Source #
:: CustomerId | The |
-> StripeRequest GetSubscriptions |
Retrieve active Subscription
s
Types
newtype ApplicationFeePercent Source #
ApplicationFeePercent
newtype AtPeriodEnd Source #
A flag that if set to true will delay the cancellation of the subscription until the end of the current period.
newtype CustomerId Source #
CustomerId
for a Customer
Coupon
Object
newtype EndingBefore a Source #
Pagination Option for StripeList
newtype ExpandParams Source #
Type of Expansion Parameters for use on Stripe
objects
Pagination Option for StripeList
Type of MetaData for use on Stripe
objects
Prorate
Generic Quantity
type to be used with Customer
,
Subscription
and InvoiceLineItem
API requests
newtype StartingAfter a Source #
Pagination Option for StripeList
data StripeList a Source #
Generic handling of Stripe JSON arrays
Eq a => Eq (StripeList a) Source # | |
Data a => Data (StripeList a) Source # | |
Ord a => Ord (StripeList a) Source # | |
Read a => Read (StripeList a) Source # | |
Show a => Show (StripeList a) Source # | |
FromJSON a => FromJSON (StripeList a) Source # | JSON Instance for |
data Subscription Source #
Subscription Object
Eq Subscription Source # | |
Data Subscription Source # | |
Ord Subscription Source # | |
Read Subscription Source # | |
Show Subscription Source # | |
FromJSON Subscription Source # | JSON Instance for |
newtype SubscriptionId Source #
SubscriptionId
for a Subscription
data SubscriptionStatus Source #
Status of a Subscription
newtype TaxPercent Source #
TaxPercent
for a Subscription
TrialEnd
for a Plan