Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Client = Client {}
- data Env
- data AdaptiveErr
- data PayResp = PayResp {}
- data CompletePayResp = CompletePayResp {}
- checkComplete :: PayResp -> Either AdaptiveErr CompletePayResp
- data PayExecStatus
- newtype PayKey = PayKey {}
- data PayInfo = PayInfo {}
- data Receiver = Receiver {}
- newtype TransactionId = TransactionId {}
- data TransactionStatus
- data Money = USD {}
- m2Currency :: Money -> Text
- m2PayPal :: Money -> String
- clUserId :: Lens' Client Text
- clSig :: Lens' Client Text
- clPassword :: Lens' Client Text
- clEnv :: Lens' Client Env
- clAppId :: Lens' Client Text
- clAccountEmail :: Lens' Client Text
- crTransactionId :: Lens' CompletePayResp TransactionId
- crSenderTransactionId :: Lens' CompletePayResp TransactionId
- crReceiver :: Lens' CompletePayResp Receiver
- crPayKey :: Lens' CompletePayResp PayKey
- _AeShouldNotHappen :: Prism' AdaptiveErr (PayResp, Text)
- _AeRefused :: Prism' AdaptiveErr PayResp
- _AePending :: Prism' AdaptiveErr PayResp
- _AeErrCodes :: Prism' AdaptiveErr [Int]
- _AeNoSuchEmail :: Prism' AdaptiveErr ()
- _AeInvalidCredentials :: Prism' AdaptiveErr ()
- _AeDecodeFailed :: Prism' AdaptiveErr (ByteString, Text)
- _AeConnectionErr :: Prism' AdaptiveErr Text
- _Production :: Prism' Env ()
- _Sandbox :: Prism' Env ()
- _PePending :: Prism' PayExecStatus ()
- _PeProcessing :: Prism' PayExecStatus ()
- _PeReversalError :: Prism' PayExecStatus ()
- _PeError :: Prism' PayExecStatus ()
- _PeIncomplete :: Prism' PayExecStatus ()
- _PeCompleted :: Prism' PayExecStatus ()
- _PeCreated :: Prism' PayExecStatus ()
- piTransactionStatus :: Lens' PayInfo (Maybe TransactionStatus)
- piTransactionId :: Lens' PayInfo (Maybe TransactionId)
- piSenderTransactionId :: Lens' PayInfo (Maybe TransactionId)
- piReceiver :: Lens' PayInfo Receiver
- prPayKey :: Lens' PayResp PayKey
- prPayInfos :: Lens' PayResp [PayInfo]
- prPayExecStatus :: Lens' PayResp PayExecStatus
- prPayError :: Lens' PayResp (Maybe Text)
- reEmail :: Lens' Receiver Text
- reAmount :: Lens' Receiver Text
- reAccountId :: Lens' Receiver Text
- _TransactionId :: Iso' TransactionId Text
- _TsFailed :: Prism' TransactionStatus ()
- _TsRefunded :: Prism' TransactionStatus ()
- _TsReversed :: Prism' TransactionStatus ()
- _TsProcessing :: Prism' TransactionStatus ()
- _TsDenied :: Prism' TransactionStatus ()
- _TsPartiallyRefunded :: Prism' TransactionStatus ()
- _TsCreated :: Prism' TransactionStatus ()
- _TsPending :: Prism' TransactionStatus ()
- _TsCompleted :: Prism' TransactionStatus ()
Client
Errors
data AdaptiveErr Source
Text is an error message in all the below types.
AeShouldNotHappen is meant to cover PayPal responses to API requests that this library doesn't support sending in the first place. TODO: is this actually how we're using it?
AeConnectionErr Text | |
AeDecodeFailed ByteString Text | |
AeInvalidCredentials | Just a wrapper around an AeErrCodes Int. |
AeNoSuchEmail | Just a wrapper around an AeErrCodes Int. Raised when the Deposit sender email or the Withdrawal account email doesn't exist. |
AeErrCodes [Int] | |
AePending PayResp | |
AeRefused PayResp | |
AeShouldNotHappen PayResp Text |
Payment Responses
Used for forgiving attempts to parse PayPal responses. For instance,
this library never expects more than one PayInfo. We still try to
parse them as a list here so we can still sucessfully parse a PayResp
to use in an AdaptiveError
if for some reason more than one PayInfo
is returned
PayResp | |
|
data CompletePayResp Source
A version of PayResp
for completed transactions.
Status fields are omitted since they should be complete.
Has no separate field for a PayInfo
list since successful transactions
will always have exactly one. Instead the pay info fields have been
flattened into the top level of this structure.
data PayExecStatus Source
This refers to the processing of this request. To make sure a payment
has actually gone through, check TransactionStatus
instead.
PayPal returns this using the JSON object key "paymentExecStatus" in responses to Withdrawal and Deposit and "status" in responses to LookupPayment.
Expires after three hours.
https://developer.paypal.com/docs/classic/api/adaptive-payments/Pay_API_Operation/
Right toPayPal responses return a PayInfo along with a _piTransactionStatus Just, with some exceptions.
Withdrawals to nonexistent accounts return no PayInfos.
- Lookups on such transactions return one PayInfo with a _piTransactionStatus of Nothing.
- Deposits don't return PayInfos.
- Lookups on such transactions return one PayInfo with a _piTransactionStatus of Nothing.
NOTE: We use the same newtype for both _piSenderTransactionId and _piTransactionStatus. They will have different values, but either can be used to look up a payment.
newtype TransactionId Source
data TransactionStatus Source
Money
m2Currency :: Money -> Text Source
Lenses
_Production :: Prism' Env () Source
_PePending :: Prism' PayExecStatus () Source
_PeError :: Prism' PayExecStatus () Source
_PeCreated :: Prism' PayExecStatus () Source
prPayInfos :: Lens' PayResp [PayInfo] Source