Interface OrderPayment
- All Superinterfaces:
org.broadleafcommerce.common.copy.MultiTenantCloneable<OrderPayment>,Serializable,org.broadleafcommerce.common.persistence.Status
- All Known Implementing Classes:
OrderPaymentImpl
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 TypeMethodDescriptionvoidaddTransaction(PaymentTransaction transaction) A more declarative way to invoke {@link #getTransactions().add()}.org.broadleafcommerce.common.money.MoneyThe amount that this payment is allotted for.Returns a successful transaction with typePaymentTransactionType.AUTHORIZEorPaymentTransactionType.AUTHORIZE_AND_CAPTUREif one exists.org.broadleafcommerce.profile.core.domain.AddressGets the billing address associated with this payment.org.broadleafcommerce.common.currency.domain.BroadleafCurrencyThe currency that this payment should be taken in.org.broadleafcommerce.common.payment.PaymentGatewayTypeGets the gateway that was used to process this order payment.getId()Returns the initial transaction for this order payment.getOrder()The soft link to aReferencedentity 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 thegetTransactions()org.broadleafcommerce.common.money.MoneygetSuccessfulTransactionAmountForType(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.MoneygetTransactionAmountForType(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.PaymentTypegetType()The type of this payment like Credit Card or Gift Card.booleanLooks through all of the transactions for this payment and returns whether or not it contains a successful transaction of typePaymentTransactionType.AUTHORIZE_AND_CAPTUREorPaymentTransactionType.AUTHORIZEbooleanReturns whether or not this payment is considered to be the final payment on the order.voidsetAmount(org.broadleafcommerce.common.money.Money amount) The amount that this payment is allotted for.voidsetBillingAddress(org.broadleafcommerce.profile.core.domain.Address billingAddress) Sets the billing address associated with this payment.voidvoidvoidsetPaymentGatewayType(org.broadleafcommerce.common.payment.PaymentGatewayType gatewayType) Gets the gateway that was used to process this order payment.voidsetReferenceNumber(String referenceNumber) Sets the soft link to aReferencedentity stored in the blSecurePU persistence unit.voidsetTransactions(List<PaymentTransaction> details) All of the transactions that have been applied to this particular payment.voidsetType(org.broadleafcommerce.common.payment.PaymentType type) Sets the type of this payment like Credit Card or Gift CardMethods inherited from interface org.broadleafcommerce.common.copy.MultiTenantCloneable
createOrRetrieveCopyInstanceMethods inherited from interface org.broadleafcommerce.common.persistence.Status
getArchived, isActive, setArchived
-
Method Details
-
getId
Long getId() -
setId
-
getOrder
Order getOrder() -
setOrder
-
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 theOrderPayments for a particularOrdershould equalOrder.getTotal() -
setAmount
void setAmount(org.broadleafcommerce.common.money.Money amount) The amount that this payment is allotted for. The summation of all of theOrderPayments for a particularOrdershould equalOrder.getTotal() -
getReferenceNumber
String getReferenceNumber()The soft link to aReferencedentity 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
Sets the soft link to aReferencedentity 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 onePaymentTransactionfor everyOrderPayment.To add a transaction to an
OrderPaymentseeaddTransaction(PaymentTransaction). -
setTransactions
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 onePaymentTransactionfor everyOrderPayment.To add a transaction to an
OrderPaymentseeaddTransaction(PaymentTransaction). -
addTransaction
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 aPaymentTransactioncan actually be added to this payment. For instance, there can only be a singlePaymentTransactionType.AUTHORIZEfor a payment.- Parameters:
type- the type of transaction to look for withingetTransactions()- 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 typePaymentTransactionType.AUTHORIZEorPaymentTransactionType.AUTHORIZE_AND_CAPTUREif 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 thegetTransactions()- 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 typePaymentTransactionType.AUTHORIZE_AND_CAPTUREorPaymentTransactionType.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 typePaymentType.THIRD_PARTY_ACCOUNTandPaymentType.CREDIT_CARDfinal 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()}.
-