com.ibm.commerce.payments.plugin.impl

Class FinancialTransactionImpl

  • java.lang.Object
    • com.ibm.commerce.payments.plugin.impl.FinancialTransactionImpl
  • All Implemented Interfaces:
    FinancialTransaction, java.io.Serializable, java.lang.Cloneable


    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

    The response 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.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      FinancialTransactionImpl(java.lang.String id)
      This method creates a FinancialTransaction container.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FinancialTransactionImpl

        public FinancialTransactionImpl(java.lang.String id)
        This method creates a FinancialTransaction container.
        Parameters:
        id - The unique identifier of the FinancialTransaction
    • Method Detail

      • setExtendedData

        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.

        Specified by:
        setExtendedData in interface FinancialTransaction
        Parameters:
        extendedData - The map of name-value pairs representing extended payment information
        See Also:
        getExtendedData()
      • setReferenceNumber

        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.

        Specified by:
        setReferenceNumber in interface FinancialTransaction
        Parameters:
        referenceNumber - The unique identifier of the financial transaction from the payment backend system perspective.
        See Also:
        getReferenceNumber().
      • 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.

        Specified by:
        getReferenceNumber in interface FinancialTransaction
        Returns:
        The unique identifier of the financial transaction from the payment back-end system perspective.
        See Also:
        setReferenceNumber(String).
      • getId

        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.

        Specified by:
        getId in interface FinancialTransaction
        Returns:
        A numeric unique identifier of the FinancialTransaction container.
      • setProcessedAmount

        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.

        Specified by:
        setProcessedAmount in interface FinancialTransaction
        Parameters:
        processedAmount - The processed amount.
        See Also:
        getProcessedAmount().
      • setReasonCode

        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.

        Specified by:
        setReasonCode in interface FinancialTransaction
        Parameters:
        reasonCode - The backend system specific reason for a failed transaction.
        See Also:
        getReasonCode().
      • 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.

        Specified by:
        getReasonCode in interface FinancialTransaction
        Returns:
        The back-end system specific reason for a failed transaction .
        See Also:
        setReasonCode(String).
      • setRequestedAmount

        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.

        Parameters:
        requestedAmount - The requested amount to be set.
        See Also:
        getRequestedAmount()., getProcessedAmount()., setProcessedAmount(BigDecimal).
      • setResponseCode

        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.

        Specified by:
        setResponseCode in interface FinancialTransaction
        Parameters:
        responseCode - The back-end system specific result of the financial transaction.
        See Also:
        getResponseCode().
      • getResponseCode

        public java.lang.String getResponseCode()

        This method gets the back-end system specific result of the financial transaction.

        Specified by:
        getResponseCode in interface FinancialTransaction
        Returns:
        The back-end system specific result of the financial transaction.
        See Also:
        setResponseCode(String).
      • setState

        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.

        Specified by:
        setState in interface FinancialTransaction
        Parameters:
        state - The state of the FinancialTransaction.
        Throws:
        InvalidDataException - If an invalid state is passed in.
        See Also:
        getState().
      • setTimeCreated

        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.

        Parameters:
        timeCreated - The time the FinancialTransaction was created.
        See Also:
        getTimeCreated().
      • setTimeUpdated

        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.

        Parameters:
        timeUpdated - The timeUpdate to set.
        See Also:
        getTimeUpdated().
      • getTimeUpdated

        public java.util.Date getTimeUpdated()

        This method gets the most recent time that the FinancialTransaction was updated.

        Specified by:
        getTimeUpdated in interface FinancialTransaction
        Returns:
        The last time the FinancialTransaction was updated.
        See Also:
        setTimeUpdated(Date).
      • setTrackingId

        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.

        Specified by:
        setTrackingId in interface FinancialTransaction
        Parameters:
        trackingId - The unique identifier of the financial transaction from the Plugin perspective.
        See Also:
        getTrackingId().
      • 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.

        Specified by:
        getTrackingId in interface FinancialTransaction
        Returns:
        The unique identifier of the financial transaction from the Plugin perspective.
        See Also:
        setTrackingId(String).
      • toString

        public java.lang.String toString()

        This method obtains a human-readable description of the contents of the FinancialTransaction container.

        Specified by:
        toString in interface FinancialTransaction
        Overrides:
        toString in class java.lang.Object
        Returns:
        A human-readable representation of the FinancialTransaction container.
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException

        This method returns a shallow copy of this FinancialTransactionImpl instance.

        Overrides:
        clone in class java.lang.Object
        Returns:
        A shallow copy of this FinancialTransactionImpl instance.
        Throws:
        java.lang.CloneNotSupportedException - If the instance cannot be cloned.
      • getStateAsString

        public static java.lang.String getStateAsString(int state)
        This method gets a non-globalized human-readable representation of a payment instruction state.
        Parameters:
        state - The payment instruction state.
        Returns:
        A non-globalized human-readable representation of a payment instruction state.