-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | PayPal API, currently supporting "ButtonManager"
--
-- This package is a moderately successful attempt to tame the
-- confusingness of PayPal's API using Haskell types. Currently only the
-- ButtonManager API is supported.
--
-- Type families are used extensively to encode PayPal's validation
-- rules, so they can be checked at compile time. Haddock doesn't get all
-- the type family stuff across, so you may find it easier to read the
-- source code. Because PayPal's documents leave you to guessing, it will
-- take trial and error to get the logic in this package correct, so
-- please contribute your fixes. Code changes to this package are likely
-- to break your code, so please depend on a specific version.
--
-- Take a look at example.hs.
--
-- The benefits of using PayPal:
--
--
-- - You can accept credit cards on your website priced for low
-- transaction volumes.
--
--
-- The drawbacks of using PayPal:
--
--
-- - PayPal tries to harvest your customers, by annoying them into
-- becoming PayPal members.
-- - If you are outside the USA, you can't have different shipping
-- rates by country, which is... beyond pathetic.
--
@package paypal-api
@version 0.2
module Network.PayPal.Types
-- | Security. Signature only at present: Certificate security is not yet
-- supported.
data Security
Signature :: ByteString -> Security
data Credentials
Credentials :: ByteString -> ByteString -> Security -> ByteString -> Credentials
crUsername :: Credentials -> ByteString
crPassword :: Credentials -> ByteString
crSecurity :: Credentials -> Security
-- | e.g. 56.0
crVersion :: Credentials -> ByteString
data Status res
Success :: res -> Status res
Failure :: [Message] -> Status res
ParseFailure :: [(ByteString, ByteString)] -> String -> Status res
class ToText a
toText :: ToText a => a -> ByteString
class FromText a
fromText :: FromText a => ByteString -> Maybe a
class ToVariables a
toVariables :: ToVariables a => a -> [(ByteString, ByteString)]
class FromVariables a
fromVariables :: FromVariables a => Map ByteString ByteString -> Either String a
class ToVariables req => PayPalRequest req where data family PayPalResponse req :: *
decodeResponse :: PayPalRequest req => Map ByteString ByteString -> Status (PayPalResponse req)
-- | Check for errors, then delegate to decodeResponse if there aren't any.
decodeResponseChecking :: PayPalRequest req => [(ByteString, ByteString)] -> Status (PayPalResponse req)
toTextTime :: FormatTime t => t -> ByteString
fromTextTime :: ParseTime t => ByteString -> Maybe t
instance Show Message
instance Show res => Show (Status res)
instance FromText (Ratio Integer)
instance ToText (Ratio Integer)
instance FromText Int
instance ToText Int
instance FromText Double
instance ToText Double
instance Functor Status
module Network.PayPal.NVP
-- | A PayPal service.
data Service
-- | PayPal sandbox.
sandbox :: Service
-- | PayPal live system.
live :: Service
-- | Submit a request to PayPal.
submit :: (Failure HttpException m, MonadIO m, PayPalRequest req) => Service -> Credentials -> req -> m (Either (Response ByteString) (Status (PayPalResponse req)))
-- | Construct an HTTP request for the specified PayPal request.
prepareRequest :: (Monad m, PayPalRequest req) => Service -> Credentials -> req -> Request m
processResponse :: (PayPalRequest req, MonadIO m) => req -> Response ByteString -> m (Either (Response ByteString) (Status (PayPalResponse req)))
module Network.PayPal.ButtonManager
data CreateButton buttonCode buttonType
CreateButton :: Variables buttonType -> Maybe ButtonSubtype -> Options -> Maybe (Either ButtonImageType ByteString) -> ButtonText buttonType -> Maybe ByteString -> Maybe ByteString -> [(ByteString, ByteString)] -> CreateButton buttonCode buttonType
cbVariables :: CreateButton buttonCode buttonType -> Variables buttonType
cbButtonSubtype :: CreateButton buttonCode buttonType -> Maybe ButtonSubtype
cbOptions :: CreateButton buttonCode buttonType -> Options
-- | Either the button image type, or the button image URL.
cbButtonImage :: CreateButton buttonCode buttonType -> Maybe (Either ButtonImageType ByteString)
cbButtonText :: CreateButton buttonCode buttonType -> ButtonText buttonType
cbCountry :: CreateButton buttonCode buttonType -> Maybe ByteString
cbLanguage :: CreateButton buttonCode buttonType -> Maybe ByteString
cbExtras :: CreateButton buttonCode buttonType -> [(ByteString, ByteString)]
data ButtonSearch t
ButtonSearch :: t -> Maybe t -> ButtonSearch t
bsStartDate :: ButtonSearch t -> t
bsEndDate :: ButtonSearch t -> Maybe t
data GetButtonDetails
GetButtonDetails :: HostedButtonID -> GetButtonDetails
gbdButtonID :: GetButtonDetails -> HostedButtonID
-- | Button code value
data HOSTED
data NONHOSTED a
-- | Button code value
data ENCRYPTED
-- | Button code value
data CLEARTEXT
-- | Button code value
data TOKEN
-- | Button type value
data BUYNOW
-- | Button type value
data CART
-- | Button type value
data GIFTCERTIFICATE
-- | Button type value
data SUBSCRIBE
-- | Button type value
data DONATE
-- | Button type value
data UNSUBSCRIBE
-- | Button type value
data VIEWCART
data Item bt
Item :: Amount bt -> Maybe Text -> Maybe ByteString -> Maybe ByteString -> Maybe Int -> Shipping bt -> Shipping bt -> Maybe Rational -> Maybe Double -> UndefinedQuantity bt -> Maybe (Double, WeightUnit) -> Item bt
-- | The price or amount of the item. Required for Add to Cart buttons. May
-- not be used when a dropdown with price (L_OPTION0PRICEn) is defined.
-- Limitations: Value must be a positive number. No currency symbol. Must
-- have two decimal places, decimal separator must be a period (.), and
-- the optional thousands separator must be a comma (,).
itAmount :: Item bt -> Amount bt
-- | Description of item. If omitted, payers enter their own name at the
-- time of payment.
itItemName :: Item bt -> Maybe Text
-- | Secure Merchant ID or Email Address. When omitted, defaults to the
-- secure merchant ID of the merchant. If an email address is specified
-- then it the following requirements apply: A merchant or 3rd Party
-- calling the API directly may specify an unregistered email and create
-- an unencrypted button only. A 3rd Party calling the API on behalf of a
-- registered merchant must specify an email address associated with the
-- merchant account. Character length and limitations: 127 single-byte
-- characters.
itBusiness :: Item bt -> Maybe ByteString
-- | Item number or ID. Character length and limitations: 127 single-byte
-- alphanumeric characters.
itItemNumber :: Item bt -> Maybe ByteString
-- | Number of items. If profile-based shipping rates are configured with a
-- basis of quantity, the sum of quantity values is used to calculate the
-- shipping charges for the transaction. PayPal appends a sequence number
-- to uniquely identify the item in the PayPal Shopping Cart (e.g.,
-- quantity1, quantity2). Note: The value for quantity must be a positive
-- integer. Null, zero, or negative numbers are not allowed.
itQuantity :: Item bt -> Maybe Int
-- | The cost of shipping this item. If you specify shipping and shipping2
-- is not defined, this flat amount is charged regardless of the quantity
-- of items purchased. This use of the shipping variable is valid only
-- for Buy Now and Add to Cart buttons. Default - If profile-based
-- shipping rates are configured, buyers are charged an amount according
-- to the shipping methods they choose.
itShipping :: Item bt -> Shipping bt
-- | The cost of shipping each additional unit of this item. If omitted and
-- profile-based shipping rates are configured, buyers are charged an
-- amount according to the shipping methods they choose. Valid only for
-- Buy Now and Add to Cart buttons.
itShipping2 :: Item bt -> Shipping bt
-- | Transaction-based tax override variable. Set this to a flat tax amount
-- to apply to the transaction regardless of the buyer's location. This
-- value overrides any tax settings set in your account profile. Valid
-- only for Buy Now and Add to Cart buttons. Default - Profile tax
-- settings, if any, apply.
itTax :: Item bt -> Maybe Rational
-- | Transaction-based tax override variable. Set this to a percentage that
-- will be applied to amount multiplied the quantity selected during
-- checkout. This value overrides any tax settings set in your account
-- profile. Allowable values are numbers 0.001 through 100. Valid only
-- for Buy Now and Add to Cart buttons. Default - Profile tax settings,
-- if any, apply.
itTaxRate :: Item bt -> Maybe Double
-- | True = allows buyers to specify the quantity.
itUndefinedQuantity :: Item bt -> UndefinedQuantity bt
-- | Weight of items. If profile-based shipping rates are configured with a
-- basis of weight, the sum of weight values is used to calculate the
-- shipping charges for the transaction.
itWeight :: Item bt -> Maybe (Double, WeightUnit)
data Subscription
Subscription :: ByteString -> Maybe ByteString -> Maybe ByteString -> Maybe (PeriodicPrice, Maybe PeriodicPrice) -> PeriodicPrice -> Maybe (Int, Bool) -> Maybe ByteString -> Maybe ByteString -> Int -> Bool -> Subscription
-- | Your PayPal ID or an email address associated with your PayPal
-- account. Email addresses must be confirmed.
suBusiness :: Subscription -> ByteString
-- | Description of item being sold (maximum 127 characters). If you are
-- collecting aggregate payments, this can include a summary of all items
-- purchased, tracking numbers, or generic terms such as
-- subscription. If omitted, customer will see a field in which
-- they have the option of entering an Item Name
suItemName :: Subscription -> Maybe ByteString
-- | The currency of prices for trial periods and the subscription. The
-- default is USD.
suCurrencyCode :: Subscription -> Maybe ByteString
-- | Trial period 1 price. For a free trial period, specify 0. Trial period
-- 2 price. Can be specified only if you also specify a1.
suTrialPeriod :: Subscription -> Maybe (PeriodicPrice, Maybe PeriodicPrice)
suRegularPrice :: Subscription -> PeriodicPrice
-- | Nothing = Subscription payments do not recur. Just (times, reattempt)
-- = Subscription payments recur. times = Number of times that
-- subscription payments recur. Specify an integer above 1. reattempt:
-- false = do not reattempt failed recurring payments true = reattempt
-- failed recurring payments before canceling
suRecurring :: Subscription -> Maybe (Int, Bool)
-- | User-defined field which will be passed through the system and
-- returned in your merchant payment notification email. This field will
-- not be shown to your subscribers. Default - No variable is passed back
-- to you.
suCustom :: Subscription -> Maybe ByteString
-- | User-defined field which must be unique with each subscription. The
-- invoice number will be shown to subscribers with the other details of
-- their transactions
suInvoice :: Subscription -> Maybe ByteString
-- | Modification behavior. Allowable values:
--
--
-- - 0 - allows subscribers to only create new subscriptions
-- - 1 - allows subscribers to modify their current subscriptions or
-- sign up for new ones
-- - 2 - allows subscribers to only modify their current
-- subscriptions
--
--
-- The default value is 0.
suModification :: Subscription -> Int
-- | Set to 1 to have PayPal generate usernames and initial passwords for
-- subscribers.
suUserManage :: Subscription -> Bool
data Payment
Payment :: Maybe Bool -> Maybe ByteString -> Maybe ByteString -> Maybe Rational -> Maybe ByteString -> Maybe Rational -> Maybe (Double, WeightUnit) -> Payment
-- | True: The address specified in prepopulation variables overrides the
-- PayPal member's stored address. The payer is shown the passed-in
-- address but cannot edit it. No address is shown if the address is not
-- valid, such as missing required fields like country, or is not
-- included at all.
payAddressOverride :: Payment -> Maybe Bool
-- | The currency of the payment. The default is USD. (3 chars)
payCurrencyCode :: Payment -> Maybe ByteString
-- | Passthrough variable never presented to the payer. Default - No
-- variable is passed back to you.
payCustom :: Payment -> Maybe ByteString
-- | Handling charges. This is not quantity-specific. The same handling
-- cost applies, regardless of the number of items on the order. Default
-- - No handling charges are included. (256 chars)
payHandling :: Payment -> Maybe Rational
-- | Passthrough variable you can use to identify your invoice number for
-- this purchase. (127 chars) Default - No variable is passed back to
-- you.
payInvoice :: Payment -> Maybe ByteString
-- | Cart-wide tax, overriding any individual item tax_x value
payTaxCart :: Payment -> Maybe Rational
-- | If profile-based shipping rates are configured with a basis of weight,
-- PayPal uses this value to calculate the shipping charges for the
-- transaction. This value overrides the weight values of individual
-- items.
payWeight :: Payment -> Maybe (Double, WeightUnit)
data ShoppingCart
ShoppingCart :: CartAction -> Maybe Rational -> PaymentAction -> Maybe ByteString -> ShoppingCart
-- | Add an item to the PayPal Shopping Cart, OR, Display the contents of
-- the PayPal Shopping Cart to the buyer, OR, Upload the contents of a
-- third party shopping cart or a custom shopping cart.
caAction :: ShoppingCart -> CartAction
-- | Single handling fee to be charged cart-wide. If handling_cart is used
-- in multiple Add to Cart buttons, the handling_cart value of the first
-- item is used.
caHandlingCart :: ShoppingCart -> Maybe Rational
-- | Indicates whether the transaction is payment on a final sale or an
-- authorization for a final sale, to be captured later. The default
-- value is sale.
--
-- Set the value to authorization to place a hold on the PayPal account
-- for the authorized amount. Set the value to order to authorize the
-- transaction without placing a hold on the PayPal account.
--
-- Important: If you set paymentaction to order, you must use the
-- Authorization & Capture API to authorize and capture the
-- transaction payments. The merchant tools on the PayPal websitel let
-- you capture payments only for authorizations, not for orders.
caPaymentAction :: ShoppingCart -> PaymentAction
-- | The URL of the page on the merchant website that buyers return to when
-- they click the Continue Shopping button on the PayPal Shopping Cart
-- page.
--
-- NOTE: If you use this, and the URL contains characters like %
-- then PayPal will mangle them. Also, shopping_url doesn't work for the
-- View Cart button. However, if you don't use this, PayPal seems
-- to use the referrer URL, so it shouldn't be necessary to use this
-- broken feature.
caShoppingURL :: ShoppingCart -> Maybe ByteString
data Duration
D :: Duration
W :: Duration
M :: Duration
Y :: Duration
data WeightUnit
Lb :: WeightUnit
Kg :: WeightUnit
class ToText bt => ButtonType bt where data family Variables bt :: * type family Amount bt :: * type family Shipping bt :: * type family UndefinedQuantity bt :: *
data ButtonSubtype
PRODUCTS :: ButtonSubtype
SERVICES :: ButtonSubtype
data CartAction
Add :: CartAction
Display :: CartAction
Upload :: CartAction
data PaymentAction
Sale :: PaymentAction
Authorization :: PaymentAction
Order :: PaymentAction
data PeriodicPrice
PeriodicPrice :: Rational -> Int -> Duration -> PeriodicPrice
-- | a3 Price of subscription. Must be specified for Subscribe buttons.
-- Value must be a positive number. No currency symbol. Must have two
-- decimal places, decimal separator must be a period (.), and the
-- optional thousands separator must be a comma (,).
ppPrice :: PeriodicPrice -> Rational
-- | p3 Regular billing cycle. Must be specified for Subscribe buttons.
-- Limitations: Must be a positive integer greater than 0 and less than
-- or equal to 30
ppCycle :: PeriodicPrice -> Int
-- | t3 Regular billing cycle units. Must be specified for Subscribe
-- buttons.
ppCycleUnits :: PeriodicPrice -> Duration
newtype HostedButtonID
HostedButtonID :: ByteString -> HostedButtonID
data ButtonInfo t
ButtonInfo :: TypeOfButton -> HostedButtonID -> ByteString -> t -> ButtonInfo t
biButtonType :: ButtonInfo t -> TypeOfButton
biButtonID :: ButtonInfo t -> HostedButtonID
biItemName :: ButtonInfo t -> ByteString
biModifyDate :: ButtonInfo t -> t
data TypeOfButton
CART :: TypeOfButton
GIFTCERTIFICATE :: TypeOfButton
SUBSCRIBE :: TypeOfButton
DONATE :: TypeOfButton
UNSUBSCRIBE :: TypeOfButton
VIEWCART :: TypeOfButton
PAYMENTPLAN :: TypeOfButton
AUTOBILLING :: TypeOfButton
PAYMENT :: TypeOfButton
data ButtonImageType
-- | Regular (default)
REG :: ButtonImageType
-- | Small
SML :: ButtonImageType
-- | small button image with credit card logos; not applicable for
-- Unsubscribe or View Cart buttons
CC :: ButtonImageType
data BuyNowText
-- | Button text is Buy Now (default)
BUYNOW_TEXT :: BuyNowText
-- | Button text is Pay Now
PAYNOW_TEXT :: BuyNowText
data SubscribeText
-- | Button text is Buy Now
BUYNOW_SUBSCRIPTION :: SubscribeText
-- | Button text is Subscribe
SUBSCRIBE_SUBSCRIPTION :: SubscribeText
data HostedButton
HostedButton_CART :: (CreateButton HOSTED CART) -> HostedButton
HostedButton_GIFTCERTIFICATE :: (CreateButton HOSTED GIFTCERTIFICATE) -> HostedButton
HostedButton_SUBSCRIBE :: (CreateButton HOSTED SUBSCRIBE) -> HostedButton
HostedButton_DONATE :: (CreateButton HOSTED DONATE) -> HostedButton
HostedButton_UNSUBSCRIBE :: (CreateButton HOSTED UNSUBSCRIBE) -> HostedButton
HostedButton_VIEWCART :: (CreateButton HOSTED VIEWCART) -> HostedButton
data UpdateButton buttonCode buttonType
UpdateButton :: HostedButtonID -> CreateButton buttonCode buttonType -> UpdateButton buttonCode buttonType
ubButtonID :: UpdateButton buttonCode buttonType -> HostedButtonID
ubDetails :: UpdateButton buttonCode buttonType -> CreateButton buttonCode buttonType
newtype Options
Options :: (Maybe (Option FIRST, [Option NONFIRST])) -> Options
-- | Note: In PayPal naming, 'option' and 'select' are swapped around from
-- the HTML naming.
data Option rank
Option :: Text -> [Select rank] -> Option rank
opName :: Option rank -> Text
opSelects :: Option rank -> [Select rank]
data Select rank
Select :: Text -> RankPrice rank -> Select rank
seName :: Select rank -> Text
sePrice :: Select rank -> RankPrice rank
class Rank r where type family RankPrice r :: *
getRankPrice :: Rank r => r -> RankPrice r -> Maybe Rational
setRankPrice :: Rank r => r -> Maybe Rational -> RankPrice r
data FIRST
data NONFIRST
instance Show (PayPalResponse GetButtonDetails)
instance Show t => Show (PayPalResponse (ButtonSearch t))
instance (Show (Variables buttonType), Show (ButtonText buttonType)) => Show (UpdateButton buttonCode buttonType)
instance Show (PayPalResponse (CreateButton (NONHOSTED bc) bt))
instance Show (PayPalResponse (CreateButton HOSTED bt))
instance (Show (Variables buttonType), Show (ButtonText buttonType)) => Show (CreateButton buttonCode buttonType)
instance Show (RankPrice rank) => Show (Option rank)
instance Show (RankPrice rank) => Show (Select rank)
instance Show (Variables VIEWCART)
instance Show (Variables UNSUBSCRIBE)
instance Show (Variables DONATE)
instance Show (Variables SUBSCRIBE)
instance Show (Variables GIFTCERTIFICATE)
instance Show (Variables CART)
instance Show (Variables BUYNOW)
instance (Show (UndefinedQuantity bt), Show (Shipping bt), Show (Amount bt)) => Show (Item bt)
instance Show Duration
instance Show WeightUnit
instance Show Payment
instance Show CartAction
instance Show PaymentAction
instance Show ShoppingCart
instance Show PeriodicPrice
instance Show Subscription
instance Eq TypeOfButton
instance Ord TypeOfButton
instance Show TypeOfButton
instance Enum TypeOfButton
instance Show ButtonSubtype
instance Show Options
instance Show HostedButtonID
instance Show ButtonImageType
instance Show BuyNowText
instance Show SubscribeText
instance Show t => Show (ButtonInfo t)
instance Show HostedButton
instance PayPalRequest GetButtonDetails
instance ToVariables GetButtonDetails
instance (FormatTime t, ParseTime t) => PayPalRequest (ButtonSearch t)
instance FormatTime t => ToVariables (ButtonSearch t)
instance FromText SubscribeText
instance ToText SubscribeText
instance FromText BuyNowText
instance ToText BuyNowText
instance FromText ButtonImageType
instance ToText ButtonImageType
instance (ToText (NONHOSTED buttonCode), ButtonType bt) => PayPalRequest (CreateButton (NONHOSTED buttonCode) bt)
instance (ToText (NONHOSTED buttonCode), ButtonType bt) => ToVariables (CreateButton (NONHOSTED buttonCode) bt)
instance ButtonType bt => PayPalRequest (CreateButton HOSTED bt)
instance ButtonType bt => ToVariables (CreateButton HOSTED bt)
instance FromVariables Options
instance ToVariables Options
instance Rank NONFIRST
instance Rank FIRST
instance FromText ButtonSubtype
instance ToText ButtonSubtype
instance ButtonType VIEWCART
instance ToText VIEWCART
instance ButtonType UNSUBSCRIBE
instance ToText UNSUBSCRIBE
instance ButtonType DONATE
instance ToText DONATE
instance ButtonType SUBSCRIBE
instance ToText SUBSCRIBE
instance ButtonType GIFTCERTIFICATE
instance ToText GIFTCERTIFICATE
instance ButtonType CART
instance ToText CART
instance FromText TypeOfButton
instance ButtonType BUYNOW
instance ToText BUYNOW
instance ButtonType bt => FromVariables (Item bt)
instance ButtonType bt => ToVariables (Item bt)
instance ToVariables Subscription
instance FromVariables ShoppingCart
instance ToVariables ShoppingCart
instance FromVariables Payment
instance ToVariables Payment
instance FromText WeightUnit
instance ToText WeightUnit
instance ToText Duration
instance ToText (NONHOSTED TOKEN)
instance ToText (NONHOSTED CLEARTEXT)
instance ToText (NONHOSTED ENCRYPTED)
instance ToText HOSTED