Interface OrderPayment

All Superinterfaces:
org.broadleafcommerce.common.copy.MultiTenantCloneable<OrderPayment>, Serializable, org.broadleafcommerce.common.persistence.Status
All Known Implementing Classes:
OrderPaymentImpl

public interface OrderPayment extends Serializable, org.broadleafcommerce.common.persistence.Status, org.broadleafcommerce.common.copy.MultiTenantCloneable<OrderPayment>

This entity is designed to deal with payments associated to an Order and is usually unique for a particular amount, PaymentGatewayType and PaymentType combination. This is immediately invalid for scenarios where multiple payments of the same PaymentType should be supported (like paying with 2 PaymentType.CREDIT_CARD or 2 PaymentType.GIFT_CARD). That said, even though the use case might be uncommon in, Broadleaf does not actively prevent that situation from occurring online payments it is very common in point of sale systems.

Once an OrderPayment is created, various PaymentTransactions can be applied to this payment as denoted by PaymentTransactionType. There should be at least 1 PaymentTransaction for every OrderPayment that is associated with an Order that has gone through checkout (which means that Order.getStatus() is OrderStatus.SUBMITTED).

OrderPayments are not actually deleted from the database but rather are only soft-deleted (archived = true)

Author:
Phillip Verheyden (phillipuniverse)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    A more declarative way to invoke {@link #getTransactions().add()}.
    org.broadleafcommerce.common.money.Money
    The amount that this payment is allotted for.
    Returns a successful transaction with type PaymentTransactionType.AUTHORIZE or PaymentTransactionType.AUTHORIZE_AND_CAPTURE if one exists.
    org.broadleafcommerce.profile.core.domain.Address
    Gets the billing address associated with this payment.
    org.broadleafcommerce.common.currency.domain.BroadleafCurrency
    The currency that this payment should be taken in.
    org.broadleafcommerce.common.payment.PaymentGatewayType
    Gets the gateway that was used to process this order payment.
     
    Returns the initial transaction for this order payment.
     
    The soft link to a Referenced entity which will be stored in the blSecurePU persistence unit.
    Convenience method to get the calculated status of this order payment based on the state of the getTransactions()
    org.broadleafcommerce.common.money.Money
    getSuccessfulTransactionAmountForType(org.broadleafcommerce.common.payment.PaymentTransactionType type)
    Returns all of the transactions on this payment that were successful for the given type.
    org.broadleafcommerce.common.money.Money
    getTransactionAmountForType(org.broadleafcommerce.common.payment.PaymentTransactionType type)
    Looks through all of the transactions for this payment and adds up the amount for the given transaction type.
    All of the transactions that have been applied to this particular payment.
    getTransactionsForType(org.broadleafcommerce.common.payment.PaymentTransactionType type)
    Returns a transaction for given type.
    org.broadleafcommerce.common.payment.PaymentType
    The type of this payment like Credit Card or Gift Card.
    boolean
    Looks through all of the transactions for this payment and returns whether or not it contains a successful transaction of type PaymentTransactionType.AUTHORIZE_AND_CAPTURE or PaymentTransactionType.AUTHORIZE
    boolean
    Returns whether or not this payment is considered to be the final payment on the order.
    void
    setAmount(org.broadleafcommerce.common.money.Money amount)
    The amount that this payment is allotted for.
    void
    setBillingAddress(org.broadleafcommerce.profile.core.domain.Address billingAddress)
    Sets the billing address associated with this payment.
    void
    setId(Long id)
     
    void
    setOrder(Order order)
     
    void
    setPaymentGatewayType(org.broadleafcommerce.common.payment.PaymentGatewayType gatewayType)
    Gets the gateway that was used to process this order payment.
    void
    setReferenceNumber(String referenceNumber)
    Sets the soft link to a Referenced entity stored in the blSecurePU persistence unit.
    void
    All of the transactions that have been applied to this particular payment.
    void
    setType(org.broadleafcommerce.common.payment.PaymentType type)
    Sets the type of this payment like Credit Card or Gift Card

    Methods inherited from interface org.broadleafcommerce.common.copy.MultiTenantCloneable

    createOrRetrieveCopyInstance

    Methods inherited from interface org.broadleafcommerce.common.persistence.Status

    getArchived, isActive, setArchived
  • Method Details

    • getId

      Long getId()
    • setId

      void setId(Long id)
    • getOrder

      Order getOrder()
    • setOrder

      void setOrder(Order order)
    • getBillingAddress

      org.broadleafcommerce.profile.core.domain.Address getBillingAddress()
      Gets the billing address associated with this payment. This might be null for some payments where no billing address is required (like gift cards or account credit)
    • setBillingAddress

      void setBillingAddress(org.broadleafcommerce.profile.core.domain.Address billingAddress)
      Sets the billing address associated with this payment. This might be null for some payments where no billing address is required (like gift cards or account credit)
    • getAmount

      org.broadleafcommerce.common.money.Money getAmount()
      The amount that this payment is allotted for. The summation of all of the OrderPayments for a particular Order should equal Order.getTotal()
    • setAmount

      void setAmount(org.broadleafcommerce.common.money.Money amount)
      The amount that this payment is allotted for. The summation of all of the OrderPayments for a particular Order should equal Order.getTotal()
    • getReferenceNumber

      String getReferenceNumber()
      The soft link to a Referenced entity which will be stored in the blSecurePU persistence unit. If you are not attempting to store credit cards in your own database (which is the usual, recommended case) then this will not be used or set. If you do use this reference number, this can be anything that is unique (like System.currentTimeMillis()).
    • setReferenceNumber

      void setReferenceNumber(String referenceNumber)
      Sets the soft link to a Referenced entity stored in the blSecurePU persistence unit. This will likely not be used as the common case is to not store credit cards yourself.
    • getType

      org.broadleafcommerce.common.payment.PaymentType getType()
      The type of this payment like Credit Card or Gift Card.
    • setType

      void setType(org.broadleafcommerce.common.payment.PaymentType type)
      Sets the type of this payment like Credit Card or Gift Card
    • getGatewayType

      org.broadleafcommerce.common.payment.PaymentGatewayType getGatewayType()
      Gets the gateway that was used to process this order payment. Only a SINGLE payment gateway can modify transactions on a particular order payment.
    • setPaymentGatewayType

      void setPaymentGatewayType(org.broadleafcommerce.common.payment.PaymentGatewayType gatewayType)

      Gets the gateway that was used to process this order payment. Only a SINGLE payment gateway can modify transactions on a particular order payment.

      It usually does not make sense to modify the gateway type after it has already been set once. Instead, consider just archiving this payment type (by deleting it) and creating a new payment for the new gateway.

    • getTransactions

      List<PaymentTransaction> getTransactions()

      All of the transactions that have been applied to this particular payment. Transactions are denoted by the various PaymentTransactionTypes. In almost all scenarios (as in, 99.9999% of all cases) there will be a at least one PaymentTransaction for every OrderPayment.

      To add a transaction to an OrderPayment see addTransaction(PaymentTransaction).

    • setTransactions

      void setTransactions(List<PaymentTransaction> details)

      All of the transactions that have been applied to this particular payment. Transactions are denoted by the various PaymentTransactionTypes. In almost all scenarios (as in, 99.9999% of all cases) there will be a at least one PaymentTransaction for every OrderPayment.

      To add a transaction to an OrderPayment see addTransaction(PaymentTransaction).

    • addTransaction

      void addTransaction(PaymentTransaction transaction)
      A more declarative way to invoke {@link #getTransactions().add()}. This is the preferred way to add a transaction to this payment.
    • getTransactionsForType

      List<PaymentTransaction> getTransactionsForType(org.broadleafcommerce.common.payment.PaymentTransactionType type)
      Returns a transaction for given type. This is useful when validating whether or not a PaymentTransaction can actually be added to this payment. For instance, there can only be a single PaymentTransactionType.AUTHORIZE for a payment.
      Parameters:
      type - the type of transaction to look for within getTransactions()
      Returns:
      a list of transactions or an empty list if there are no transaction of that type
    • getInitialTransaction

      PaymentTransaction getInitialTransaction()
      Returns the initial transaction for this order payment. Implementation-wise this would be any PaymentTransaction whose parentTransaction is NULL.
      Returns:
      the initial transaction for this order payment or null if there isn't any
    • getAuthorizeTransaction

      PaymentTransaction getAuthorizeTransaction()
      Returns a successful transaction with type PaymentTransactionType.AUTHORIZE or PaymentTransactionType.AUTHORIZE_AND_CAPTURE if one exists. Note there can only be a single authorize transaction for a given payment.
      Returns:
    • getTransactionAmountForType

      org.broadleafcommerce.common.money.Money getTransactionAmountForType(org.broadleafcommerce.common.payment.PaymentTransactionType type)
      Looks through all of the transactions for this payment and adds up the amount for the given transaction type. This ignores whether the transaction was successful or not
      Parameters:
      type -
      Returns:
      the amount of all of the transactions for the given type
    • getSuccessfulTransactionAmountForType

      org.broadleafcommerce.common.money.Money getSuccessfulTransactionAmountForType(org.broadleafcommerce.common.payment.PaymentTransactionType type)
      Returns all of the transactions on this payment that were successful for the given type.
      Parameters:
      type - the type of transaction
      Returns:
      the amount of all of the transaction on this payment for the given type that have been successful
    • getStatus

      OrderPaymentStatus getStatus()
      Convenience method to get the calculated status of this order payment based on the state of the getTransactions()
      Returns:
      OrderPaymentStatus
    • isConfirmed

      boolean isConfirmed()
      Looks through all of the transactions for this payment and returns whether or not it contains a successful transaction of type PaymentTransactionType.AUTHORIZE_AND_CAPTURE or PaymentTransactionType.AUTHORIZE
      Returns:
    • isFinalPayment

      boolean isFinalPayment()
      Returns whether or not this payment is considered to be the final payment on the order. The default implementation considers those payment of type PaymentType.THIRD_PARTY_ACCOUNT and PaymentType.CREDIT_CARD final payments because integrations with external Payment Gateways require it.

      For example, a THIRD_PARTY_ACCOUNT payment's (e.g. PayPal Express Checkout) amount to charge to the customer will be automatically calculated based on other payments that have already been applied to the order, such as GIFT_CARDs or ACCOUNT_CREDITs. This final amount (OrderPayment) will be sent to the gateway.

      Returns:
    • getCurrency

      org.broadleafcommerce.common.currency.domain.BroadleafCurrency getCurrency()
      The currency that this payment should be taken in. This is a delegate to {@link #getOrder()#getCurrency()}.