public class PaymentImpl extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable, Payment
This class is a value object container for payment-related transactions.
This container can contain a single payment approval/authorization and multiple deposits/captures for the same approval/capture. However, multiple deposits/captures per a single approval/authorization might not be supported by the payment back-end system.
The Payment
container is created before the approval/authorization transaction and
it is used in on subsequently transactions like deposits/captures and reversals.
The Payment Plugin Controller guarantees that:
approve
transaction will be issued against a Payment
pending
for a given
Payment
at the same time.
AVS_COMPLETE_MATCH, AVS_NO_MATCH, AVS_OTHER_RESPONSE, AVS_POSTALCODE_MATCH, AVS_STREET_ADDRESS_MATCH, AVS_UNKNOWN, STATE_APPROVED, STATE_APPROVING, STATE_CANCELED, STATE_EXPIRED, STATE_FAILED, STATE_NEW
Constructor and Description |
---|
PaymentImpl(java.lang.String id,
PaymentInstructionImpl paymentInstruction)
This method creates a
Payment container. |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
This method returns a shallow copy of this
PaymentImpl instance. |
java.math.BigDecimal |
getApprovedAmount()
This method gets the currently approved amount.
|
FinancialTransaction |
getApproveTransaction()
This method gets the
approve transaction container. |
java.math.BigDecimal |
getApprovingAmount()
This method gets the amount being approved.
|
short |
getAvsCode()
This method gets the AVS code associated with the
approve transaction. |
java.math.BigDecimal |
getDepositedAmount()
This method gets the amount currently deposited.
|
java.math.BigDecimal |
getDepositingAmount()
This method gets the amount being deposited.
|
java.util.ArrayList |
getDepositTransactions()
This method gets a list of
deposit transactions. |
java.util.Date |
getExpirationDate()
This method gets the date the payment approval (authorization) is supposed to expire.
|
java.lang.String |
getId()
This method gets the unique identifier of the
Payment container. |
PaymentInstruction |
getPaymentInstruction()
This method gets the
PaymentInstruction container this Payment is associated
with. |
java.util.ArrayList |
getReverseApprovalTransactions()
This method gets a list of
reverse approval transactions. |
java.util.ArrayList |
getReverseDepositTransactions()
This method gets an array of reverse deposit Transactions.
|
java.math.BigDecimal |
getReversingApprovedAmount()
This method gets the reversing deposit amount.
|
java.math.BigDecimal |
getReversingDepositedAmount()
This method gets the deposited amount being reversed.
|
short |
getState()
This method gets the state o the
Payment container. |
static java.lang.String |
getStateAsString(int state)
This method gets a non-globalized human-readable representation of a payment state.
|
java.math.BigDecimal |
getTargetAmount()
This method gets the requested target amount.
|
boolean |
isAttentionRequired()
This method checks if the
Payment requires external intervention. |
boolean |
isExpired()
This method checks if the payment approval (authorization) has expired.
|
void |
setApprovedAmount(java.math.BigDecimal approvedAmount)
This method sets the approved amount after an
approve transaction. |
void |
setApproveTransaction(FinancialTransactionImpl approveTransaction)
This method sets the
approve transaction container. |
void |
setApprovingAmount(java.math.BigDecimal approvingAmount)
This method sets the amount being approved.
|
void |
setAttentionRequired(boolean attentionRequired)
This method sets a flag to indicate that the
Payment requires attention even though all
transactions might have finalized successfully. |
void |
setAvsCode(short avsCode)
This method sets the AVS code for the
approve transaction. |
void |
setDepositedAmount(java.math.BigDecimal depositedAmount)
This method sets the currently deposited amount.
|
void |
setDepositingAmount(java.math.BigDecimal depositingAmount)
This method sets the amount being deposited.
|
void |
setDepositTransactions(java.util.ArrayList depositTransactions)
This method sets a list of
deposit transactions. |
void |
setExpirationDate(java.util.Date expirationDate)
This method sets the expiration date of the
Payment approval (authorization). |
void |
setExpired(boolean expired)
This method indicates if the
Payment approval (authorization) has expired. |
void |
setPaymentInstruction(PaymentInstructionImpl instruction)
This method sets the payment instruction container which this
Payment is associated with. |
void |
setReverseApprovalTransactions(java.util.ArrayList reverseApprovalTransactions)
This method sets the list
approve reversal transactions associated with this
Payment container. |
void |
setReverseDepositTransactions(java.util.ArrayList reverseDepositTransactions)
This method sets a list of
reverse deposit transactions. |
void |
setReversingApprovedAmount(java.math.BigDecimal reversingApprovedAmount)
This method sets the approved amount being reversed.
|
void |
setReversingDepositedAmount(java.math.BigDecimal reversingDepositedAmount)
This method sets the deposited amount being reversed.
|
void |
setState(short state)
This method sets the state of the
Payment container. |
void |
setTargetAmount(java.math.BigDecimal targetAmount)
This method sets the target amount to be processed for the
approve transaction. |
java.lang.String |
toString()
This method prints a human-readable rendering of this container object.
|
public PaymentImpl(java.lang.String id, PaymentInstructionImpl paymentInstruction)
This method creates a Payment
container.
id
- The unique identifier of the Payment
containerpaymentInstruction
- The PaymentInstruction
container this
Payment
is associated with.public void setApproveTransaction(FinancialTransactionImpl approveTransaction)
This method sets the approve
transaction container.
approveTransaction
- The approve transaction container.getApproveTransaction().
public FinancialTransaction getApproveTransaction()
This method gets the approve
transaction container.
getApproveTransaction
in interface Payment
setApproveTransaction(FinancialTransactionImpl)
public void setApprovedAmount(java.math.BigDecimal approvedAmount)
This method sets the approved amount after an approve
transaction.
The plug-ins will invoke this method only if the actually approved amount is different from
the requested approve
transaction amount. This is only possible for back-end
systems that support amounts to be processed that are less that the requested amount.
Plug-ins will also invoke this method when supporting queries.
During approve reversal
transactions, the approved amount should decrease.
Gift Certificate example
Suppose a Plugin supports Gift Certificates(GC). If an approve
asks for $15.00
in a given GC and the GC has actually only $14.45 remaining, the Plugin could approve
$14.45.
This is the rationale: Gift Certificates have very limited amounts and are typically used with other payment methods like Credit Cards. The Gift Certificate is expected to be fully consumed before the Credit Card is charged. If the requested amount cannot be fully processed, the remaining is expected to be processed later on against the Credit Card.
Accepting the behavior above really depends on the Plugin. Even though this scenario is
possible, the Plugin might choose to reject the approve
transaction indicating
that the account limit has been reached.
setApprovedAmount
in interface Payment
approvedAmount
- The approved amount to be set.getApprovedAmount().
public java.math.BigDecimal getApprovedAmount()
This method gets the currently approved amount.
The approved amount will be different from zero only after the initial approve
transaction has successfully finished and before any approve reversal
transactions.
The approved amount can be different from the target amount associated with the
Payment
container. This occurs if the back-end system supports processing less
that the requested amount during an approval
transaction. Also, if reversals
have occurred, the approved amount will be different from the target amount.
For an example of differences between approved amount and target amount, please refer to
setApprovedAmount(BigDecimal)
.
getApprovedAmount
in interface Payment
setApprovedAmount(BigDecimal).
public void setApprovingAmount(java.math.BigDecimal approvingAmount)
Plug-ins will invoke this method when supporting queries.
setApprovingAmount
in interface Payment
approvingAmount
- The amount being approved.getApprovingAmount().
public java.math.BigDecimal getApprovingAmount()
This method gets the amount being approved.
The approving amount will be different from zero when the initial approve
transaction has been issued and not completed. Or if its state stays in pending state pending
after its execution.
getApprovingAmount
in interface Payment
setApprovingAmount(BigDecimal).
public void setAttentionRequired(boolean attentionRequired)
This method sets a flag to indicate that the Payment
requires attention even though all
transactions might have finalized successfully.
External intervention might be required. Typical examples:
Payment.AVS_COMPLETE_MATCH
during approve
and
approveAndDeposit
transactions.
The Plugin might have other reasons to raise this flag that are specific to the payment protocol being implemented.
setAttentionRequired
in interface Payment
attentionRequired
- If the Payment
requires external intervention.isAttentionRequired().
public boolean isAttentionRequired()
This method checks if the Payment
requires external intervention.
isAttentionRequired
in interface Payment
Payment
requires external intervention.setAttentionRequired(boolean).
public void setAvsCode(short avsCode)
This method sets the AVS code for the approve
transaction.
AVS stands for Address Verification System/Service. An AVS code is typically returned by a payment back-end system during approvals (authorization) transactions. When there is a mismatch between the billing address specified in the transaction and the actual billing address registered in the account being charged.
Plug-ins are responsible for setting the AVS code for approve
transactions
whenever necessary. If plug-ins do not set the AVS code, the Payment Plugin Controller will
use Payment.AVS_COMPLETE_MATCH
.
These are the possible AVS codes:
setAvsCode
in interface Payment
avsCode
- The AVS code to be set.getAvsCode().
public short getAvsCode()
This method gets the AVS code associated with the approve
transaction.
These are the possible AVS codes:
getAvsCode
in interface Payment
setAvsCode(short).
public void setDepositTransactions(java.util.ArrayList depositTransactions)
This method sets a list of deposit
transactions.
Each element in the list is a FinancialTransaction
.
depositTransactions
- A list of FinancialTransaction
containing deposit
transactions to be set.getDepositTransactions().
public java.util.ArrayList getDepositTransactions()
This method gets a list of deposit
transactions.
Each element in the list is a FinancialTransaction
.
getDepositTransactions
in interface Payment
FinancialTransaction
with deposits; this list
is potentially empty.getDepositTransactions().
public void setDepositedAmount(java.math.BigDecimal depositedAmount)
This method sets the currently deposited amount.
The deposited amount is set by the Payment Plugin Controller on a successful
deposit
transaction. If multiple deposits have been made against a Payment
this will represent the sum of the deposited amounts of all the individual transactions.
Plug-ins will invoke this method when supporting queries.
setDepositedAmount
in interface Payment
depositedAmount
- The targetAmount deposited by the back-end system.getDepositedAmount().
public java.math.BigDecimal getDepositedAmount()
This method gets the amount currently deposited.
If multiple deposits have been made against a Payment
, this amount will
represent the total amount deposited for all deposit
transactions, that is,
the sum of all the individual deposit
transaction amounts.
getDepositedAmount
in interface Payment
Payment
.setDepositedAmount(BigDecimal).
public void setDepositingAmount(java.math.BigDecimal depositingAmount)
This method sets the amount being deposited.
The Payment Plugin Controller will set the depositing amount on deposit
transactions that go to the state FinancialTransaction.STATE_PENDING
.
Plug-ins will invoke this method when supporting queries.
setDepositingAmount
in interface Payment
depositingAmount
- The amount being deposited.getDepositingAmount().
public java.math.BigDecimal getDepositingAmount()
This method gets the amount being deposited.
getDepositingAmount
in interface Payment
setDepositingAmount(BigDecimal).
public void setExpirationDate(java.util.Date expirationDate)
This method sets the expiration date of the Payment
approval (authorization).
The expiration date is expressed on GMT standard time.
Plug-ins will invoke this method when supporting queries.
setExpirationDate
in interface Payment
expirationDate
- The expiration date to be set.isExpired().
,
setExpired(boolean).
,
getExpirationDate().
,
PluginConfiguration
public java.util.Date getExpirationDate()
This method gets the date the payment approval (authorization) is supposed to expire.
This value is calculated by the Payment Plugin Controller based on the actual approval timestamp and the Plugin configuration of the expiration .
getExpirationDate
in interface Payment
isExpired()
,
setExpired(boolean).
,
setExpirationDate(Date).
public void setExpired(boolean expired)
This method indicates if the Payment
approval (authorization) has expired.
This flag indicates if the payment approval (authorization) has expired while the expiration
date is an expected expiration date. Note that if the Plugin configuration is not done
correctly (PluginConfiguration
), the expiration date and the
actual time of the expiration might vary considerably.
setExpired
in interface Payment
expired
- Whether thePayment
approval has expired or not.isExpired().
,
getExpirationDate().
,
setExpirationDate(Date).
,
PluginConfiguration
public boolean isExpired()
This method checks if the payment approval (authorization) has expired.
isExpired
in interface Payment
setExpired(boolean).
,
getExpirationDate().
,
setExpirationDate(Date).
public java.lang.String getId()
This method gets the unique identifier of the Payment
container.
public void setPaymentInstruction(PaymentInstructionImpl instruction)
This method sets the payment instruction container which this Payment
is associated with.
instruction
- The PaymentInstruction
to be associated with this
Payment
container.getPaymentInstruction().
public PaymentInstruction getPaymentInstruction()
This method gets the PaymentInstruction
container this Payment
is associated
with.
getPaymentInstruction
in interface Payment
PaymentInstruction
this payment is associated with.setPaymentInstruction(PaymentInstructionImpl)
public void setReverseApprovalTransactions(java.util.ArrayList reverseApprovalTransactions)
This method sets the list approve reversal
transactions associated with this
Payment
container.
Each element of the list is a FinancialTransaction
.
reverseApprovalTransactions
- The list of FinancialTransaction
containing approve reversal
transactions.getReverseApprovalTransactions().
public java.util.ArrayList getReverseApprovalTransactions()
This method gets a list of reverse approval
transactions.
Each of the element in the list is a FinancialTransaction
.
getReverseApprovalTransactions
in interface Payment
FinancialTransaction
with reverse approve
transaction.setReverseApprovalTransactions(ArrayList).
public void setReverseDepositTransactions(java.util.ArrayList reverseDepositTransactions)
This method sets a list of reverse deposit
transactions.
Each element in the list is a FinancialTransaction
.
reverseDepositTransactions
- A list containing FinancialTransaction
objects that represent a reverse deposit
transaction.getReverseDepositTransactions().
public java.util.ArrayList getReverseDepositTransactions()
This method gets an array of reverse deposit Transactions.
Each element in the list is a FinancialTransaction
.
getReverseDepositTransactions
in interface Payment
FinancialTransaction
objects that
represent a reverse deposit
transaction.setReverseDepositTransactions(ArrayList).
public void setReversingApprovedAmount(java.math.BigDecimal reversingApprovedAmount)
This method sets the approved amount being reversed.
Plug-ins will invoke this method when supporting queries.
setReversingApprovedAmount
in interface Payment
reversingApprovedAmount
- The approved amount being reversed.getReversingApprovedAmount().
public java.math.BigDecimal getReversingApprovedAmount()
This method gets the reversing deposit amount.
getReversingApprovedAmount
in interface Payment
setReversingApprovedAmount(BigDecimal).
public void setReversingDepositedAmount(java.math.BigDecimal reversingDepositedAmount)
This method sets the deposited amount being reversed.
Plug-ins will invoke this method when supporting queries.
setReversingDepositedAmount
in interface Payment
reversingDepositedAmount
- The deposited amount being reversed.getReversingDepositedAmount().
public java.math.BigDecimal getReversingDepositedAmount()
This method gets the deposited amount being reversed.
getReversingDepositedAmount
in interface Payment
setReversingDepositedAmount(BigDecimal).
public void setState(short state) throws InvalidDataException
This method sets the state of the Payment
container.
These are the validate state values:
state
- The new state of the Payment
container to be set.InvalidDataException
- If an invalid state is specified.getState().
public short getState()
This method gets the state o the Payment
container.
These are the validate state values:
getState
in interface Payment
Payment
container.setState(short).
public static java.lang.String getStateAsString(int state)
state
- The payment state.public void setTargetAmount(java.math.BigDecimal targetAmount)
This method sets the target amount to be processed for the approve
transaction.
targetAmount
- The amount that has been requested to be approved by the back-end system.Payment.getTargetAmount().
public java.math.BigDecimal getTargetAmount()
This method gets the requested target amount.
getTargetAmount
in interface Payment
Payment
container.setTargetAmount(BigDecimal).
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
This method returns a shallow copy of this PaymentImpl
instance.
clone
in class java.lang.Object
PaymentImpl
instance.java.lang.CloneNotSupportedException
- If the instance cannot be cloned.