Class OrderPaymentImpl

java.lang.Object
org.broadleafcommerce.core.payment.domain.OrderPaymentImpl
All Implemented Interfaces:
Serializable, org.broadleafcommerce.common.copy.MultiTenantCloneable<OrderPayment>, org.broadleafcommerce.common.currency.util.CurrencyCodeIdentifiable, org.broadleafcommerce.common.persistence.Status, OrderPayment

@Entity public class OrderPaymentImpl extends Object implements OrderPayment, org.broadleafcommerce.common.currency.util.CurrencyCodeIdentifiable
See Also:
  • Field Details

    • id

      protected Long id
    • order

      protected Order order
    • billingAddress

      protected org.broadleafcommerce.profile.core.domain.Address billingAddress
    • amount

      protected BigDecimal amount
    • referenceNumber

      protected String referenceNumber
    • type

      protected String type
    • gatewayType

      protected String gatewayType
    • transactions

      protected List<PaymentTransaction> transactions
    • archiveStatus

      protected org.broadleafcommerce.common.persistence.ArchiveStatus archiveStatus
  • Constructor Details

    • OrderPaymentImpl

      public OrderPaymentImpl()
  • Method Details

    • getAmount

      public org.broadleafcommerce.common.money.Money getAmount()
      Description copied from interface: OrderPayment
      The amount that this payment is allotted for. The summation of all of the OrderPayments for a particular Order should equal Order.getTotal()
      Specified by:
      getAmount in interface OrderPayment
    • setAmount

      public void setAmount(org.broadleafcommerce.common.money.Money amount)
      Description copied from interface: OrderPayment
      The amount that this payment is allotted for. The summation of all of the OrderPayments for a particular Order should equal Order.getTotal()
      Specified by:
      setAmount in interface OrderPayment
    • getId

      public Long getId()
      Specified by:
      getId in interface OrderPayment
    • setId

      public void setId(Long id)
      Specified by:
      setId in interface OrderPayment
    • getOrder

      public Order getOrder()
      Specified by:
      getOrder in interface OrderPayment
    • setOrder

      public void setOrder(Order order)
      Specified by:
      setOrder in interface OrderPayment
    • getBillingAddress

      public org.broadleafcommerce.profile.core.domain.Address getBillingAddress()
      Description copied from interface: OrderPayment
      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)
      Specified by:
      getBillingAddress in interface OrderPayment
    • setBillingAddress

      public void setBillingAddress(org.broadleafcommerce.profile.core.domain.Address billingAddress)
      Description copied from interface: OrderPayment
      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)
      Specified by:
      setBillingAddress in interface OrderPayment
    • getReferenceNumber

      public String getReferenceNumber()
      Description copied from interface: OrderPayment
      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()).
      Specified by:
      getReferenceNumber in interface OrderPayment
    • setReferenceNumber

      public void setReferenceNumber(String referenceNumber)
      Description copied from interface: OrderPayment
      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.
      Specified by:
      setReferenceNumber in interface OrderPayment
    • getType

      public org.broadleafcommerce.common.payment.PaymentType getType()
      Description copied from interface: OrderPayment
      The type of this payment like Credit Card or Gift Card.
      Specified by:
      getType in interface OrderPayment
    • setType

      public void setType(org.broadleafcommerce.common.payment.PaymentType type)
      Description copied from interface: OrderPayment
      Sets the type of this payment like Credit Card or Gift Card
      Specified by:
      setType in interface OrderPayment
    • getGatewayType

      public org.broadleafcommerce.common.payment.PaymentGatewayType getGatewayType()
      Description copied from interface: OrderPayment
      Gets the gateway that was used to process this order payment. Only a SINGLE payment gateway can modify transactions on a particular order payment.
      Specified by:
      getGatewayType in interface OrderPayment
    • setPaymentGatewayType

      public void setPaymentGatewayType(org.broadleafcommerce.common.payment.PaymentGatewayType gatewayType)
      Description copied from interface: OrderPayment

      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.

      Specified by:
      setPaymentGatewayType in interface OrderPayment
    • getTransactions

      public List<PaymentTransaction> getTransactions()
      Description copied from interface: OrderPayment

      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 OrderPayment.addTransaction(PaymentTransaction).

      Specified by:
      getTransactions in interface OrderPayment
    • setTransactions

      public void setTransactions(List<PaymentTransaction> transactions)
      Description copied from interface: OrderPayment

      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 OrderPayment.addTransaction(PaymentTransaction).

      Specified by:
      setTransactions in interface OrderPayment
    • addTransaction

      public void addTransaction(PaymentTransaction transaction)
      Description copied from interface: OrderPayment
      A more declarative way to invoke {@link #getTransactions().add()}. This is the preferred way to add a transaction to this payment.
      Specified by:
      addTransaction in interface OrderPayment
    • getTransactionsForType

      public List<PaymentTransaction> getTransactionsForType(org.broadleafcommerce.common.payment.PaymentTransactionType type)
      Description copied from interface: OrderPayment
      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.
      Specified by:
      getTransactionsForType in interface OrderPayment
      Parameters:
      type - the type of transaction to look for within OrderPayment.getTransactions()
      Returns:
      a list of transactions or an empty list if there are no transaction of that type
    • getInitialTransaction

      public PaymentTransaction getInitialTransaction()
      Description copied from interface: OrderPayment
      Returns the initial transaction for this order payment. Implementation-wise this would be any PaymentTransaction whose parentTransaction is NULL.
      Specified by:
      getInitialTransaction in interface OrderPayment
      Returns:
      the initial transaction for this order payment or null if there isn't any
    • getAuthorizeTransaction

      public PaymentTransaction getAuthorizeTransaction()
      Description copied from interface: OrderPayment
      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.
      Specified by:
      getAuthorizeTransaction in interface OrderPayment
      Returns:
    • getTransactionAmountForType

      public org.broadleafcommerce.common.money.Money getTransactionAmountForType(org.broadleafcommerce.common.payment.PaymentTransactionType type)
      Description copied from interface: OrderPayment
      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
      Specified by:
      getTransactionAmountForType in interface OrderPayment
      Returns:
      the amount of all of the transactions for the given type
    • getSuccessfulTransactionAmountForType

      public org.broadleafcommerce.common.money.Money getSuccessfulTransactionAmountForType(org.broadleafcommerce.common.payment.PaymentTransactionType type)
      Description copied from interface: OrderPayment
      Returns all of the transactions on this payment that were successful for the given type.
      Specified by:
      getSuccessfulTransactionAmountForType in interface OrderPayment
      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

      public OrderPaymentStatus getStatus()
      Description copied from interface: OrderPayment
      Convenience method to get the calculated status of this order payment based on the state of the OrderPayment.getTransactions()
      Specified by:
      getStatus in interface OrderPayment
      Returns:
      OrderPaymentStatus
    • isConfirmed

      public boolean isConfirmed()
      Description copied from interface: OrderPayment
      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
      Specified by:
      isConfirmed in interface OrderPayment
      Returns:
    • isFinalPayment

      public boolean isFinalPayment()
      Description copied from interface: OrderPayment
      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.

      Specified by:
      isFinalPayment in interface OrderPayment
      Returns:
    • getCurrency

      public org.broadleafcommerce.common.currency.domain.BroadleafCurrency getCurrency()
      Description copied from interface: OrderPayment
      The currency that this payment should be taken in. This is a delegate to {@link #getOrder()#getCurrency()}.
      Specified by:
      getCurrency in interface OrderPayment
    • getCurrencyCode

      public String getCurrencyCode()
      Specified by:
      getCurrencyCode in interface org.broadleafcommerce.common.currency.util.CurrencyCodeIdentifiable
    • getArchived

      public Character getArchived()
      Specified by:
      getArchived in interface org.broadleafcommerce.common.persistence.Status
    • setArchived

      public void setArchived(Character archived)
      Specified by:
      setArchived in interface org.broadleafcommerce.common.persistence.Status
    • isActive

      public boolean isActive()
      Specified by:
      isActive in interface org.broadleafcommerce.common.persistence.Status
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • createOrRetrieveCopyInstance

      public <G extends OrderPayment> org.broadleafcommerce.common.copy.CreateResponse<G> createOrRetrieveCopyInstance(org.broadleafcommerce.common.copy.MultiTenantCopyContext context) throws CloneNotSupportedException
      Specified by:
      createOrRetrieveCopyInstance in interface org.broadleafcommerce.common.copy.MultiTenantCloneable<OrderPayment>
      Throws:
      CloneNotSupportedException