public interface OrderPayment extends Serializable, Status, 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 PaymentTransaction
s 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
).
OrderPayment
s are not actually deleted from the database but rather are only soft-deleted (archived = true)
PaymentTransactionType}
,
PaymentTransaction}
,
PaymentType}
Modifier and Type | Method and Description |
---|---|
void |
addTransaction(PaymentTransaction transaction)
A more declarative way to invoke
#getTransactions().add() . |
Money |
getAmount()
The amount that this payment is allotted for.
|
PaymentTransaction |
getAuthorizeTransaction()
Returns a successful transaction with type
PaymentTransactionType.AUTHORIZE or
PaymentTransactionType.AUTHORIZE_AND_CAPTURE if one exists. |
Address |
getBillingAddress()
Gets the billing address associated with this payment.
|
BroadleafCurrency |
getCurrency()
The currency that this payment should be taken in.
|
PaymentGatewayType |
getGatewayType()
Gets the gateway that was used to process this order payment.
|
Long |
getId() |
PaymentTransaction |
getInitialTransaction()
Returns the initial transaction for this order payment.
|
Order |
getOrder() |
String |
getReferenceNumber()
The soft link to a
Referenced entity which will be stored in the blSecurePU persistence unit. |
OrderPaymentStatus |
getStatus()
Convenience method to get the calculated status of this order payment based on the
state of the
getTransactions() |
Money |
getSuccessfulTransactionAmountForType(PaymentTransactionType type)
Returns all of the transactions on this payment that were successful for the given type.
|
Money |
getTransactionAmountForType(PaymentTransactionType type)
Looks through all of the transactions for this payment and adds up the amount for the given transaction type.
|
List<PaymentTransaction> |
getTransactions()
All of the transactions that have been applied to this particular payment.
|
List<PaymentTransaction> |
getTransactionsForType(PaymentTransactionType type)
Returns a transaction for given type.
|
PaymentType |
getType()
The type of this payment like Credit Card or Gift Card.
|
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 |
boolean |
isFinalPayment()
Returns whether or not this payment is considered to be the final payment on the order.
|
void |
setAmount(Money amount)
The amount that this payment is allotted for.
|
void |
setBillingAddress(Address billingAddress)
Sets the billing address associated with this payment.
|
void |
setId(Long id) |
void |
setOrder(Order order) |
void |
setPaymentGatewayType(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 |
setTransactions(List<PaymentTransaction> details)
All of the transactions that have been applied to this particular payment.
|
void |
setType(PaymentType type)
Sets the type of this payment like Credit Card or Gift Card
|
getArchived, isActive, setArchived
createOrRetrieveCopyInstance
Long getId()
void setId(Long id)
Order getOrder()
void setOrder(Order order)
Address getBillingAddress()
void setBillingAddress(Address billingAddress)
Money getAmount()
OrderPayment
s for a particular
Order
should equal Order.getTotal()
void setAmount(Money amount)
OrderPayment
s for a particular
Order
should equal Order.getTotal()
String getReferenceNumber()
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()).void setReferenceNumber(String referenceNumber)
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.PaymentType getType()
PaymentType}
void setType(PaymentType type)
PaymentType}
PaymentGatewayType getGatewayType()
void setPaymentGatewayType(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.
List<PaymentTransaction> getTransactions()
All of the transactions that have been applied to this particular payment. Transactions are denoted by the various
PaymentTransactionType
s. 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(PaymentTransaction)}
void setTransactions(List<PaymentTransaction> details)
All of the transactions that have been applied to this particular payment. Transactions are denoted by the various
PaymentTransactionType
s. 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(PaymentTransaction)}
void addTransaction(PaymentTransaction transaction)
#getTransactions().add()
. This is the preferred way to add a transaction
to this payment.List<PaymentTransaction> getTransactionsForType(PaymentTransactionType type)
PaymentTransaction
can actually be added to this payment. For instance, there can only be a single PaymentTransactionType.AUTHORIZE
for a payment.type
- the type of transaction to look for within getTransactions()
PaymentTransaction getInitialTransaction()
PaymentTransaction getAuthorizeTransaction()
PaymentTransactionType.AUTHORIZE
or
PaymentTransactionType.AUTHORIZE_AND_CAPTURE
if one exists. Note there can only be a single authorize
transaction for a given payment.Money getTransactionAmountForType(PaymentTransactionType type)
type
- #getSuccessfulTransactionAmountForType(PaymentTransactionType)}
Money getSuccessfulTransactionAmountForType(PaymentTransactionType type)
type
- the type of transactionOrderPaymentStatus getStatus()
getTransactions()
OrderPaymentStatus
boolean isConfirmed()
PaymentTransactionType.AUTHORIZE_AND_CAPTURE
or
PaymentTransactionType.AUTHORIZE
boolean isFinalPayment()
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.BroadleafCurrency getCurrency()
#getOrder()#getCurrency()
.Copyright © 2019. All rights reserved.