public class CreditImpl extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable, Credit
This class is a value object container for credit-related transactions.
Possible financial transactions associated with a Credit are:
A Credit container supports only one credit transaction during its life-span. However, multiple reversals might be supported for the same credit transaction.
Note that since this is a value object, no financial transaction will actually happen through this object. But rather this object contains information associated with the financial transactions before, during and after the processing of them.
Credits are some times referred as refunds when associated with an RMA (Refund Merchandise Authorization).
Dependent and independent credits
Credit transactions can be classified as dependent and independent. Dependent credits are transactions associated with a PaymentInstruction where deposits have already taken place. For example, after a deposit of $100.00, a credit up to $100.00 would be considered a dependent credit. In the other hand, independent credits are transactions associated with a PaymentInstruction where no previous deposits have taken place or the amount of credit goes beyond of the previously deposited amount. For example, after a deposit of $100.00, a credit of $150.00 would be an independent credit. Also, without any previous deposit, a credit of any dollar amount would be a dependent credit. A plug-in can access Payment containers associated with a PaymentInstruction to determine if a credit transaction depends on a previous deposit transaction. If that is the case, the credit transaction is a dependent one. Otherwise, it is an independent credit transaction.
Support for dependent and independent credits might vary among payment back-end systems.
Credits are always associated with a PaymentInstruction container. A PaymentInstruction keeps references to all Payment containers and all Credit containers associated with it.
A plug-in can access the associated Payment containers to determine if a credit transaction depends on a previous deposit transaction. If that is the case, the credit transaction is a dependent credit and the plug-in can proceed accordingly. Otherwise, the transaction is an independent credit and the plug-in has to deal with it as such.
Online and offline processing.
Online refers to the processing of financial transactions that do not require external intervention for successful execution. In other words, the complete process of the financial transaction is done electronically and automatically without needing any external/human intervention.
Offline refers to the processing of financial transactions that require external intervention for successful execution. For example, when a credit card needs to be processed over the phone or through a swipe box. The processing of the credit card is considered offline.
Constructor and Description |
---|
CreditImpl(java.lang.String id, PaymentInstructionImpl paymentInstruction, java.math.BigDecimal targetAmount)
This method creates a Credit container associated with a particular PaymentInstruction.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object | clone()
This method returns a shallow copy of this CreditImpl instance.
|
java.math.BigDecimal | getCreditedAmount()
This method gets the currently credited amount.
|
java.math.BigDecimal | getCreditingAmount()
This method gets the amount being currently credited.
|
FinancialTransaction | getCreditTransaction()
This method gets the associated credit transaction if any.
|
java.lang.String | getId()
This method gets the unique identifier of the Credit container.
|
PaymentInstruction | getPaymentInstruction()
This method gets the associated PaymentInstruction.
|
java.util.ArrayList | getReverseCreditTransactions()
This method gets the list of credit reversal transactions.
|
java.math.BigDecimal | getReversingAmount()
This method gets the reversingAmount.
|
short | getState()
This method gets the current state of the Credit container.
|
static java.lang.String | getStateAsString(int state)
This method gets a non-globalized human-readable representation of a credit state.
|
java.math.BigDecimal | getTargetAmount()
This method gets the amount that is the target as the total to be credited in the life-time of the container.
|
void | setCreditedAmount(java.math.BigDecimal creditedAmount)
This method sets the amount credited in the container.
|
void | setCreditingAmount(java.math.BigDecimal creditingAmount)
This method sets the amount being credited, that is, in pending to be credited.
|
void | setCreditTransaction(FinancialTransactionImpl creditTransaction)
This method sets the credit transaction to the Credit container.
|
void | setPaymentInstruction(PaymentInstructionImpl instruction)
This method sets the payment instruction container which this credit is associated with.
|
void | setReverseCreditTransactions(java.util.ArrayList reverseTransactions)
This method sets the list of credit reversal transactions.
|
void | setReversingAmount(java.math.BigDecimal reversingAmount)
This method sets the reverse credited amount.
|
void | setState(short state)
This method sets the state of the Credit container.
|
java.lang.String | toString()
This method obtains a human-readable representation of the Credit container.
|
public CreditImpl(java.lang.String id, PaymentInstructionImpl paymentInstruction, java.math.BigDecimal targetAmount)
This method creates a Credit container associated with a particular PaymentInstruction.
public void setCreditTransaction(FinancialTransactionImpl creditTransaction)
This method sets the credit transaction to the Credit container.
Plug-ins will invoke this method when optionally supporting a credit query.
public FinancialTransaction getCreditTransaction()
This method gets the associated credit transaction if any.
This method allows a plug-in to obtain the credit transaction that has been executed under the Credit.
public void setCreditedAmount(java.math.BigDecimal creditedAmount)
This method sets the amount credited in the container.
Plug-ins will invoke this method when supporting queries.
public java.math.BigDecimal getCreditedAmount()
This method gets the currently credited amount.
Plug-ins can use this method to verify how much has been actually credited after a successful credit transaction. Usually the actual credited amount is the same of the requested amount. However, some payment back-end systems might process a different amount.
public void setCreditingAmount(java.math.BigDecimal creditingAmount)
This method sets the amount being credited, that is, in pending to be credited.
Plug-ins will invoke this method when supporting queries.
public java.math.BigDecimal getCreditingAmount()
This method gets the amount being currently credited.
Plug-ins can use this method to verify how much credit is in pending. credit transactions might go in pending for a variety of reasons including slow network processing, timeouts and when offline processing is required. Offline processing typically requires human interaction to process transactions over the phone or through a swipe machine.
public java.lang.String getId()
This method gets the unique identifier of the Credit container.
public void setPaymentInstruction(PaymentInstructionImpl instruction)
This method sets the payment instruction container which this credit is associated with.
public PaymentInstruction getPaymentInstruction()
This method gets the associated PaymentInstruction.
Plug-ins need to use the PaymentInstruction to determine if a credit transaction is dependent or independent.
public void setReverseCreditTransactions(java.util.ArrayList reverseTransactions)
This method sets the list of credit reversal transactions. The list contains all of the credit reversals processed under the Credit container.
Each of the elements in reverseTransactions is a FinancialTransaction container.
Plug-ins will invoke this method when supporting credit queries.
public java.util.ArrayList getReverseCreditTransactions()
This method gets the list of credit reversal transactions.
This method allows a plug-in to obtain all the credit reversal transactions that have been executed against the Credit container.
Each of the elements in the array is a FinancialTransaction.
public void setReversingAmount(java.math.BigDecimal reversingAmount)
This method sets the reverse credited amount.
Plug-ins will invoke this method when supporting credit queries.
public java.math.BigDecimal getReversingAmount()
This method gets the reversingAmount.
public void setState(short state) throws InvalidDataException
This method sets the state of the Credit container.
Plug-ins will invoke this method when supporting queries.
Valid values:
public short getState()
This method gets the current state of the Credit container.
Valid values:
public static java.lang.String getStateAsString(int state)
public java.math.BigDecimal getTargetAmount()
This method gets the amount that is the target as the total to be credited in the life-time of the container.
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
This method returns a shallow copy of this CreditImpl instance.