| Copyright | (c) David Johnson, 2014 |
|---|---|
| Maintainer | [email protected] |
| 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 :: 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 #
Instances
Arguments
| :: CustomerId | The |
| -> PlanId | The |
| -> StripeRequest CreateSubscription |
Create a Subscription by CustomerId and PlanId
data GetSubscription Source #
Instances
Arguments
| :: CustomerId | The |
| -> SubscriptionId | The |
| -> StripeRequest GetSubscription |
Retrieve a Subscription by CustomerId and SubscriptionId
data UpdateSubscription Source #
Instances
Arguments
| :: CustomerId | The |
| -> SubscriptionId | The |
| -> StripeRequest UpdateSubscription |
Update a Subscription by CustomerId and SubscriptionId
data CancelSubscription Source #
Instances
Arguments
| :: CustomerId | The |
| -> SubscriptionId | The |
| -> StripeRequest CancelSubscription |
Delete a Subscription by CustomerId and SubscriptionId
data GetSubscriptions Source #
Arguments
| :: CustomerId | The |
| -> StripeRequest GetSubscriptions |
Retrieve active Subscriptions
Types
newtype ApplicationFeePercent Source #
ApplicationFeePercent
Constructors
| ApplicationFeePercent Double |
Instances
newtype AtPeriodEnd Source #
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 Source #
CustomerId for a Customer
Constructors
| CustomerId Text |
Instances
Instances
Coupon Object
Constructors
| Coupon | |
Fields
| |
newtype EndingBefore a Source #
Pagination Option for StripeList
Constructors
| EndingBefore a |
Instances
newtype ExpandParams Source #
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
Instances
Prorate
Generic Quantity type to be used with Customer,
Subscription and InvoiceLineItem API requests
Instances
newtype StartingAfter a Source #
Pagination Option for StripeList
Constructors
| StartingAfter a |
Instances
data StripeList a Source #
Generic handling of Stripe JSON arrays
Constructors
| StripeList | |
Instances
| 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
Constructors
Instances
| 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
Constructors
| SubscriptionId | |
Fields | |
Instances
TrialEnd for a Plan
Instances