public class FinancialTransactionImpl extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable, FinancialTransaction
This class is a value object container representing a financial transaction.
A FinancialTransaction
container represents all possible types of financial
transactions processed by a Plugin. Depending on the actual transaction type, different
attributes will be available.
These are the transaction types supported in this specification:
Plug-ins are responsible for updating this containers while processing financial transactions.
Several attributes are predefined in the FinancialTransaction
container. However, the plug-in might also need to add additional information to the
FinancialTransaction
container by using the associated
ExtendedData
.
Response code, reason code, reference number and tracking ID
Theresponse code
is a back-end system specific representation of a financial
transaction result. It is typically used by the backend system to indicate if the financial
transaction was successful or not. For example, it might indicate that a credit card
authorization failed.
The reason code
is a back-end system specific representation of an error condition.
It is typically used by the backend system to indicate why a financial transaction failed.
For example, it might indicate that a credit card has expired.
When the response code
alone cannot determine what has happened in a
financial transaction, the reason code
can be used to precisely determine a
financial transaction error.
The response code
and the reason code
can also be seen as a primary
and secondary error codes. As back-end system specific, these codes are used in problem determination
whenever the standard plug-in mechanisms do not suffice.
The tracking ID
is an optional attribute used by the plug-in to identify
the financial transaction in the payment back-end system on behalf of the merchant.
The tracking ID
is set by the plug-in during the processing of financial
transactions. The plug-in generates this ID and has to make sure it is unique in the plug-in and
in the backend system realm. Although optional, the tracking ID
might be the only way to
track a financial transaction in the backend system if an error occurs. For example, during a
financial transaction, the connection can be lost. And the plug-in wouldn't be able to tell
if the backend system actually processed the transaction. The tracking ID
would be the
mechanism to query the back-end system later on, once connectivity is re-stablished. If the
tracking ID
is known by the backend system it means the transaction has reached the
backend system. If it is unknown, the transaction needs to be executed again.
The reference number
is an ID generated by the payment back-end system
during the processing of financial transactions. The reference number
is usually
required by back-end systems to process subsequent (and related) financial transactions.
For example, during a deposit
transaction the reference number
of
a previous approve
transaction is required. In this case, the reference
number
is the authorization code returned by the backend system during the approve
transaction.
While the tracking ID
is used to identify a financial transaction from the
plug-in perspective, the reference number
is used to identify a financial
transaction from the payment back-end system perspective. The tracking ID
is the
first identifier of the financial transaction to exist. Once the reference number
is obtained from the backend system, the plug-ins might not need the tracking ID
anymore
since the reference number
is known by both parties: the plug-in and the
payment back-end system.
STATE_CANCELED, STATE_FAILED, STATE_NEW, STATE_PENDING, STATE_SUCCESS, TRANSACTION_TYPE_APPROVE, TRANSACTION_TYPE_APPROVE_AND_DEPOSIT, TRANSACTION_TYPE_CREDIT, TRANSACTION_TYPE_DEPOSIT, TRANSACTION_TYPE_REVERSE_APPROVAL, TRANSACTION_TYPE_REVERSE_CREDIT, TRANSACTION_TYPE_REVERSE_DEPOSIT
Constructor and Description |
---|
FinancialTransactionImpl(java.lang.String id)
This method creates a
FinancialTransaction container. |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
This method returns a shallow copy of this
FinancialTransactionImpl instance. |
Credit |
getCredit()
This method gets the
Credit container that is associated with the financial transaction. |
ExtendedData |
getExtendedData()
This method gets the extra data associated with the financial transaction.
|
java.lang.String |
getId()
This method gets the unique identifier of the
FinancialTransaction container. |
Payment |
getPayment()
This method gets the
Payment container that is associated with the financial transaction. |
java.math.BigDecimal |
getProcessedAmount()
This method gets the actual processed amount.
|
java.lang.String |
getReasonCode()
This method gets the reason for a failed financial transaction.
|
java.lang.String |
getReferenceNumber()
This method gets the reference number of the financial transaction.
|
java.math.BigDecimal |
getRequestedAmount()
This method gets the amount to be processed in a financial transaction.
|
java.lang.String |
getResponseCode()
This method gets the back-end system specific result of the financial transaction.
|
short |
getState()
This method gets the state of the financial transaction.
|
static java.lang.String |
getStateAsString(int state)
This method gets a non-globalized human-readable representation of a payment instruction state.
|
java.util.Date |
getTimeCreated()
This method gets the time the
FinancialTransaction was created. |
java.util.Date |
getTimeUpdated()
This method gets the most recent time that the
FinancialTransaction was updated. |
java.lang.String |
getTrackingId()
This method gets the
FinancialTransaction tracking ID. |
short |
getTransactionType()
This method gets the type of the
FinancialTransaction . |
void |
setCredit(CreditImpl credit)
This method sets the
Credit container this FinancialTransaction is associated with. |
void |
setExtendedData(ExtendedData extendedData)
This method adds extended data to the
FinancialTransaction container. |
void |
setPayment(PaymentImpl payment)
This method sets the
Payment container that is associated with the
FinancialTransaction container. |
void |
setProcessedAmount(java.math.BigDecimal processedAmount)
This method sets the amount actually processed in the financial transaction.
|
void |
setReasonCode(java.lang.String reasonCode)
This method sets the reason for a failed transaction.
|
void |
setReferenceNumber(java.lang.String referenceNumber)
This method sets the reference number of the financial transaction.
|
void |
setRequestedAmount(java.math.BigDecimal requestedAmount)
This method sets the amount to be processed in a financial transaction.
|
void |
setResponseCode(java.lang.String responseCode)
This method sets the back-end system specific result of the financial transaction.
|
void |
setState(short state)
This method sets the state of the
FinancialTransaction . |
void |
setTimeCreated(java.util.Date timeCreated)
This method sets the time the
FinancialTransaction was created. |
void |
setTimeUpdated(java.util.Date timeUpdated)
This method sets the time the
FinancialTransaction was last updated. |
void |
setTrackingId(java.lang.String trackingId)
This method sets the
FinancialTransaction tracking identifier. |
void |
setTransactionType(short transactionType)
This method sets the type of the
FinancialTransaction . |
java.lang.String |
toString()
This method obtains a human-readable description of the contents of the
FinancialTransaction container. |
public FinancialTransactionImpl(java.lang.String id)
FinancialTransaction
container.id
- The unique identifier of the FinancialTransaction
public void setCredit(CreditImpl credit)
This method sets the Credit
container this FinancialTransaction
is associated with.
This method is used for FinancialTransaction
s with the types
FinancialTransaction.TRANSACTION_TYPE_CREDIT
and FinancialTransaction.TRANSACTION_TYPE_REVERSE_CREDIT
.
credit
- The Credit
container associated with this
FinancialTransaction
getCredit()
public Credit getCredit()
This method gets the Credit
container that is associated with the financial transaction.
The Credit
container will be present only for transactions of the types
FinancialTransaction.TRANSACTION_TYPE_CREDIT
and FinancialTransaction.TRANSACTION_TYPE_REVERSE_CREDIT
.
getCredit
in interface FinancialTransaction
Credit
container associated with this FinancialTransaction
setCredit(CreditImpl)
public void setExtendedData(ExtendedData extendedData)
This method adds extended data to the FinancialTransaction
container.
The information passed here will be added to the existing extended data associated to the financial transaction. If any mapped value already exists it will be replaced with the new value.
The plug-in invokes this method when additional information needs to be added to
The FinancialTransaction
container during the processing of a financial
transaction. The information might be required in subsequent financial transactions.
setExtendedData
in interface FinancialTransaction
extendedData
- The map of name-value pairs representing extended payment
informationgetExtendedData()
public ExtendedData getExtendedData()
This method gets the extra data associated with the financial transaction.
getExtendedData
in interface FinancialTransaction
setExtendedData(ExtendedData)
public void setReferenceNumber(java.lang.String referenceNumber)
This method sets the reference number of the financial transaction.
The plug-in needs to invoke this method during the processing of a financial transaction to update the reference number from the payment back-end system. This field is the unique identifier of the financial transaction from the payment back-end system perspective. For more details, please refer to the introduction of this Javadoc.
setReferenceNumber
in interface FinancialTransaction
referenceNumber
- The unique identifier of the financial transaction from
the payment backend system perspective.getReferenceNumber().
public java.lang.String getReferenceNumber()
This method gets the reference number of the financial transaction.
This field is the unique identifier of the financial transaction from the payment back-end system perspective. For more details, please refer to the introduction of this Javadoc.
getReferenceNumber
in interface FinancialTransaction
setReferenceNumber(String).
public java.lang.String getId()
This method gets the unique identifier of the FinancialTransaction
container.
This ID is guaranteed to be unique by the Payment Plug-in Controller.
getId
in interface FinancialTransaction
FinancialTransaction
container.public void setPayment(PaymentImpl payment)
This method sets the Payment
container that is associated with the
FinancialTransaction
container. This is only set for
financial transactions with these types:
FinancialTransaction.TRANSACTION_TYPE_APPROVE
, FinancialTransaction.TRANSACTION_TYPE_DEPOSIT
,
FinancialTransaction.TRANSACTION_TYPE_REVERSE_APPROVAL
, FinancialTransaction.TRANSACTION_TYPE_REVERSE_DEPOSIT
.
payment
- The Payment
container to which this
financial transaction is associated with.getPayment().
public Payment getPayment()
This method gets the Payment
container that is associated with the financial transaction.
The Payment container is only present in financial transactions with these types:
FinancialTransaction.TRANSACTION_TYPE_APPROVE
, FinancialTransaction.TRANSACTION_TYPE_DEPOSIT
,
FinancialTransaction.TRANSACTION_TYPE_REVERSE_APPROVAL
, FinancialTransaction.TRANSACTION_TYPE_REVERSE_DEPOSIT
.
getPayment
in interface FinancialTransaction
Payment
container to which this FinancialTransaction
is associated with.setPayment(PaymentImpl)
public void setProcessedAmount(java.math.BigDecimal processedAmount)
This method sets the amount actually processed in the financial transaction.
This is the amount that was actually processed by the back-end system on the
FinancialTransaction
. This value will typically be the same as the requested
amount. Unless the payment protocol used by the backend system supports a different amount to
be processed.
The Plugin is responsible for setting this amount during the processing of a financial transaction. It is set when the amount processed by the backend system is different from the requested amount. If this amount is not set, the Payment Plugin Controller will assume that the requested amount was completely processed.
setProcessedAmount
in interface FinancialTransaction
processedAmount
- The processed amount.getProcessedAmount().
public java.math.BigDecimal getProcessedAmount()
This method gets the actual processed amount.
getProcessedAmount
in interface FinancialTransaction
setProcessedAmount(BigDecimal).
public void setReasonCode(java.lang.String reasonCode)
This method sets the reason for a failed transaction.
The Plugin needs to invoke this method during the processing of a financial transaction to update the failure reason from the payment back-end system. For more details on this field, please refer to the introduction of this Javadoc.
setReasonCode
in interface FinancialTransaction
reasonCode
- The backend system specific reason for a failed transaction.getReasonCode().
public java.lang.String getReasonCode()
This method gets the reason for a failed financial transaction.
For more details on this field, please refer to the introduction of this Javadoc.
getReasonCode
in interface FinancialTransaction
setReasonCode(String).
public void setRequestedAmount(java.math.BigDecimal requestedAmount)
This method sets the amount to be processed in a financial transaction.
This amount represents the amount that the system needs to process on any given transaction. The actual processed amount might be different from the requested amount.
This method is invoked by the Payment Plugin Controller before the financial transaction starts.
requestedAmount
- The requested amount to be set.getRequestedAmount().
,
getProcessedAmount().
,
setProcessedAmount(BigDecimal).
public java.math.BigDecimal getRequestedAmount()
This method gets the amount to be processed in a financial transaction.
This amount represents the amount that the system needs to process on any given transaction. The actual processed amount might be different from the requested amount.
getRequestedAmount
in interface FinancialTransaction
setRequestedAmount(BigDecimal).
,
getProcessedAmount().
,
setProcessedAmount(BigDecimal).
public void setResponseCode(java.lang.String responseCode)
This method sets the back-end system specific result of the financial transaction.
The Plugin needs to invoke this method during the processing of financial transactions to update the result coming from the payment back-end system. For more details on this field, please refer to the introduction of this Javadoc.
setResponseCode
in interface FinancialTransaction
responseCode
- The back-end system specific result of the financial transaction.getResponseCode().
public java.lang.String getResponseCode()
This method gets the back-end system specific result of the financial transaction.
getResponseCode
in interface FinancialTransaction
setResponseCode(String).
public void setState(short state) throws InvalidDataException
This method sets the state of the FinancialTransaction
.
Valid values are:
Usually the Payment Plugin Controller will invoke this method to update a financial transaction during its lifetime. However, if the Plugin needs to force the financial transaction into a different state, the Plugin can call this method directly.
setState
in interface FinancialTransaction
state
- The state of the FinancialTransaction
.InvalidDataException
- If an invalid state is passed in.getState().
public short getState()
This method gets the state of the financial transaction.
Valid values are:
getState
in interface FinancialTransaction
setState(short).
public void setTimeCreated(java.util.Date timeCreated)
This method sets the time the FinancialTransaction
was created.
The Payment Plugin Controller sets this field when the FinancialTransaction
is
created.
timeCreated
- The time the FinancialTransaction
was created.getTimeCreated().
public java.util.Date getTimeCreated()
This method gets the time the FinancialTransaction
was created.
getTimeCreated
in interface FinancialTransaction
FinancialTransaction
was created.setTimeCreated(Date).
public void setTimeUpdated(java.util.Date timeUpdated)
This method sets the time the FinancialTransaction
was last updated.
The Payment Plugin Controller updates this field everytime the
FinancialTransaction
changes.
timeUpdated
- The timeUpdate to set.getTimeUpdated().
public java.util.Date getTimeUpdated()
This method gets the most recent time that the FinancialTransaction
was updated.
getTimeUpdated
in interface FinancialTransaction
FinancialTransaction
was updated.setTimeUpdated(Date).
public void setTrackingId(java.lang.String trackingId)
This method sets the FinancialTransaction
tracking identifier.
The Plugin needs to invoke this method when processing a financial transaction to update the tracking ID. This field is the unique identifier of the financial transaction from the Plugin perspective. For more details, please refer to the introduction of this Javadoc.
setTrackingId
in interface FinancialTransaction
trackingId
- The unique identifier of the financial transaction from the Plugin
perspective.getTrackingId().
public java.lang.String getTrackingId()
This method gets the FinancialTransaction
tracking ID.
This field is the unique identifier of the financial transaction from the Plugin perspective. For more details, please refer to the introduction of this Javadoc.
getTrackingId
in interface FinancialTransaction
setTrackingId(String).
public void setTransactionType(short transactionType) throws InvalidDataException
This method sets the type of the FinancialTransaction
.
Valid transaction types are:
TRANSACTION_TYPE_APPROVE
TRANSACTION_TYPE_DEPOSIT
TRANSACTION_TYPE_APPROVE_AND_DEPOSIT
TRANSACTION_TYPE_CREDIT
TRANSACTION_TYPE_REVERSE_APPROVAL
TRANSACTION_TYPE_REVERSE_DEPOSIT
TRANSACTION_TYPE_REVERSE_CREDIT
The Payment Plugin Controller sets the type of the transaction during its creation.
transactionType
- The type of the financial transaction.InvalidDataException
- Thrown when an invalid transaction type is specified.getTransactionType().
public short getTransactionType()
This method gets the type of the FinancialTransaction
.
Valid transaction types are:
getTransactionType
in interface FinancialTransaction
setTransactionType(short)
public java.lang.String toString()
This method obtains a human-readable description of the contents of the
FinancialTransaction
container.
toString
in interface FinancialTransaction
toString
in class java.lang.Object
FinancialTransaction
container.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
This method returns a shallow copy of this FinancialTransactionImpl
instance.
clone
in class java.lang.Object
FinancialTransactionImpl
instance.java.lang.CloneNotSupportedException
- If the instance cannot be cloned.public static java.lang.String getStateAsString(int state)
state
- The payment instruction state.