public class PaymentTransaction extends Object implements Serializable
Used to store individual transactions about a particular payment. While a Payment
holds
data like what the user might be paying with and the total amount they will be paying (like
credit card and $10), a PaymentTransaction
is used to record transactional interactions
with a payment gateway for a particular payment. Thus, PaymentTransactions
do not make sense by themselves and ONLY make sense in the context of a
Payment
.
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 PaymentTransaction
can have a parent
transaction (retrieved via getParentTransactionId()
). The parent transaction will
only be set in the following cases:
Constructor and Description |
---|
PaymentTransaction() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
canEqual(Object other) |
boolean |
equals(Object o) |
javax.money.MonetaryAmount |
getAmount()
The amount related to this transaction.
|
Map<String,String> |
getAttributes()
Map of specific attributes that have been gathered from the raw response.
|
String |
getCustomerIpAddress()
The customer IP address that instigated this transaction
|
Instant |
getDateRecorded()
The timestamp when this transaction response was recorded
|
String |
getDeclineType()
The type of transaction failure (hard vs soft failure)
|
String |
getFailureType()
The type of transaction failure
|
String |
getGatewayResponseCode()
The response code provided by the payment gateway which may represent a success or failure
|
String |
getId()
The id of this payment transaction.
|
String |
getManagementState()
The state of this transaction - e.g.
|
String |
getParentTransactionId()
The id of the parent
PaymentTransaction . |
String |
getRawResponse()
The string representation of the serialized response from the gateway.
|
String |
getRequestId()
The id used to represent the request that produced this transaction.
|
String |
getStatus()
The status of the transaction
|
String |
getTransactionReferenceId()
The transaction id known by the payment gateway.
|
String |
getType()
The type of this transaction (authorize, capture, refund, etc.)
|
int |
hashCode() |
boolean |
isIndeterminateResult()
Tells if this transaction has an indeterminate result.
|
void |
setAmount(javax.money.MonetaryAmount amount)
The amount related to this transaction.
|
void |
setAttributes(Map<String,String> attributes)
Map of specific attributes that have been gathered from the raw response.
|
void |
setCustomerIpAddress(String customerIpAddress)
The customer IP address that instigated this transaction
|
void |
setDateRecorded(Instant dateRecorded)
The timestamp when this transaction response was recorded
|
void |
setDeclineType(String declineType)
The type of transaction failure (hard vs soft failure)
|
void |
setFailureType(String failureType)
The type of transaction failure
|
void |
setGatewayResponseCode(String gatewayResponseCode)
The response code provided by the payment gateway which may represent a success or failure
|
void |
setId(String id)
The id of this payment transaction.
|
void |
setIndeterminateResult(boolean indeterminateResult)
Tells if this transaction has an indeterminate result.
|
void |
setManagementState(String managementState)
The state of this transaction - e.g.
|
void |
setParentTransactionId(String parentTransactionId)
The id of the parent
PaymentTransaction . |
void |
setRawResponse(String rawResponse)
The string representation of the serialized response from the gateway.
|
void |
setRequestId(String requestId)
The id used to represent the request that produced this transaction.
|
void |
setStatus(String status)
The status of the transaction
|
void |
setTransactionReferenceId(String transactionReferenceId)
The transaction id known by the payment gateway.
|
void |
setType(String type)
The type of this transaction (authorize, capture, refund, etc.)
|
String |
toString() |
boolean |
wasSuccessful()
Whether or not this transaction was successful based on
getStatus() . |
public boolean wasSuccessful()
getStatus()
.getStatus()
,
TransactionStatus
public String getId()
public String getType()
public String getManagementState()
TransactionManagementState
public String getStatus()
TransactionStatus
public String getTransactionReferenceId()
public String getRequestId()
public javax.money.MonetaryAmount getAmount()
type
, this may be the
amount authorized, captured, refunded, etc.public Instant getDateRecorded()
public String getGatewayResponseCode()
public String getFailureType()
public String getDeclineType()
public String getRawResponse()
public String getParentTransactionId()
PaymentTransaction
.
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:
public Map<String,String> getAttributes()
PaymentTransactionAdditionalFieldType
public String getCustomerIpAddress()
public boolean isIndeterminateResult()
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:
public void setId(String id)
paymentTransactionId
- The id of this payment transaction.public void setType(String type)
amount
- The type of this transactionpublic void setManagementState(String managementState)
managementState
- The state of this transactionTransactionManagementState
public void setStatus(String status)
status
- The status of the transactionTransactionStatus
public void setTransactionReferenceId(String transactionReferenceId)
transactionReferenceId
- The transaction id known by the payment gatewaypublic void setRequestId(String requestId)
requestId
- The id used to represent the request that produced this transactionpublic void setAmount(javax.money.MonetaryAmount amount)
type
, this may be the
amount authorized, captured, refunded, etc.amount
- The amount related to this transactionpublic void setDateRecorded(Instant dateRecorded)
dateRecorded
- The timestamp when this transaction response was recordedpublic void setGatewayResponseCode(String gatewayResponseCode)
gatewayResponseCode
- The response code provided by the payment gateway which may
represent a success or failurepublic void setFailureType(String failureType)
failureType
- The type of transaction failurepublic void setDeclineType(String declineType)
failureType
- The type of transaction failure (hard vs soft failure)public void setRawResponse(String rawResponse)
rawResponse
- The string representation of the serialized response from the gatewaypublic void setParentTransactionId(String parentTransactionId)
PaymentTransaction
.
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:
parentTransactionId
- The id of the parent PaymentTransaction.public void setAttributes(Map<String,String> attributes)
attributes
- Map of specific fields that have been gathered from the raw responsePaymentTransactionAdditionalFieldType
public void setCustomerIpAddress(String customerIpAddress)
customerIpAddress
- The customer IP address that instigated this transactionpublic void setIndeterminateResult(boolean indeterminateResult)
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:
protected boolean canEqual(Object other)
Copyright © 2021. All rights reserved.