| Copyright | (c) David Johnson, 2014 |
|---|---|
| Maintainer | djohnson.m@gmail.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Web.Stripe.Subscription
Description
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
Arguments
| :: CustomerId | The |
| -> PlanId | The |
| -> MetaData | The |
| -> Stripe Subscription |
Create a Subscription by CustomerId and PlanId
Arguments
| :: CustomerId | The |
| -> SubscriptionId | The |
| -> Stripe Subscription |
Retrieve a Subscription by CustomerId and SubscriptionId
getSubscriptionExpandable Source
Arguments
| :: CustomerId | The |
| -> SubscriptionId | The |
| -> ExpandParams | The |
| -> Stripe Subscription |
Retrieve a Subscription by CustomerId and SubscriptionId with ExpandParams
Arguments
| :: 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 Subscriptions
getSubscriptionsExpandable Source
Arguments
| :: 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 Subscriptions
Arguments
| :: CustomerId | The |
| -> SubscriptionId | The |
| -> Maybe CouponId | Optional: The |
| -> MetaData | |
| -> Stripe Subscription |
Update a Subscription by CustomerId and SubscriptionId
Arguments
| :: 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
Constructors
Instances
| Eq Subscription | |
| Show Subscription | |
| FromJSON Subscription | JSON Instance for |
newtype SubscriptionId Source
SubscriptionId for a Subscription
Constructors
| SubscriptionId Text |
Instances
data SubscriptionStatus Source
Status of a Subscription
Instances
| Eq SubscriptionStatus | |
| Show SubscriptionStatus | |
| FromJSON SubscriptionStatus | JSON Instance for |
data CustomerId Source
CustomerId for a Customer
Constructors
| CustomerId Text | |
| ExpandedCustomer Customer |
Instances
| Eq CustomerId | |
| Show CustomerId | |
| FromJSON CustomerId | JSON Instance for |
Coupon Object
Constructors
| Coupon | |
Fields
| |
data StripeList a Source
Generic handling of Stripe JSON arrays
Constructors
| StripeList | |
Instances
| Eq a => Eq (StripeList a) | |
| Show a => Show (StripeList a) | |
| FromJSON a => FromJSON (StripeList a) | JSON Instance for |