Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Client = Client {}
- data Env
- class AdaptiveAPI a where
- data AdaptiveErr
- data Withdrawal = Withdrawal {}
- data Deposit = Deposit {
- _dpAmount :: Money
- _dpSenderEmail :: Text
- _dpReturnUrl :: Text
- _dpCancelUrl :: Text
- approvalUrl :: Client -> PayKey -> Text
- data LookupPayment a where
- data PayResp = PayResp {}
- 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
Documentation
class AdaptiveAPI a where Source
AdaptiveAPI Deposit | |
AdaptiveAPI Withdrawal | Sending a payment to a PayPal account that doesn't exist yet
returns a PayResp with an empty list of PayInfos. We return this
as Left |
AdaptiveAPI (LookupPayment a) |
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 | AeInvalidCredentials just a wrapper around an AeErrCodes Int. |
AeNoSuchEmail | AeNoSuchEmail is just a wrapper around an AeErrCodes Int. It's raised when the Deposit sender email or the Withdrawal account email doesn't exist. |
AeErrCodes [Int] | |
AePending PayResp | |
AeRefused PayResp | |
AeShouldNotHappen PayResp Text |
data Withdrawal Source
Send a single payment from your account.
Pay operation docs: https://developer.paypal.com/docs/classic/api/adaptive-payments/Pay_API_Operation/
This is a "Simple Payment" which means there's a single sender and receiver (same as Deposit).
It uses the Implicit payment approval type, meaning the application making the API call must also be the sender of the payment.
Withdrawal | |
|
Eq Withdrawal | |
Show Withdrawal | |
Default Withdrawal | |
AdaptiveAPI Withdrawal | Sending a payment to a PayPal account that doesn't exist yet
returns a PayResp with an empty list of PayInfos. We return this
as Left |
Start the process of someone paying you. You have to redirect the payer's browser to PayPal to finish it.
Pay operation docs: https://developer.paypal.com/docs/classic/api/adaptive-payments/Pay_API_Operation/
This is a "Simple Payment" which means there's a single sender and receiver (same as Withdrawal).
It uses the Explicit payment approval type, meaning the payer must go to PayPal in their browser to approve the payment. Here's an example payment approval URL with a PayKey of "foo":
https://www.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=foo
Deposit | |
|
approvalUrl :: Client -> PayKey -> Text Source
data LookupPayment a where Source
Look up information about a payment.
https://developer.paypal.com/docs/classic/api/adaptive-payments/PaymentDetails_API_Operation/
LookupTrID :: TransactionId -> LookupPayment TransactionId | |
LookupPayKey :: PayKey -> LookupPayment PayKey |
ToJSON (LookupPayment a) | |
AdaptiveAPI (LookupPayment a) |
PayResp | |
|
data PayExecStatus Source
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
m2Currency :: Money -> Text Source