com.ibm.commerce.payments.plugin

Interface Credit

  • All Superinterfaces:
    java.io.Serializable
    All Known Implementing Classes:
    CreditImpl


    public interface Credit
    extends java.io.Serializable

    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 the transaction.

    Credits are sometimes referred as refunds when associated with a Refund Merchandise Authorization (RMA).

    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 above 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. Then the processing of the credit card is considered offline.

    Payment state machine

    Credit state machine
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
      static short STATE_CANCELED
      The state of the Credit container when it has been fully reversed.
      static short STATE_CREDITED
      The state of the Credit container when a successful credit transaction has been completed.
      static short STATE_CREDITING
      The state of the Credit container while a credit transaction is pending.
      static short STATE_FAILED
      The state of the Credit container when a transaction has failed.
      static short STATE_NEW
      The state of the Credit container after its creation.
    • Field Detail

      • COPYRIGHT

        static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • STATE_NEW

        static final short STATE_NEW
        The state of the Credit container after its creation. This is the initial state of a Credit container. The only valid transaction while in this state is credit.
        See Also:
        Constant Field Values
      • STATE_CREDITING

        static final short STATE_CREDITING
        The state of the Credit container while a credit transaction is pending. The only valid transaction while in this state is credit reversal.
        See Also:
        Constant Field Values
      • STATE_CREDITED

        static final short STATE_CREDITED
        The state of the Credit container when a successful credit transaction has been completed. This is usually a final state. However, some payment back-end systems might support reversals on finalized credited transactions. The only valid transaction while in this state is credit reversal.
        See Also:
        Constant Field Values
      • STATE_FAILED

        static final short STATE_FAILED
        The state of the Credit container when a transaction has failed. This is a final state. No transaction is accepted once this state is reached. Note that the failure could have happened in a credit or a credit reversal transaction.
        See Also:
        Constant Field Values
      • STATE_CANCELED

        static final short STATE_CANCELED
        The state of the Credit container when it has been fully reversed. Since this is a final state no transaction is accepted once this state is reached.
        See Also:
        Constant Field Values
    • Method Detail

      • getCreditTransaction

        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.

        Returns:
        The credit transaction associated with this credit container if any; null if no credit transaction is associated.
      • setCreditedAmount

        void setCreditedAmount(java.math.BigDecimal decimal)

        This method sets the amount credited in the container.

        Plug-ins will invoke this method when supporting queries.

        Parameters:
        decimal - The currently credited amount.
        See Also:
        getCreditedAmount()
      • getCreditedAmount

        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 as the requested amount. However, some payment back-end systems might process a different amount.

        Returns:
        The currently credited amount.
        See Also:
        setCreditedAmount(BigDecimal)
      • setCreditingAmount

        void setCreditingAmount(java.math.BigDecimal decimal)

        This method sets the amount being credited, that is, in pending to be credited.

        Plug-ins will invoke this method when supporting queries.

        Parameters:
        decimal - The credit amount in pending.
        See Also:
        getCreditingAmount()
      • getCreditingAmount

        java.math.BigDecimal getCreditingAmount()

        This method gets the amount currently being 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.

        Returns:
        The current amount being credited (pending).
        See Also:
        setCreditingAmount(BigDecimal)
      • getId

        java.lang.String getId()

        This method gets the unique identifier of the Credit container.

        Returns:
        The unique identifier of the Credit container.
      • getPaymentInstruction

        PaymentInstruction getPaymentInstruction()

        This method gets the associated PaymentInstruction.

        The plug-ins need to use the PaymentInstruction to determine if a credit transaction is dependent or independent.

        Returns:
        The payment instruction container associated with the Credit container.
      • getReverseCreditTransactions

        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.

        Returns:
        A list containing zero or more FinancialTransaction.
      • setReversingAmount

        void setReversingAmount(java.math.BigDecimal reversingAmount)

        This method sets the reverse credited amount.

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

        Parameters:
        reversingAmount - The amount being reversed.
        See Also:
        getReversingAmount().
      • getReversingAmount

        java.math.BigDecimal getReversingAmount()

        This method gets the amount currently being reversed.

        Returns:
        Amount representing the crediting amount.
        See Also:
        setReversingAmount(BigDecimal).
      • getTargetAmount

        java.math.BigDecimal getTargetAmount()

        This method gets the amount that is the target as the total to be credited in the lifetime of the container.

        Returns:
        The target credit amount.
      • toString

        java.lang.String toString()

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

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