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
import Web.Stripe import Web.Stripe.Subscription import Web.Stripe.Customer import Web.Stripe.Plan main :: IO () main = do let config = SecretKey "secret_key" result <- stripe config $ do Customer { customerId = cid } <- createEmptyCustomer Plan { planId = pid } <- createPlan (PlanId "free plan") (0 :: Amount) -- free plan (USD :: Currency) (Month :: Inteval) ("sample plan" :: Name) ([] :: MetaData) createSubscription cid pid ([] :: MetaData) case result of Right subscription -> print subscription Left stripeError -> print stripeError
- createSubscription :: CustomerId -> PlanId -> MetaData -> Stripe Subscription
- getSubscription :: CustomerId -> SubscriptionId -> Stripe Subscription
- getSubscriptionExpandable :: CustomerId -> SubscriptionId -> ExpandParams -> Stripe Subscription
- getSubscriptions :: CustomerId -> Limit -> StartingAfter SubscriptionId -> EndingBefore SubscriptionId -> Stripe (StripeList Subscription)
- getSubscriptionsExpandable :: CustomerId -> Limit -> StartingAfter SubscriptionId -> EndingBefore SubscriptionId -> ExpandParams -> Stripe (StripeList Subscription)
- updateSubscription :: CustomerId -> SubscriptionId -> Maybe CouponId -> MetaData -> Stripe Subscription
- cancelSubscription :: CustomerId -> SubscriptionId -> Bool -> Stripe Subscription
- data Subscription = Subscription {
- subscriptionId :: SubscriptionId
- subscriptionPlan :: Plan
- subscriptionObject :: Text
- subscriptionStart :: UTCTime
- subscriptionStatus :: SubscriptionStatus
- subscriptionCustomerId :: 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
- newtype SubscriptionId = SubscriptionId Text
- data SubscriptionStatus
- data CustomerId
- 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 PlanId = PlanId Text
- data StripeList a = StripeList {}
API
:: CustomerId | The |
-> PlanId | The |
-> MetaData | The |
-> Stripe Subscription |
Create a Subscription
by CustomerId
and PlanId
:: CustomerId | The |
-> SubscriptionId | The |
-> Stripe Subscription |
Retrieve a Subscription
by CustomerId
and SubscriptionId
getSubscriptionExpandable Source
:: CustomerId | The |
-> SubscriptionId | The |
-> ExpandParams | The |
-> Stripe Subscription |
Retrieve a Subscription
by CustomerId
and SubscriptionId
with ExpandParams
:: CustomerId | The |
-> Limit | Defaults to 10 if |
-> StartingAfter SubscriptionId | Paginate starting after the following |
-> EndingBefore SubscriptionId | Paginate ending before the following |
-> Stripe (StripeList Subscription) |
Retrieve active Subscription
s
getSubscriptionsExpandable Source
:: CustomerId | The |
-> Limit | Defaults to 10 if |
-> StartingAfter SubscriptionId | Paginate starting after the following |
-> EndingBefore SubscriptionId | Paginate ending before the following |
-> ExpandParams | The |
-> Stripe (StripeList Subscription) |
Retrieve active Subscription
s
:: CustomerId | The |
-> SubscriptionId | The |
-> Maybe CouponId | Optional: The |
-> MetaData | |
-> Stripe Subscription |
Update a Subscription
by CustomerId
and SubscriptionId
:: CustomerId | The |
-> SubscriptionId | The |
-> Bool | Flag set to true will delay cancellation until end of current period, default |
-> Stripe Subscription |
Delete a Subscription
by CustomerId
and SubscriptionId
Types
data Subscription Source
Subscription Object
Eq Subscription | |
Show Subscription | |
FromJSON Subscription | JSON Instance for |
newtype SubscriptionId Source
SubscriptionId
for a Subscription
data SubscriptionStatus Source
Status of a Subscription
Eq SubscriptionStatus | |
Show SubscriptionStatus | |
FromJSON SubscriptionStatus | JSON Instance for |
data CustomerId Source
CustomerId
for a Customer
Eq CustomerId | |
Show CustomerId | |
FromJSON CustomerId | JSON Instance for |
Coupon
Object
data StripeList a Source
Generic handling of Stripe JSON arrays
Eq a => Eq (StripeList a) | |
Show a => Show (StripeList a) | |
FromJSON a => FromJSON (StripeList a) | JSON Instance for |