Class Payment
java.lang.Object
com.broadleafcommerce.paymenttransaction.domain.Payment
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware
,Serializable
public class Payment
extends Object
implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware
This entity is designed to store payment methods associated to a Cart, the getAmount()
the user is to be charged via that payment method, and the history of attempted transactions
(authorizations, charges, refunds, etc.) against that payment method for the owning Cart.
Every payment gateway interaction should have its results stored in the transactions
collection.
Payments
are not actually deleted from the database but rather are only
soft-deleted (archived = true)
- Author:
- Chad Harchar (charchar), Chris Kittrell (ckittrell)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddAddress
(String addressType, Address address) Adds anAddress
to the map, identified by the provided addressType.protected boolean
boolean
The list of restrictions that apply to payment access.getAddress
(String addressType) Gathers one of the payment's relatedaddresses
by typeThe collection of related addresses that may include billing or shipping addressesjavax.money.MonetaryAmount
The payment's adjustments (a.k.a discounts) total, usually excluding shipping/fulfillment discounts.javax.money.MonetaryAmount
The amount for which this payment is allotted.General use map to capture any additional attributes needed for this PaymentGathers the billing address.com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState
A subset ofTracking
information to expose the context state for this object.javax.money.CurrencyUnit
The currency gathered from thegetAmount()
Deprecated.The date that this payment was created.General use map to capture any display properties for this Paymentjavax.money.MonetaryAmount
The total fees related to the transactionamount
Note: Only theamount
is required, but if this value is included, then thesubtotal
,fulfillmentTotal
,adjustmentsTotal
,taxTotal
, &includedTaxTotal
should be included also.javax.money.MonetaryAmount
The payment's total fulfillment cost.The gateway used to process this payment.getId()
The id of this payment.javax.money.MonetaryAmount
The amount of taxes that are included in the subtotal (VAT).getName()
The name of this payment.The id of the entity that owns this payment.Describes the owner of the payment.The email address of the owning user identified byowningUserType
andowningUserId
.The id of the owning user that owns this payment.The name of the owning user identified byowningUserType
andowningUserId
.Describes the owning user type of the payment.Map to capture any information about the payment method needed to perform gateway transactionsThe id of the saved payment method that was used to build this payment object.Gathers the shipping address.boolean
Should the payment method be saved to the owning userboolean
Deprecated, for removal: This API element is subject to removal in a future version.since 1.0.2, in favor ofgetShouldSavePaymentForFutureUse()
to support owning user types other than a customer (i.e.javax.money.MonetaryAmount
The payment's total usually excluding adjustments, tax, fees, and shipping.javax.money.MonetaryAmount
The payment's total tax cost.Transaction data representing each payment gateway interaction related to this payment.getType()
The type of this payment like Credit Card or Gift Card.The version of this payment.int
hashCode()
boolean
Returns whether or not the payment is for an anonymous user.boolean
Whether or not the underlying payment method can only be used once.void
setAccessRestrictions
(List<String> accessRestrictions) The list of restrictions that apply to payment access.void
setAddressByType
(Map<String, Address> addressByType) The collection of related addresses that may include billing or shipping addressesvoid
setAdjustmentsTotal
(javax.money.MonetaryAmount adjustmentsTotal) The payment's adjustments (a.k.a discounts) total, usually excluding shipping/fulfillment discounts.void
setAmount
(javax.money.MonetaryAmount amount) The amount for which this payment is allotted.void
setAttributes
(Map<String, String> attributes) General use map to capture any additional attributes needed for this Paymentvoid
setContextState
(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.void
setCustomerRef
(CustomerRef customerRef) Deprecated.since 1.0.2, usegetOwningUserType()
andgetOwningUserId()
insteadvoid
setDateCreated
(Instant dateCreated) The date that this payment was created.void
setDisplayAttributes
(Map<String, String> displayAttributes) General use map to capture any display properties for this Paymentvoid
setFeesTotal
(javax.money.MonetaryAmount feesTotal) The total fees related to the transactionamount
Note: Only theamount
is required, but if this value is included, then thesubtotal
,fulfillmentTotal
,adjustmentsTotal
,taxTotal
, &includedTaxTotal
should be included also.void
setFulfillmentTotal
(javax.money.MonetaryAmount fulfillmentTotal) The payment's total fulfillment cost.void
setGatewayType
(String gatewayType) The gateway used to process this payment.void
The id of this payment.void
setIncludedTaxTotal
(javax.money.MonetaryAmount includedTaxTotal) The amount of taxes that are included in the subtotal (VAT).void
The name of this payment.void
setOwnerId
(String ownerId) The id of the entity that owns this payment.void
setOwnerType
(String ownerType) Describes the owner of the payment.void
setOwningUserEmailAddress
(String owningUserEmailAddress) The email address of the owning user identified byowningUserType
andowningUserId
.void
setOwningUserId
(String owningUserId) The id of the owning user that owns this payment.void
setOwningUserName
(String owningUserName) The name of the owning user identified byowningUserType
andowningUserId
.void
setOwningUserType
(String owningUserType) Describes the owning user type of the payment.void
setPaymentMethodProperties
(Map<String, String> paymentMethodProperties) Map to capture any information about the payment method needed to perform gateway transactionsvoid
setSavedPaymentMethodId
(String savedPaymentMethodId) The id of the saved payment method that was used to build this payment object.void
setShouldSavePaymentForFutureUse
(boolean shouldSavePaymentForFutureUse) Should the payment method be saved to theowning user
.void
setShouldSavePaymentToCustomer
(boolean shouldSavePaymentToCustomer) Deprecated.since 1.0.2, in favor ofshouldSavePaymentForFutureUse
to support owning user types other than a customer (i.e.void
setSingleUsePaymentMethod
(boolean isSingleUsePaymentMethod) Whether or not the underlying payment method can only be used once.void
setSubtotal
(javax.money.MonetaryAmount subtotal) The payment's total usually excluding adjustments, tax, fees, and shipping.void
setTaxTotal
(javax.money.MonetaryAmount taxTotal) The payment's total tax cost.void
setTransactions
(List<PaymentTransaction> transactions) Transaction data representing each payment gateway interaction related to this payment.void
The type of this payment like Credit Card or Gift Card.void
setVersion
(Integer version) The version of this payment.toString()
-
Constructor Details
-
Payment
public Payment()
-
-
Method Details
-
getCurrency
@Nullable public javax.money.CurrencyUnit getCurrency()The currency gathered from thegetAmount()
- Returns:
- The currency gathered from the payment amount
-
addAddress
Adds anAddress
to the map, identified by the provided addressType.- Parameters:
addressType
- The type of address that is to be addedaddress
- The address that is to be added- Returns:
- The address that was added to the map.
-
getAddress
Gathers one of the payment's relatedaddresses
by type- Returns:
- The payment's related address identified by type
-
getShippingAddress
Gathers the shipping address.- Returns:
- The payment's shipping address
-
getBillingAddress
Gathers the billing address.- Returns:
- The payment's billing address
-
getShouldSavePaymentToCustomer
Deprecated, for removal: This API element is subject to removal in a future version.since 1.0.2, in favor ofgetShouldSavePaymentForFutureUse()
to support owning user types other than a customer (i.e. account). -
getShouldSavePaymentForFutureUse
public boolean getShouldSavePaymentForFutureUse()Should the payment method be saved to the owning user- Returns:
- Should the payment method be saved to the owning user
-
isAnonymous
public boolean isAnonymous()Returns whether or not the payment is for an anonymous user.- Returns:
- whether or not the payment is for an anonymous user.
-
getId
The id of this payment.- Returns:
- The id of this payment.
-
getName
The name of this payment. This name is typically something like "Visa ending in 1234".- Returns:
- The name of this payment.
-
getOwnerType
Describes the owner of the payment. For example, the payment could have originated with a cart or a subscription, therefore this value might be CART or SUBSCRIPTION.- Returns:
- The type describing the owner of the payment
-
getOwnerId
The id of the entity that owns this payment. For example, this may be a cart id, or a subscription billing cycle id.- Returns:
- The id of the entity that owns this payment.
-
getOwningUserType
Describes the owning user type of the payment. For example, the payment could belong to a customer or an account, therefore this value might be BLC_CUSTOMER or BLC_ACCOUNT.- Returns:
- The type describing the owning user of the payment
- See Also:
-
getOwningUserId
The id of the owning user that owns this payment. For example, this may be a customer id, or an account id.- Returns:
- The id of the owning user that owns this payment.
-
getOwningUserName
The name of the owning user identified byowningUserType
andowningUserId
.- Returns:
- The name of the owning user.
-
getOwningUserEmailAddress
The email address of the owning user identified byowningUserType
andowningUserId
.- Returns:
- The email address of the owning user.
-
getCustomerRef
Deprecated.since 1.0.2, usegetOwningUserType()
andgetOwningUserId()
insteadA reference to the customer that owns this payment.- Returns:
- A reference to the customer that owns this payment.
-
getAccessRestrictions
The list of restrictions that apply to payment access.- Returns:
- the list of restrictions that apply to payment access
-
getSavedPaymentMethodId
The id of the saved payment method that was used to build this payment object. Note: This property is only relevant if the user desires to use a saved payment method to pay for their order. Otherwise, this value should remain unset.- Returns:
- The id of the saved payment method.
-
getType
The type of this payment like Credit Card or Gift Card.- Returns:
- The type of this payment like Credit Card or Gift Card.
-
getGatewayType
The gateway used to process this payment. Only a SINGLE payment gateway can be used for a payment.- Returns:
- The gateway used to process this payment.
-
getAmount
public javax.money.MonetaryAmount getAmount()The amount for which this payment is allotted. If specified, the amount details should be equal to this amount using the following equation: transactionAmount =subtotal
+fulfillmentTotal
+feesTotal
-adjustmentsTotal
+taxTotal
-includedTaxTotal
.- Returns:
- The amount for which this payment is allotted.
-
getSubtotal
public javax.money.MonetaryAmount getSubtotal()The payment's total usually excluding adjustments, tax, fees, and shipping. Note: Only theamount
is required, but if this value is included, then thefulfillmentTotal
,feesTotal
,adjustmentsTotal
,taxTotal
, &includedTaxTotal
should be included also.- Returns:
- The payment's total usually excluding adjustments, tax, fees, and shipping.
-
getAdjustmentsTotal
public javax.money.MonetaryAmount getAdjustmentsTotal()The payment's adjustments (a.k.a discounts) total, usually excluding shipping/fulfillment discounts. Note: Only theamount
is required, but if this value is included, then thesubtotal
,fulfillmentTotal
,feesTotal
,taxTotal
, &includedTaxTotal
should be included also.- Returns:
- The payment's adjustments (a.k.a discounts) total, usually excluding shipping/fulfillment discounts.
-
getFulfillmentTotal
public javax.money.MonetaryAmount getFulfillmentTotal()The payment's total fulfillment cost. Note: Only theamount
is required, but if this value is included, then thesubtotal
,feesTotal
,adjustmentsTotal
,taxTotal
, &includedTaxTotal
should be included also.- Returns:
- The payment's total fulfillment cost.
-
getFeesTotal
public javax.money.MonetaryAmount getFeesTotal()The total fees related to the transactionamount
Note: Only theamount
is required, but if this value is included, then thesubtotal
,fulfillmentTotal
,adjustmentsTotal
,taxTotal
, &includedTaxTotal
should be included also.- Returns:
- The total fees related to the transaction
amount
-
getTaxTotal
public javax.money.MonetaryAmount getTaxTotal()The payment's total tax cost. Note: Only theamount
is required, but if this value is included, then thesubtotal
,fulfillmentTotal
,feesTotal
,adjustmentsTotal
, &includedTaxTotal
should be included also.- Returns:
- The payment's total tax cost.
-
getIncludedTaxTotal
public javax.money.MonetaryAmount getIncludedTaxTotal()The amount of taxes that are included in the subtotal (VAT). Note: Only theamount
is required, but if this value is included, then thesubtotal
,fulfillmentTotal
,feesTotal
,adjustmentsTotal
, &taxTotal
should be included also.- Returns:
- The amount of taxes that are included in the subtotal (VAT).
-
getAddressByType
The collection of related addresses that may include billing or shipping addresses- Returns:
- The collection of related addresses
-
getPaymentMethodProperties
Map to capture any information about the payment method needed to perform gateway transactions- Returns:
- Map to capture any information about the payment method needed to perform gateway transactions
-
getAttributes
General use map to capture any additional attributes needed for this Payment- Returns:
- General use map to capture any additional attributes needed for this Payment
-
getDisplayAttributes
General use map to capture any display properties for this Payment- Returns:
- General use map to capture any display properties for this Payment
-
getTransactions
Transaction data representing each payment gateway interaction related to this payment.- Returns:
- Transactions related to this payment.
-
isSingleUsePaymentMethod
public boolean isSingleUsePaymentMethod()Whether or not the underlying payment method can only be used once. In most cases, we're managing a single-use token that represents a credit card. This flag is especially important for managing payments with successful transactions. In those cases, the token has already been used and cannot be reused. If we need modify the payment's amount, then we may actually need to archive the existing payment, and create a new payment, with a new underlying token. Additionally, this flag is helpful when needing to re-authorize an expired authorization transaction. In that case, if the payment represents a single-use payment method, then the re-authorization may not be possible, and you'll need to seek an alternative form of payment.- Returns:
- Whether or not the underlying payment method can only be used once
-
getContextState
public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()A subset ofTracking
information to expose the context state for this object.- Specified by:
getContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Returns:
- a subset of
Tracking
information to expose the context state for this object
-
getVersion
The version of this payment. Used for checking that the requested version of the payment is up-to-date before saving changes. Required for any request which results in an update being made to the payment. This should never be manually incremented/decremented. -
getDateCreated
The date that this payment was created.- Returns:
- The date that this payment was created.
-
setId
The id of this payment.- Parameters:
id
- The id of this payment.
-
setName
The name of this payment. This name is typically something like "Visa ending in 1234".- Parameters:
name
- The name of this payment.
-
setOwnerType
Describes the owner of the payment. For example, the payment could have originated with a cart or a subscription, therefore this value might be CART or SUBSCRIPTION.- Parameters:
ownerType
- The type describing the owner of the payment
-
setOwnerId
The id of the entity that owns this payment. For example, this may be a cart id, or a subscription billing cycle id.- Parameters:
ownerId
- The id of the entity that owns this payment.
-
setOwningUserType
Describes the owning user type of the payment. For example, the payment could belong to a customer or an account, therefore this value might be BLC_CUSTOMER or BLC_ACCOUNT.- Parameters:
owningUserType
- The type describing the owning user of the payment- See Also:
-
setOwningUserId
The id of the owning user that owns this payment. For example, this may be a customer id, or an account id.- Parameters:
owningUserId
- The id of the owning user that owns this payment.
-
setOwningUserName
The name of the owning user identified byowningUserType
andowningUserId
.- Parameters:
owningUserName
- The name of the owning user.
-
setOwningUserEmailAddress
The email address of the owning user identified byowningUserType
andowningUserId
.- Parameters:
owningUserEmailAddress
- The email address of the owning user.
-
setCustomerRef
Deprecated.since 1.0.2, usegetOwningUserType()
andgetOwningUserId()
insteadA reference to the customer that owns this payment.- Parameters:
customerRef
- A reference to the customer that owns this payment.
-
setAccessRestrictions
The list of restrictions that apply to payment access.- Parameters:
accessRestrictions
- the list of restrictions that apply to payment access
-
setSavedPaymentMethodId
The id of the saved payment method that was used to build this payment object. Note: This property is only relevant if the user desires to use a saved payment method to pay for their order. Otherwise, this value should remain unset.- Parameters:
savedPaymentMethodId
- The id of the saved payment method.
-
setType
The type of this payment like Credit Card or Gift Card.- Parameters:
type
- The type of this payment like Credit Card or Gift Card.
-
setGatewayType
The gateway used to process this payment. Only a SINGLE payment gateway can be used for a payment.- Parameters:
gatewayType
- The gateway used to process this payment.
-
setAmount
public void setAmount(javax.money.MonetaryAmount amount) The amount for which this payment is allotted. If specified, the amount details should be equal to this amount using the following equation: transactionAmount =subtotal
+fulfillmentTotal
+feesTotal
-adjustmentsTotal
+taxTotal
-includedTaxTotal
.- Parameters:
amount
- The amount for which this payment is allotted.
-
setSubtotal
public void setSubtotal(javax.money.MonetaryAmount subtotal) The payment's total usually excluding adjustments, tax, fees, and shipping. Note: Only theamount
is required, but if this value is included, then thefulfillmentTotal
,feesTotal
,adjustmentsTotal
,taxTotal
, &includedTaxTotal
should be included also.- Parameters:
subtotal
- The payment's total usually excluding adjustments, tax, fees, and shipping.
-
setAdjustmentsTotal
public void setAdjustmentsTotal(javax.money.MonetaryAmount adjustmentsTotal) The payment's adjustments (a.k.a discounts) total, usually excluding shipping/fulfillment discounts. Note: Only theamount
is required, but if this value is included, then thesubtotal
,fulfillmentTotal
,feesTotal
,taxTotal
, &includedTaxTotal
should be included also.- Parameters:
adjustmentsTotal
- The payment's adjustments (a.k.a discounts) total, usually excluding shipping/fulfillment discounts.
-
setFulfillmentTotal
public void setFulfillmentTotal(javax.money.MonetaryAmount fulfillmentTotal) The payment's total fulfillment cost. Note: Only theamount
is required, but if this value is included, then thesubtotal
,feesTotal
,adjustmentsTotal
,taxTotal
, &includedTaxTotal
should be included also.- Parameters:
fulfillmentTotal
- The payment's total fulfillment cost.
-
setFeesTotal
public void setFeesTotal(javax.money.MonetaryAmount feesTotal) The total fees related to the transactionamount
Note: Only theamount
is required, but if this value is included, then thesubtotal
,fulfillmentTotal
,adjustmentsTotal
,taxTotal
, &includedTaxTotal
should be included also.- Parameters:
feesTotal
- The total fees related to the transactionamount
-
setTaxTotal
public void setTaxTotal(javax.money.MonetaryAmount taxTotal) The payment's total tax cost. Note: Only theamount
is required, but if this value is included, then thesubtotal
,fulfillmentTotal
,feesTotal
,adjustmentsTotal
, &includedTaxTotal
should be included also.- Parameters:
taxTotal
- The payment's total tax cost.
-
setIncludedTaxTotal
public void setIncludedTaxTotal(javax.money.MonetaryAmount includedTaxTotal) The amount of taxes that are included in the subtotal (VAT). Note: Only theamount
is required, but if this value is included, then thesubtotal
,fulfillmentTotal
,feesTotal
,adjustmentsTotal
, &taxTotal
should be included also.- Parameters:
includedTaxTotal
- The amount of taxes that are included in the subtotal (VAT).
-
setAddressByType
The collection of related addresses that may include billing or shipping addresses- Parameters:
addressByType
- The collection of related addresses
-
setPaymentMethodProperties
Map to capture any information about the payment method needed to perform gateway transactions- Parameters:
paymentMethodProperties
- Map to capture any information about the payment method needed to perform gateway transactions
-
setAttributes
General use map to capture any additional attributes needed for this Payment- Parameters:
attributes
- General use map to capture any additional attributes needed for this Payment
-
setDisplayAttributes
General use map to capture any display properties for this Payment- Parameters:
displayAttributes
- General use map to capture any display properties for this Payment
-
setTransactions
Transaction data representing each payment gateway interaction related to this payment.- Parameters:
transactions
- Transactions related to this payment.
-
setSingleUsePaymentMethod
public void setSingleUsePaymentMethod(boolean isSingleUsePaymentMethod) Whether or not the underlying payment method can only be used once. In most cases, we're managing a single-use token that represents a credit card. This flag is especially important for managing payments with successful transactions. In those cases, the token has already been used and cannot be reused. If we need modify the payment's amount, then we may actually need to archive the existing payment, and create a new payment, with a new underlying token. Additionally, this flag is helpful when needing to re-authorize an expired authorization transaction. In that case, if the payment represents a single-use payment method, then the re-authorization may not be possible, and you'll need to seek an alternative form of payment.- Parameters:
isSingleUsePaymentMethod
- Whether or not the underlying payment method can only be used once
-
setShouldSavePaymentToCustomer
Deprecated.since 1.0.2, in favor ofshouldSavePaymentForFutureUse
to support owning user types other than a customer (i.e. account). -
setShouldSavePaymentForFutureUse
public void setShouldSavePaymentForFutureUse(boolean shouldSavePaymentForFutureUse) Should the payment method be saved to theowning user
. Typically, this value is set totrue
when the payment's initial transaction is executed using a single-use token, and produces a mutli-use token that can be used for future purchases. In that case, we'd expect the multi-use token to be provided viaPaymentResponse.getPaymentMethodProperties()
.- Parameters:
shouldSavePaymentForFutureUse
- Should the payment method be saved to the owning user
-
setContextState
public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.- Specified by:
setContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Parameters:
contextState
- a subset ofTracking
information to expose the context state for this object
-
setVersion
The version of this payment. Used for checking that the requested version of the payment is up-to-date before saving changes. Required for any request which results in an update being made to the payment. This should never be manually incremented/decremented. -
setDateCreated
The date that this payment was created.- Parameters:
dateCreated
- The date that this payment was created.
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-
getOwningUserType()
andgetOwningUserId()
instead