| 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
{-# 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 :: StripeRequest GetSubscriptions
- data GetSubscriptionsByCustomerId
- getSubscriptionsByCustomerId :: CustomerId -> StripeRequest GetSubscriptionsByCustomerId
- 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 #
Instances
Arguments
| :: CustomerId | The |
| -> PlanId | The |
| -> StripeRequest CreateSubscription |
Create a Subscription by CustomerId and PlanId
data GetSubscription #
Instances
Arguments
| :: CustomerId | The |
| -> SubscriptionId | The |
| -> StripeRequest GetSubscription |
Retrieve a Subscription by CustomerId and SubscriptionId
data UpdateSubscription #
Instances
Arguments
| :: CustomerId | The |
| -> SubscriptionId | The |
| -> StripeRequest UpdateSubscription |
Update a Subscription by CustomerId and SubscriptionId
data CancelSubscription #
Instances
Arguments
| :: CustomerId | The |
| -> SubscriptionId | The |
| -> StripeRequest CancelSubscription |
Delete a Subscription by CustomerId and SubscriptionId
data GetSubscriptions #
getSubscriptions :: StripeRequest GetSubscriptions #
Retrieve all active Subscriptions
data GetSubscriptionsByCustomerId #
Instances
getSubscriptionsByCustomerId :: CustomerId -> StripeRequest GetSubscriptionsByCustomerId #
Retrieve a customer's Subscriptions
Types
newtype ApplicationFeePercent #
ApplicationFeePercent
Constructors
| ApplicationFeePercent Double |
Instances
newtype AtPeriodEnd #
A flag that if set to true will delay the cancellation of the subscription until the end of the current period.
Constructors
| AtPeriodEnd Bool |
newtype CustomerId #
CustomerId for a Customer
Constructors
| CustomerId Text |
Instances
Instances
Coupon Object
Constructors
| Coupon | |
Fields
| |
newtype EndingBefore a #
Pagination Option for StripeList
Constructors
| EndingBefore a |
Instances
newtype ExpandParams #
Type of Expansion Parameters for use on Stripe objects
Constructors
| ExpandParams | |
Fields
| |
Instances
Pagination Option for StripeList
Instances
Type of MetaData for use on Stripe objects
Instances
Prorate
Generic Quantity type to be used with Customer,
Subscription and InvoiceLineItem API requests
newtype StartingAfter a #
Pagination Option for StripeList
Constructors
| StartingAfter a |
Instances
data StripeList a #
Generic handling of Stripe JSON arrays
Constructors
| StripeList | |
Instances
| Eq a => Eq (StripeList a) # | |
| Data a => Data (StripeList a) # | |
| Ord a => Ord (StripeList a) # | |
| Read a => Read (StripeList a) # | |
| Show a => Show (StripeList a) # | |
| FromJSON a => FromJSON (StripeList a) # | JSON Instance for |
data Subscription #
Subscription Object
Constructors
Instances
| Eq Subscription # | |
| Data Subscription # | |
| Ord Subscription # | |
| Read Subscription # | |
| Show Subscription # | |
| FromJSON Subscription # | JSON Instance for |
newtype SubscriptionId #
SubscriptionId for a Subscription
Constructors
| SubscriptionId | |
Fields | |
Instances
TrialEnd for a Plan