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:
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.
public void setApproveTransaction(FinancialTransactionImpl approveTransaction)
This method sets the approve transaction container.
public FinancialTransaction getApproveTransaction()
This method gets the approve transaction container.
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.
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).
public void setApprovingAmount(java.math.BigDecimal approvingAmount)
Plug-ins will invoke this method when supporting queries.
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.
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:
The Plugin might have other reasons to raise this flag that are specific to the payment protocol being implemented.
public boolean isAttentionRequired()
This method checks if the Payment requires external intervention.
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:
public short getAvsCode()
This method gets the AVS code associated with the approve transaction.
These are the possible AVS codes:
public void setDepositTransactions(java.util.ArrayList depositTransactions)
This method sets a list of deposit transactions.
Each element in the list is a FinancialTransaction.
public java.util.ArrayList getDepositTransactions()
This method gets a list of deposit transactions.
Each element in the list is a FinancialTransaction.
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.
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.
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.
public java.math.BigDecimal getDepositingAmount()
This method gets the amount being deposited.
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.
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 .
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.
public boolean isExpired()
This method checks if the payment approval (authorization) has expired.
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.
public PaymentInstruction getPaymentInstruction()
This method gets the PaymentInstruction container this Payment is associated with.
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.
public java.util.ArrayList getReverseApprovalTransactions()
This method gets a list of reverse approval transactions.
Each of the element in the list is a FinancialTransaction.
public void setReverseDepositTransactions(java.util.ArrayList reverseDepositTransactions)
This method sets a list of reverse deposit transactions.
Each element in the list is a FinancialTransaction.
public java.util.ArrayList getReverseDepositTransactions()
This method gets an array of reverse deposit Transactions.
Each element in the list is a FinancialTransaction.
public void setReversingApprovedAmount(java.math.BigDecimal reversingApprovedAmount)
This method sets the approved amount being reversed.
Plug-ins will invoke this method when supporting queries.
public java.math.BigDecimal getReversingApprovedAmount()
This method gets the reversing deposit amount.
public void setReversingDepositedAmount(java.math.BigDecimal reversingDepositedAmount)
This method sets the deposited amount being reversed.
Plug-ins will invoke this method when supporting queries.
public java.math.BigDecimal getReversingDepositedAmount()
This method gets the deposited amount being reversed.
public void setState(short state) throws InvalidDataException
This method sets the state of the Payment container.
These are the validate state values:
public short getState()
This method gets the state o the Payment container.
These are the validate state values:
public static java.lang.String getStateAsString(int state)
public void setTargetAmount(java.math.BigDecimal targetAmount)
This method sets the target amount to be processed for the approve transaction.
public java.math.BigDecimal getTargetAmount()
This method gets the requested target amount.
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
This method returns a shallow copy of this PaymentImpl instance.