paypal-adaptive-hoops-0.13.1.0: src/PayPal/Adaptive/Core/PayResponse/PaymentInfo.hs
{-# LANGUAGE TemplateHaskell #-}
module PayPal.Adaptive.Core.PayResponse.PaymentInfo
( module Export
, module PayPal.Adaptive.Core.PayResponse.PaymentInfo
) where
import Data.Aeson.TH
import Data.Char (toLower)
import Import
import PayPal.Adaptive.Core.PayResponse.PaymentInfo.Receiver as Export
import PayPal.Adaptive.Core.PayResponse.PaymentInfo.TransactionId as Export
import PayPal.Adaptive.Core.PayResponse.PaymentInfo.TransactionStatus as Export
-- | Right toPayPal responses return a PayInfo along with a
-- _piTransactionStatus Just, with some exceptions.
--
-- 1. Withdrawals to nonexistent accounts return no PayInfos.
--
-- 2. Lookups on such transactions return one PayInfo with a
-- _piTransactionStatus of Nothing.
--
-- 3. Deposits don't return PayInfos.
--
-- 4. 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.
--
--
-- https://developer.paypal.com/docs/classic/api/adaptive-payments/PaymentDetails_API_Operation/
--
-- Represents the payment attempt made to a receiver of a PayRequest. If the execution of the payment has not yet completed, there are no transaction details returned.
data PaymentInfo = PaymentInfo
{ _piReceiver :: Receiver
, _piTransactionId :: Maybe TransactionId
, _piTransactionStatus :: Maybe TransactionStatus
, _piSenderTransactionId :: Maybe TransactionId
, _piSenderTransactionStatus :: Maybe TransactionStatus
} deriving (Eq, Show)
$(deriveFromJSON defaultOptions { fieldLabelModifier = (\(x:xs) -> toLower x:xs) . drop 3 } ''PaymentInfo)
$(makeLenses ''PaymentInfo)