module Web.Stripe.Invoice
(
createInvoice
, getInvoice
, getInvoiceExpandable
, getInvoices
, getInvoicesExpandable
, getInvoiceLineItems
, getUpcomingInvoice
, getUpcomingInvoices
, updateInvoice
, payInvoice
, Invoice (..)
, InvoiceId (..)
, InvoiceLineItem (..)
, InvoiceLineItemId (..)
, InvoiceLineItemType (..)
, Discount (..)
, Period (..)
) where
import Web.Stripe.Client.Internal
import Web.Stripe.Types
import Web.Stripe.Types.Util
createInvoice
:: CustomerId
-> MetaData
-> Stripe Invoice
createInvoice
customerid
metadata = callAPI request
where request = StripeRequest POST url params
url = "invoices"
params = toMetaData metadata ++ getParams [
("customer", Just $ getCustomerId customerid)
]
getInvoice
:: InvoiceId
-> Stripe Invoice
getInvoice
invoiceid = getInvoiceExpandable invoiceid []
getInvoiceExpandable
:: InvoiceId
-> ExpandParams
-> Stripe Invoice
getInvoiceExpandable
invoiceid
expandParams = callAPI request
where request = StripeRequest GET url params
url = "invoices" </> getInvoiceId invoiceid
params = toExpandable expandParams
getInvoices
:: Maybe Limit
-> StartingAfter InvoiceItemId
-> EndingBefore InvoiceItemId
-> Stripe (StripeList Invoice)
getInvoices
limit
startingAfter
endingBefore =
getInvoicesExpandable limit startingAfter endingBefore []
getInvoicesExpandable
:: Maybe Limit
-> StartingAfter InvoiceItemId
-> EndingBefore InvoiceItemId
-> ExpandParams
-> Stripe (StripeList Invoice)
getInvoicesExpandable
limit
startingAfter
endingBefore
expandParams = callAPI request
where request = StripeRequest GET url params
url = "invoices"
params = getParams [
("limit", toText `fmap` limit )
, ("starting_after", (\(InvoiceItemId x) -> x) `fmap` startingAfter)
, ("ending_before", (\(InvoiceItemId x) -> x) `fmap` endingBefore)
] ++ toExpandable expandParams
getInvoiceLineItems
:: InvoiceId
-> Limit
-> StartingAfter InvoiceLineItemId
-> EndingBefore InvoiceLineItemId
-> Stripe (StripeList InvoiceLineItem)
getInvoiceLineItems
invoiceid
limit
startingAfter
endingBefore = callAPI request
where request = StripeRequest GET url params
url = "invoices" </> getInvoiceId invoiceid </> "lines"
params = getParams [
("limit", toText `fmap` limit )
, ("starting_after", (\(InvoiceLineItemId x) -> x) `fmap` startingAfter)
, ("ending_before", (\(InvoiceLineItemId x) -> x) `fmap` endingBefore)
]
payInvoice
:: InvoiceId
-> Stripe Invoice
payInvoice
invoiceid = callAPI request
where request = StripeRequest POST url params
url = "invoices" </> getInvoiceId invoiceid </> "pay"
params = []
updateInvoice
:: InvoiceId
-> MetaData
-> Stripe Invoice
updateInvoice
invoiceid
metadata = callAPI request
where request = StripeRequest POST url params
url = "invoices" </> getInvoiceId invoiceid
params = toMetaData metadata
getUpcomingInvoice
:: CustomerId
-> Stripe Invoice
getUpcomingInvoice
customerid = callAPI request
where request = StripeRequest GET url params
url = "invoices" </> "upcoming"
params = getParams [
("customer", Just $ getCustomerId customerid)
]
getUpcomingInvoices
:: CustomerId
-> Stripe (StripeList Invoice)
getUpcomingInvoices
customerid = callAPI request
where request = StripeRequest GET url params
url = "invoices"
params = getParams [
("customer", Just $ getCustomerId customerid)
]