com.ibm.commerce.payments.plugin.impl

Class PaymentImpl

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


    public class PaymentImpl
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable, Payment

    This class is a value object container for payment-related transactions.

    This container can contain a single payment approval/authorization and multiple deposits/captures for the same approval/capture. However, multiple deposits/captures per a single approval/authorization might not be supported by the payment back-end system.

    The Payment container is created before the approval/authorization transaction and it is used in on subsequently transactions like deposits/captures and reversals.

    The Payment Plugin Controller guarantees that:

    • only one single approve transaction will be issued against a Payment
    • only one single transaction will be in pending for a given Payment at the same time.

    See Also:
    Serialized Form
    • Constructor Detail

      • PaymentImpl

        public PaymentImpl(java.lang.String id,
                           PaymentInstructionImpl paymentInstruction)

        This method creates a Payment container.

        Parameters:
        id - The unique identifier of the Payment container
        paymentInstruction - The PaymentInstruction container this Payment is associated with.
    • Method Detail

      • setApproveTransaction

        public void setApproveTransaction(FinancialTransactionImpl approveTransaction)

        This method sets the approve transaction container.

        Parameters:
        approveTransaction - The approve transaction container.
        See Also:
        getApproveTransaction().
      • setApprovedAmount

        public void setApprovedAmount(java.math.BigDecimal approvedAmount)

        This method sets the approved amount after an approve transaction.

        The plug-ins will invoke this method only if the actually approved amount is different from the requested approve transaction amount. This is only possible for back-end systems that support amounts to be processed that are less that the requested amount.

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

        During approve reversal transactions, the approved amount should decrease.

        Gift Certificate example

        Suppose a Plugin supports Gift Certificates(GC). If an approve asks for $15.00 in a given GC and the GC has actually only $14.45 remaining, the Plugin could approve $14.45.

        This is the rationale: Gift Certificates have very limited amounts and are typically used with other payment methods like Credit Cards. The Gift Certificate is expected to be fully consumed before the Credit Card is charged. If the requested amount cannot be fully processed, the remaining is expected to be processed later on against the Credit Card.

        Accepting the behavior above really depends on the Plugin. Even though this scenario is possible, the Plugin might choose to reject the approve transaction indicating that the account limit has been reached.

        Specified by:
        setApprovedAmount in interface Payment
        Parameters:
        approvedAmount - The approved amount to be set.
        See Also:
        getApprovedAmount().
      • getApprovedAmount

        public java.math.BigDecimal getApprovedAmount()

        This method gets the currently approved amount.

        The approved amount will be different from zero only after the initial approve transaction has successfully finished and before any approve reversal transactions.

        The approved amount can be different from the target amount associated with the Payment container. This occurs if the back-end system supports processing less that the requested amount during an approval transaction. Also, if reversals have occurred, the approved amount will be different from the target amount.

        For an example of differences between approved amount and target amount, please refer to setApprovedAmount(BigDecimal).

        Specified by:
        getApprovedAmount in interface Payment
        Returns:
        The amount that has been approved.
        See Also:
        setApprovedAmount(BigDecimal).
      • setApprovingAmount

        public void setApprovingAmount(java.math.BigDecimal approvingAmount)
        This method sets the amount being approved.

        Plug-ins will invoke this method when supporting queries.

        Specified by:
        setApprovingAmount in interface Payment
        Parameters:
        approvingAmount - The amount being approved.
        See Also:
        getApprovingAmount().
      • getApprovingAmount

        public java.math.BigDecimal getApprovingAmount()

        This method gets the amount being approved.

        The approving amount will be different from zero when the initial approve transaction has been issued and not completed. Or if its state stays in pending state pending after its execution.

        Specified by:
        getApprovingAmount in interface Payment
        Returns:
        The amount being approved.
        See Also:
        setApprovingAmount(BigDecimal).
      • setAttentionRequired

        public void setAttentionRequired(boolean attentionRequired)

        This method sets a flag to indicate that the Payment requires attention even though all transactions might have finalized successfully.

        External intervention might be required. Typical examples:

        The Plugin might have other reasons to raise this flag that are specific to the payment protocol being implemented.

        Specified by:
        setAttentionRequired in interface Payment
        Parameters:
        attentionRequired - If the Payment requires external intervention.
        See Also:
        isAttentionRequired().
      • isAttentionRequired

        public boolean isAttentionRequired()

        This method checks if the Payment requires external intervention.

        Specified by:
        isAttentionRequired in interface Payment
        Returns:
        If the Payment requires external intervention.
        See Also:
        setAttentionRequired(boolean).
      • setDepositTransactions

        public void setDepositTransactions(java.util.ArrayList depositTransactions)

        This method sets a list of deposit transactions.

        Each element in the list is a FinancialTransaction.

        Parameters:
        depositTransactions - A list of FinancialTransaction containing deposit transactions to be set.
        See Also:
        getDepositTransactions().
      • setDepositedAmount

        public void setDepositedAmount(java.math.BigDecimal depositedAmount)

        This method sets the currently deposited amount.

        The deposited amount is set by the Payment Plugin Controller on a successful deposit transaction. If multiple deposits have been made against a Payment this will represent the sum of the deposited amounts of all the individual transactions.

        Plug-ins will invoke this method when supporting queries.

        Specified by:
        setDepositedAmount in interface Payment
        Parameters:
        depositedAmount - The targetAmount deposited by the back-end system.
        See Also:
        getDepositedAmount().
      • getDepositedAmount

        public java.math.BigDecimal getDepositedAmount()

        This method gets the amount currently deposited.

        If multiple deposits have been made against a Payment, this amount will represent the total amount deposited for all deposit transactions, that is, the sum of all the individual deposit transaction amounts.

        Specified by:
        getDepositedAmount in interface Payment
        Returns:
        The total deposited amount in for this Payment.
        See Also:
        setDepositedAmount(BigDecimal).
      • setDepositingAmount

        public void setDepositingAmount(java.math.BigDecimal depositingAmount)

        This method sets the amount being deposited.

        The Payment Plugin Controller will set the depositing amount on deposit transactions that go to the state FinancialTransaction.STATE_PENDING.

        Plug-ins will invoke this method when supporting queries.

        Specified by:
        setDepositingAmount in interface Payment
        Parameters:
        depositingAmount - The amount being deposited.
        See Also:
        getDepositingAmount().
      • setExpirationDate

        public void setExpirationDate(java.util.Date expirationDate)

        This method sets the expiration date of the Payment approval (authorization).

        The expiration date is expressed on GMT standard time.

        Plug-ins will invoke this method when supporting queries.

        Specified by:
        setExpirationDate in interface Payment
        Parameters:
        expirationDate - The expiration date to be set.
        See Also:
        isExpired()., setExpired(boolean)., getExpirationDate()., PluginConfiguration
      • getExpirationDate

        public java.util.Date getExpirationDate()

        This method gets the date the payment approval (authorization) is supposed to expire.

        This value is calculated by the Payment Plugin Controller based on the actual approval timestamp and the Plugin configuration of the expiration .

        Specified by:
        getExpirationDate in interface Payment
        Returns:
        The date the payment approval (authorization) expires.
        See Also:
        isExpired(), setExpired(boolean)., setExpirationDate(Date).
      • setExpired

        public void setExpired(boolean expired)

        This method indicates if the Payment approval (authorization) has expired.

        This flag indicates if the payment approval (authorization) has expired while the expiration date is an expected expiration date. Note that if the Plugin configuration is not done correctly (PluginConfiguration), the expiration date and the actual time of the expiration might vary considerably.

        Specified by:
        setExpired in interface Payment
        Parameters:
        expired - Whether thePayment approval has expired or not.
        See Also:
        isExpired()., getExpirationDate()., setExpirationDate(Date)., PluginConfiguration
      • getId

        public java.lang.String getId()

        This method gets the unique identifier of the Payment container.

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

        public void setPaymentInstruction(PaymentInstructionImpl instruction)

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

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

        public void setReverseApprovalTransactions(java.util.ArrayList reverseApprovalTransactions)

        This method sets the list approve reversal transactions associated with this Payment container.

        Each element of the list is a FinancialTransaction.

        Parameters:
        reverseApprovalTransactions - The list of FinancialTransaction containing approve reversal transactions.
        See Also:
        getReverseApprovalTransactions().
      • setReverseDepositTransactions

        public void setReverseDepositTransactions(java.util.ArrayList reverseDepositTransactions)

        This method sets a list of reverse deposit transactions.

        Each element in the list is a FinancialTransaction.

        Parameters:
        reverseDepositTransactions - A list containing FinancialTransaction objects that represent a reverse deposit transaction.
        See Also:
        getReverseDepositTransactions().
      • setReversingApprovedAmount

        public void setReversingApprovedAmount(java.math.BigDecimal reversingApprovedAmount)

        This method sets the approved amount being reversed.

        Plug-ins will invoke this method when supporting queries.

        Specified by:
        setReversingApprovedAmount in interface Payment
        Parameters:
        reversingApprovedAmount - The approved amount being reversed.
        See Also:
        getReversingApprovedAmount().
      • setReversingDepositedAmount

        public void setReversingDepositedAmount(java.math.BigDecimal reversingDepositedAmount)

        This method sets the deposited amount being reversed.

        Plug-ins will invoke this method when supporting queries.

        Specified by:
        setReversingDepositedAmount in interface Payment
        Parameters:
        reversingDepositedAmount - The deposited amount being reversed.
        See Also:
        getReversingDepositedAmount().
      • getStateAsString

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

        public void setTargetAmount(java.math.BigDecimal targetAmount)

        This method sets the target amount to be processed for the approve transaction.

        Parameters:
        targetAmount - The amount that has been requested to be approved by the back-end system.
        See Also:
        Payment.getTargetAmount().
      • getTargetAmount

        public java.math.BigDecimal getTargetAmount()

        This method gets the requested target amount.

        Specified by:
        getTargetAmount in interface Payment
        Returns:
        The requested target amount for this Payment container.
        See Also:
        setTargetAmount(BigDecimal).
      • clone

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

        This method returns a shallow copy of this PaymentImpl instance.

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

        public java.lang.String toString()

        This method prints a human-readable rendering of this container object.

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