com.ibm.commerce.payments.plugin.impl

Class CreditImpl

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


    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:

    • credit
    • credit reversal

    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.

    See Also:
    Serialized Form
    • Constructor Detail

      • CreditImpl

        public CreditImpl(java.lang.String id,
                          PaymentInstructionImpl paymentInstruction,
                          java.math.BigDecimal targetAmount)

        This method creates a Credit container associated with a particular PaymentInstruction.

        Parameters:
        id - The uniquely identifier of the Credit container.
        paymentInstruction - The payment instruction where credit transactions will be associated with.
        targetAmount - The target amount expected to be credited in a credit transaction.
    • Method Detail

      • setCreditTransaction

        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.

        Parameters:
        creditTransaction - The credit transaction to be set.
        See Also:
        getCreditTransaction()
      • getCreditTransaction

        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.

        Specified by:
        getCreditTransaction in interface Credit
        Returns:
        The credit transaction associated with this credit container if any; null if no credit transaction is associated.
        See Also:
        setCreditTransaction(FinancialTransactionImpl)
      • setCreditedAmount

        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.

        Specified by:
        setCreditedAmount in interface Credit
        Parameters:
        creditedAmount - The currently credited amount.
        See Also:
        getCreditedAmount()
      • getCreditedAmount

        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.

        Specified by:
        getCreditedAmount in interface Credit
        Returns:
        The currently credited amount.
        See Also:
        setCreditedAmount(BigDecimal)
      • setCreditingAmount

        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.

        Specified by:
        setCreditingAmount in interface Credit
        Parameters:
        creditingAmount - The credit amount in pending.
        See Also:
        getCreditingAmount()
      • getCreditingAmount

        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.

        Specified by:
        getCreditingAmount in interface Credit
        Returns:
        The current amount being credited (pending).
        See Also:
        setCreditingAmount(BigDecimal)
      • getId

        public java.lang.String getId()

        This method gets the unique identifier of the Credit container.

        Specified by:
        getId in interface Credit
        Returns:
        The unique identifier of the Credit container.
      • setPaymentInstruction

        public void setPaymentInstruction(PaymentInstructionImpl instruction)

        This method sets the payment instruction container which this credit is associated with.

        Parameters:
        instruction - The PaymentInstruction to be associated with this credit container.
        See Also:
        getPaymentInstruction().
      • setReverseCreditTransactions

        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.

        Parameters:
        reverseTransactions - A list of FinancialTransaction containers.
        See Also:
        getReverseCreditTransactions().
      • setReversingAmount

        public void setReversingAmount(java.math.BigDecimal reversingAmount)

        This method sets the reverse credited amount.

        Plug-ins will invoke this method when supporting credit queries.

        Specified by:
        setReversingAmount in interface Credit
        Parameters:
        reversingAmount - The amount being reversed.
        See Also:
        getReversingAmount().
      • getStateAsString

        public static java.lang.String getStateAsString(int state)
        This method gets a non-globalized human-readable representation of a credit state.
        Parameters:
        state - A String that specifies the credit state.
        Returns:
        A non-globalized human-readable representation of a credit state.
      • getTargetAmount

        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.

        Specified by:
        getTargetAmount in interface Credit
        Returns:
        The target credit amount.
      • clone

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

        This method returns a shallow copy of this CreditImpl instance.

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

        public java.lang.String toString()

        This method obtains a human-readable representation of the Credit container.

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