Class PaymentTransaction
- java.lang.Object
-
- com.broadleafcommerce.paymentgateway.domain.PaymentTransaction
-
- All Implemented Interfaces:
Serializable
public class PaymentTransaction extends Object implements Serializable
Used to store individual transactions about a particular payment. While a
PaymentValidationRequestholds data like what the user might be paying with and the total amount they will be paying (like credit card and $10), aPaymentTransactionis used to record transactional interactions with a payment gateway for a particular payment. Thus,PaymentTransactionsdo not make sense by themselves and ONLY make sense in the context of aPaymentValidationRequest.For instance, the user might pay $10, but rather than capture the payment during checkout, the business may first want to use & record an authorize-typed transaction. Later, when the business ships the item, a capture-typed transaction would be used & recorded.
In the above case, this also implies that a
PaymentTransactioncan have a parent transaction (retrieved viagetParentTransactionId()). The parent transaction will only be set in the following cases:- Child Transaction -> Parent Transaction
- Reverse Authorize -> Authorize
- Capture -> Authorize
- Refund -> Capture
- Refund -> AuthorizeAndCapture
- Author:
- Phillip Verheyden (phillipuniverse), Chris Kittrell (ckittrell)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PaymentTransaction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(Object other)booleanequals(Object o)javax.money.MonetaryAmountgetAmount()The amount related to this transaction.Map<String,String>getAttributes()Map of specific attributes that have been gathered from the raw response.javax.money.CurrencyUnitgetCurrency()The currency gathered fromgetAmount()StringgetCustomerIpAddress()The customer IP address that instigated this transactionInstantgetDateRecorded()The timestamp when this transaction response was recordedStringgetDeclineType()The type of transaction failure (hard vs soft failure)StringgetFailureType()The type of transaction failureStringgetGatewayMessage()Message from the gateway describing the result of the transaction.StringgetGatewayResponseCode()The response code provided by the payment gateway which may represent a success or failureStringgetGatewayTransactionId()The gateway-specific id for the transaction.StringgetId()The id of this payment transaction.StringgetManagementState()The state of this transaction - e.g.StringgetParentTransactionId()The id of the parentPaymentTransaction.StringgetRawResponse()The string representation of the serialized response from the gateway.StringgetRequestId()The id used to represent the request that produced this transaction.StringgetSource()The name of the system that initiated the transaction - e.g.StringgetStatus()The status of the transactionStringgetThreeDSecureVerificationUrl()The gateway-provided url where the customer must verify that they are in fact the owner of the payment method.StringgetTransactionReferenceId()The transaction id known by the payment gateway.StringgetType()The type of this transaction (authorize, capture, refund, etc.)IntegergetVersion()The version of this payment transaction.inthashCode()booleanisIndeterminateResult()Tells if this transaction has an indeterminate result.voidsetAmount(javax.money.MonetaryAmount amount)The amount related to this transaction.voidsetAttributes(Map<String,String> attributes)Map of specific attributes that have been gathered from the raw response.voidsetCustomerIpAddress(String customerIpAddress)The customer IP address that instigated this transactionvoidsetDateRecorded(Instant dateRecorded)The timestamp when this transaction response was recordedvoidsetDeclineType(String declineType)The type of transaction failure (hard vs soft failure)voidsetFailureType(String failureType)The type of transaction failurevoidsetGatewayMessage(String gatewayMessage)Message from the gateway describing the result of the transaction.voidsetGatewayResponseCode(String gatewayResponseCode)The response code provided by the payment gateway which may represent a success or failurevoidsetGatewayTransactionId(String gatewayTransactionId)The gateway-specific id for the transaction.voidsetId(String id)The id of this payment transaction.voidsetIndeterminateResult(boolean indeterminateResult)Tells if this transaction has an indeterminate result.voidsetManagementState(String managementState)The state of this transaction - e.g.voidsetParentTransactionId(String parentTransactionId)The id of the parentPaymentTransaction.voidsetRawResponse(String rawResponse)The string representation of the serialized response from the gateway.voidsetRequestId(String requestId)The id used to represent the request that produced this transaction.voidsetSource(String source)The name of the system that initiated the transaction - e.g.voidsetStatus(String status)The status of the transactionvoidsetThreeDSecureVerificationUrl(String threeDSecureVerificationUrl)The gateway-provided url where the customer must verify that they are in fact the owner of the payment method.voidsetTransactionReferenceId(String transactionReferenceId)The transaction id known by the payment gateway.voidsetType(String type)The type of this transaction (authorize, capture, refund, etc.)voidsetVersion(Integer version)The version of this payment transaction.StringtoString()
-
-
-
Method Detail
-
getCurrency
@Nullable public javax.money.CurrencyUnit getCurrency()
The currency gathered fromgetAmount()- Returns:
- The currency gathered from the amount
-
getId
public String getId()
The id of this payment transaction.- Returns:
- The id of this payment transaction.
-
getType
public String getType()
The type of this transaction (authorize, capture, refund, etc.)- Returns:
- The type of this transaction (authorize, capture, refund, etc.)
-
getManagementState
public String getManagementState()
The state of this transaction - e.g. whether the transaction is scheduled for reversal or if it's being used in an active checkout. If the transaction was not successful, then we expect this value to be null.- Returns:
- The state of this transaction
-
getStatus
public String getStatus()
The status of the transaction- Returns:
- The status of the transaction
-
getTransactionReferenceId
public String getTransactionReferenceId()
The transaction id known by the payment gateway. This reference can be used to link the request to the gateway's record of the transaction in the case that the calling application does not receive a response from the gateway.- Returns:
- The transaction id known by the payment gateway
-
getGatewayTransactionId
public String getGatewayTransactionId()
The gateway-specific id for the transaction.- Returns:
- The gateway-specific id for the transaction
-
getSource
public String getSource()
The name of the system that initiated the transaction - e.g. CART_OPERATION_SERVICES vs ORDER_OPERATION_SERVICES.- Returns:
- The name of the system that initiated the transaction
-
getRequestId
public String getRequestId()
The id used to represent the request that produced this transaction. This is normally related to a checkout submission request.- Returns:
- The id used to represent the request that produced this transaction
-
getAmount
public javax.money.MonetaryAmount getAmount()
The amount related to this transaction. Depending on thetype, this may be the amount authorized, captured, refunded, etc.- Returns:
- The amount related to this transaction
-
getDateRecorded
public Instant getDateRecorded()
The timestamp when this transaction response was recorded- Returns:
- The timestamp when this transaction response was recorded
-
getGatewayResponseCode
public String getGatewayResponseCode()
The response code provided by the payment gateway which may represent a success or failure- Returns:
- The response code provided by the payment gateway which may represent a success or failure
-
getFailureType
public String getFailureType()
The type of transaction failure- Returns:
- The type of transaction failure
-
getDeclineType
public String getDeclineType()
The type of transaction failure (hard vs soft failure)- Returns:
- The type of transaction failure (hard vs soft failure)
-
getThreeDSecureVerificationUrl
public String getThreeDSecureVerificationUrl()
The gateway-provided url where the customer must verify that they are in fact the owner of the payment method. The customer is typically redirected to this location, but the page can also be rendered within an iframe if you'd like.- Returns:
- The gateway-provided url where the customer must verify that they are in fact the owner of the payment method.
-
getGatewayMessage
public String getGatewayMessage()
Message from the gateway describing the result of the transaction.- Returns:
- Message from the gateway describing the result of the transaction.
-
getRawResponse
public String getRawResponse()
The string representation of the serialized response from the gateway. This is usually the complete request parameter map serialized in string form.- Returns:
- The string representation of the serialized response from the gateway
-
getParentTransactionId
public String getParentTransactionId()
The id of the parentPaymentTransaction. Necessary for operations on a payment that require something to have happened beforehand. For instance, an authorize transaction would not have a parent but a capture must have an authorize parent transaction and a refund must have a capture parent transaction. The full set of expected parent-child transaction relationships are as follows:- Child Transaction -> Parent Transaction
- Reverse Authorize -> Authorize
- Capture -> Authorize
- Refund -> Capture
- Refund -> AuthorizeAndCapture
- Returns:
- The id of the parent PaymentTransaction.
-
getAttributes
public Map<String,String> getAttributes()
Map of specific attributes that have been gathered from the raw response. This should be used for data points that are to be used programmatically. For example, a gateway-specific transaction id that can be used to capture or refund the transaction.- Returns:
- Map of specific fields that have been gathered from the raw response
-
getCustomerIpAddress
public String getCustomerIpAddress()
The customer IP address that instigated this transaction- Returns:
- The customer IP address that instigated this transaction
-
isIndeterminateResult
public boolean isIndeterminateResult()
Tells if this transaction has an indeterminate result.Having an indeterminate result means that the true outcome of the transaction is not known. For example, if a transaction is sent to the payment processor but a network error occurred, it is not known to us whether the user was actually charged or not (thus, the result is indeterminate).
Transactions should be marked as indeterminate when sending to the payment processor, and then unmarked once a response is received, understood, and recorded. This means that a transaction in an indeterminate result state is expected during the sending to processor phase. However, if the transaction remains in that state for an excessive amount of time, something likely went wrong and the transaction will need to be reconciled. If the transaction changes from the sending to processor status but remains indeterminate, the transaction will also require reconciliation in that scenario.
Some situations which may lead to an indeterminate result:
- A transaction is sent to the processor, but a network error prevents us from receiving the response
- A transaction is sent to the processor, but the processor returns an unexpected error (e.g. 500 internal server error)
- A transaction is sent to the processor and a response is received, but cannot be recorded because Cart Services is down
- A transaction is sent to the processor and a response is received, but cannot be recorded because the database is down
-
getVersion
public Integer getVersion()
The version of this payment transaction. Used for checking that the requested version of the payment transaction is up-to-date before saving changes. Required for any request which results in an update being made to the payment transaction. This should never be manually incremented/decremented.
-
setId
public void setId(String id)
The id of this payment transaction.- Parameters:
paymentTransactionId- The id of this payment transaction.
-
setType
public void setType(String type)
The type of this transaction (authorize, capture, refund, etc.)- Parameters:
amount- The type of this transaction
-
setManagementState
public void setManagementState(String managementState)
The state of this transaction - e.g. whether the transaction is scheduled for reversal or if it's being used in an active checkout. If the transaction was not successful, then we expect this value to be null.- Parameters:
managementState- The state of this transaction
-
setStatus
public void setStatus(String status)
The status of the transaction- Parameters:
status- The status of the transaction
-
setTransactionReferenceId
public void setTransactionReferenceId(String transactionReferenceId)
The transaction id known by the payment gateway. This reference can be used to link the request to the gateway's record of the transaction in the case that the calling application does not receive a response from the gateway.- Parameters:
transactionReferenceId- The transaction id known by the payment gateway
-
setGatewayTransactionId
public void setGatewayTransactionId(String gatewayTransactionId)
The gateway-specific id for the transaction.- Parameters:
gatewayTransactionId- The gateway-specific id for the transaction
-
setSource
public void setSource(String source)
The name of the system that initiated the transaction - e.g. CART_OPERATION_SERVICES vs ORDER_OPERATION_SERVICES.- Parameters:
source- The name of the system that initiated the transaction
-
setRequestId
public void setRequestId(String requestId)
The id used to represent the request that produced this transaction. This is normally related to a checkout submission request.- Parameters:
requestId- The id used to represent the request that produced this transaction
-
setAmount
public void setAmount(javax.money.MonetaryAmount amount)
The amount related to this transaction. Depending on thetype, this may be the amount authorized, captured, refunded, etc.- Parameters:
amount- The amount related to this transaction
-
setDateRecorded
public void setDateRecorded(Instant dateRecorded)
The timestamp when this transaction response was recorded- Parameters:
dateRecorded- The timestamp when this transaction response was recorded
-
setGatewayResponseCode
public void setGatewayResponseCode(String gatewayResponseCode)
The response code provided by the payment gateway which may represent a success or failure- Parameters:
gatewayResponseCode- The response code provided by the payment gateway which may represent a success or failure
-
setFailureType
public void setFailureType(String failureType)
The type of transaction failure- Parameters:
failureType- The type of transaction failure
-
setDeclineType
public void setDeclineType(String declineType)
The type of transaction failure (hard vs soft failure)- Parameters:
failureType- The type of transaction failure (hard vs soft failure)
-
setThreeDSecureVerificationUrl
public void setThreeDSecureVerificationUrl(String threeDSecureVerificationUrl)
The gateway-provided url where the customer must verify that they are in fact the owner of the payment method. The customer is typically redirected to this location, but the page can also be rendered within an iframe if you'd like.- Parameters:
threeDSecureVerificationUrl- The gateway-provided url where the customer must verify that they are in fact the owner of the payment method.
-
setGatewayMessage
public void setGatewayMessage(String gatewayMessage)
Message from the gateway describing the result of the transaction.- Parameters:
gatewayMessage- Message from the gateway describing the result of the transaction.
-
setRawResponse
public void setRawResponse(String rawResponse)
The string representation of the serialized response from the gateway. This is usually the complete request parameter map serialized in string form.- Parameters:
rawResponse- The string representation of the serialized response from the gateway
-
setParentTransactionId
public void setParentTransactionId(String parentTransactionId)
The id of the parentPaymentTransaction. Necessary for operations on a payment that require something to have happened beforehand. For instance, an authorize transaction would not have a parent but a capture must have an authorize parent transaction and a refund must have a capture parent transaction. The full set of expected parent-child transaction relationships are as follows:- Child Transaction -> Parent Transaction
- Reverse Authorize -> Authorize
- Capture -> Authorize
- Refund -> Capture
- Refund -> AuthorizeAndCapture
- Parameters:
parentTransactionId- The id of the parent PaymentTransaction.
-
setAttributes
public void setAttributes(Map<String,String> attributes)
Map of specific attributes that have been gathered from the raw response. This should be used for data points that are to be used programmatically. For example, a gateway-specific transaction id that can be used to capture or refund the transaction.- Parameters:
attributes- Map of specific fields that have been gathered from the raw response
-
setCustomerIpAddress
public void setCustomerIpAddress(String customerIpAddress)
The customer IP address that instigated this transaction- Parameters:
customerIpAddress- The customer IP address that instigated this transaction
-
setIndeterminateResult
public void setIndeterminateResult(boolean indeterminateResult)
Tells if this transaction has an indeterminate result.Having an indeterminate result means that the true outcome of the transaction is not known. For example, if a transaction is sent to the payment processor but a network error occurred, it is not known to us whether the user was actually charged or not (thus, the result is indeterminate).
Transactions should be marked as indeterminate when sending to the payment processor, and then unmarked once a response is received, understood, and recorded. This means that a transaction in an indeterminate result state is expected during the sending to processor phase. However, if the transaction remains in that state for an excessive amount of time, something likely went wrong and the transaction will need to be reconciled. If the transaction changes from the sending to processor status but remains indeterminate, the transaction will also require reconciliation in that scenario.
Some situations which may lead to an indeterminate result:
- A transaction is sent to the processor, but a network error prevents us from receiving the response
- A transaction is sent to the processor, but the processor returns an unexpected error (e.g. 500 internal server error)
- A transaction is sent to the processor and a response is received, but cannot be recorded because Cart Services is down
- A transaction is sent to the processor and a response is received, but cannot be recorded because the database is down
-
setVersion
public void setVersion(Integer version)
The version of this payment transaction. Used for checking that the requested version of the payment transaction is up-to-date before saving changes. Required for any request which results in an update being made to the payment transaction. This should never be manually incremented/decremented.
-
canEqual
protected boolean canEqual(Object other)
-
-