Class PaymentResponse
- java.lang.Object
-
- com.broadleafcommerce.paymentgateway.domain.PaymentResponse
-
- All Implemented Interfaces:
Serializable
public class PaymentResponse extends Object implements Serializable
The DTO object that represents the response coming back from any call to the Gateway. This can either wrap an API result call or a translated HTTP Web response. This can not only be the results of a transaction, but also a request for a Secure Token etc...
Note: the success and validity flags are set to true by default, unless otherwise overridden by specific gateway implementations
- Author:
- Elbert Bautista (elbertbautista)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PaymentResponse()PaymentResponse(PaymentType paymentType, PaymentGatewayType gatewayType)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PaymentResponseamount(javax.money.MonetaryAmount amount)PaymentResponseawaitingAsyncResults(boolean awaitingAsyncResults)Address<PaymentResponse>billTo()PaymentResponsecompleteCheckoutOnCallback(boolean completeCheckoutOnCallback)CreditCard<PaymentResponse>creditCard()GatewayCustomer<PaymentResponse>customer()PaymentResponsecustomer(GatewayCustomer<PaymentResponse> customer)CustomerCredit<PaymentResponse>customerCredit()PaymentResponsedateRecorded(Instant dateRecorded)PaymentResponsedeclineType(String declineType)PaymentResponsefailureType(String failureType)PaymentResponsegatewayResponseCode(String gatewayResponseCode)PaymentResponsegatewayTransactionId(String gatewayTransactionId)PaymentResponsegatewayTransactionType(String gatewayTransactionType)javax.money.MonetaryAmountgetAmount()Address<PaymentResponse>getBillTo()The billing address associated with this transactionCreditCard<PaymentResponse>getCreditCard()for sale/authorize transactions, this will be the Credit Card object that was charged.GatewayCustomer<PaymentResponse>getCustomer()Any customer information that relates to this transactionList<CustomerCredit<PaymentResponse>>getCustomerCredits()Any customer credit accounts that have been processed.InstantgetDateRecorded()The timestamp when this transaction response was recordedStringgetDeclineType()The type of transaction decline (hard vs soft decline)StringgetFailureType()The type of transaction failure (TransactionFailureType).StringgetGatewayResponseCode()The response code provided by the payment gateway which may represent a success or failureStringgetGatewayTransactionId()The transaction id that is returned by the payment gateway.StringgetGatewayTransactionType()The executed transaction type, as described by the gateway.List<GiftCard<PaymentResponse>>getGiftCards()Any gift cards that have been processed.StringgetMessage()Message describing the result of the transactionStringgetOrderId()Deprecated.In favor ofpaymentOwnerTypeandpaymentOwnerId.PaymentGatewayTypegetPaymentGatewayType()The Payment Gateway Type that this transaction response representsStringgetPaymentId()The Payment ID that this transaction is associated withMap<String,String>getPaymentMethodProperties()Map to capture any information about the payment method needed to perform gateway transactions.StringgetPaymentOwnerDescription()A description of the payment owner associated with this transactionStringgetPaymentOwnerId()The id of the entity that owns the payment.StringgetPaymentOwnerType()Describes the owner of the payment.StringgetPaymentToken()Deprecated.in favor ofgetPaymentMethodProperties()PaymentTypegetPaymentType()The Type of Payment that this transaction response representsStringgetRawResponse()A string representation of the response that came from the gateway.Map<String,String>getResponseMap()A more convenient representation ofrawResponseto hold the response from the gateway.Address<PaymentResponse>getShipTo()If shipping information is captured on the gateway, the values sent back will be put hereStringgetThreeDSecureVerificationUrl()The gateway-provided url where the customer must verify that they are in fact the owner of the payment method.StringgetTransactionReferenceId()The transaction reference that is passed to the payment gateway.TransactionTypegetTransactionType()The Transaction Type of the Payment that this response representsGiftCard<PaymentResponse>giftCard()booleanisAwaitingAsyncResults()Declares whether the transaction was executed synchronously, or if the transaction results will be provided asynchronously.booleanisCompleteCheckoutOnCallback()Sets whether or not this module should complete checkout on callback.booleanisSuccessful()Whether or not the transaction on the gateway was successful.booleanisValid()Whether or not this response was tampered with.PaymentResponsemessage(String message)PaymentResponseorderId(String orderId)Deprecated.In favor ofpaymentOwnerTypeandpaymentOwnerId.PaymentResponsepaymentGatewayType(PaymentGatewayType paymentGatewayType)PaymentResponsepaymentId(String paymentId)PaymentResponsepaymentMethodProperties(Map<String,String> paymentMethodProperties)PaymentResponsepaymentOwnerId(String ownerId)PaymentResponsepaymentOwnerType(String ownerType)PaymentResponsepaymentToken(String paymentToken)Deprecated.in favor ofpaymentMethodProperties(Map)PaymentResponsepaymentType(PaymentType paymentType)PaymentResponserawResponse(String rawResponse)PaymentResponseresponseMap(String key, String value)Address<PaymentResponse>shipTo()PaymentResponsesuccessful(boolean successful)PaymentResponsethreeDSecureVerificationUrl(String threeDSecureVerificationUrl)PaymentResponsetransactionReferenceId(String transactionReferenceId)PaymentResponsetransactionType(TransactionType transactionType)PaymentResponsevalid(boolean valid)
-
-
-
Constructor Detail
-
PaymentResponse
public PaymentResponse(PaymentType paymentType, PaymentGatewayType gatewayType)
-
PaymentResponse
public PaymentResponse()
-
-
Method Detail
-
customer
public PaymentResponse customer(GatewayCustomer<PaymentResponse> customer)
-
customer
public GatewayCustomer<PaymentResponse> customer()
-
creditCard
public CreditCard<PaymentResponse> creditCard()
-
shipTo
public Address<PaymentResponse> shipTo()
-
billTo
public Address<PaymentResponse> billTo()
-
giftCard
public GiftCard<PaymentResponse> giftCard()
-
customerCredit
public CustomerCredit<PaymentResponse> customerCredit()
-
responseMap
public PaymentResponse responseMap(String key, String value)
-
paymentOwnerType
public PaymentResponse paymentOwnerType(String ownerType)
-
paymentOwnerId
public PaymentResponse paymentOwnerId(String ownerId)
-
orderId
@Deprecated public PaymentResponse orderId(String orderId)
Deprecated.In favor ofpaymentOwnerTypeandpaymentOwnerId.Sets the Order ID that this transaction is associated with.- Returns:
- the
PaymentResponse
-
getOrderId
@Deprecated public String getOrderId()
Deprecated.In favor ofpaymentOwnerTypeandpaymentOwnerId.Gets the Order ID that this transaction is associated with.- Returns:
- the Order ID that this transaction is associated with.
-
paymentId
public PaymentResponse paymentId(String paymentId)
-
amount
public PaymentResponse amount(javax.money.MonetaryAmount amount)
-
paymentToken
@Deprecated public PaymentResponse paymentToken(String paymentToken)
Deprecated.in favor ofpaymentMethodProperties(Map)Sets the payment transaction that was created during the associated transaction.- Returns:
- the
PaymentResponse
-
getPaymentToken
@Deprecated public String getPaymentToken()
Deprecated.in favor ofgetPaymentMethodProperties()Gets the payment transaction that was created during the associated transaction.- Returns:
- the payment transaction that was created during the associated transaction.
-
paymentMethodProperties
public PaymentResponse paymentMethodProperties(Map<String,String> paymentMethodProperties)
-
transactionReferenceId
public PaymentResponse transactionReferenceId(String transactionReferenceId)
-
gatewayTransactionId
public PaymentResponse gatewayTransactionId(String gatewayTransactionId)
-
gatewayResponseCode
public PaymentResponse gatewayResponseCode(String gatewayResponseCode)
-
message
public PaymentResponse message(String message)
-
threeDSecureVerificationUrl
public PaymentResponse threeDSecureVerificationUrl(String threeDSecureVerificationUrl)
-
failureType
public PaymentResponse failureType(String failureType)
-
declineType
public PaymentResponse declineType(String declineType)
-
dateRecorded
public PaymentResponse dateRecorded(Instant dateRecorded)
-
paymentGatewayType
public PaymentResponse paymentGatewayType(PaymentGatewayType paymentGatewayType)
-
paymentType
public PaymentResponse paymentType(PaymentType paymentType)
-
transactionType
public PaymentResponse transactionType(TransactionType transactionType)
-
gatewayTransactionType
public PaymentResponse gatewayTransactionType(String gatewayTransactionType)
-
awaitingAsyncResults
public PaymentResponse awaitingAsyncResults(boolean awaitingAsyncResults)
-
successful
public PaymentResponse successful(boolean successful)
-
completeCheckoutOnCallback
public PaymentResponse completeCheckoutOnCallback(boolean completeCheckoutOnCallback)
-
valid
public PaymentResponse valid(boolean valid)
-
rawResponse
public PaymentResponse rawResponse(String rawResponse)
-
getCustomer
public GatewayCustomer<PaymentResponse> getCustomer()
Any customer information that relates to this transaction
-
getShipTo
public Address<PaymentResponse> getShipTo()
If shipping information is captured on the gateway, the values sent back will be put here
-
getBillTo
public Address<PaymentResponse> getBillTo()
The billing address associated with this transaction
-
getCreditCard
public CreditCard<PaymentResponse> getCreditCard()
for sale/authorize transactions, this will be the Credit Card object that was charged. This data is useful for showing on an order confirmation screen.
-
getGiftCards
public List<GiftCard<PaymentResponse>> getGiftCards()
Any gift cards that have been processed. This data is useful for showing on an order confirmation screen
-
getCustomerCredits
public List<CustomerCredit<PaymentResponse>> getCustomerCredits()
Any customer credit accounts that have been processed. This data is useful for showing on an order confirmation screen
-
getPaymentGatewayType
public PaymentGatewayType getPaymentGatewayType()
The Payment Gateway Type that this transaction response represents
-
getPaymentType
public PaymentType getPaymentType()
The Type of Payment that this transaction response represents
-
getTransactionType
public TransactionType getTransactionType()
The Transaction Type of the Payment that this response represents
-
getGatewayTransactionType
public String getGatewayTransactionType()
The executed transaction type, as described by the gateway. For example, thetransactionTypemay beDefaultTransactionTypes.REFUND, while the gateway transaction is called a "VOID" in their system.
-
getTransactionReferenceId
public String getTransactionReferenceId()
The transaction reference that is passed to 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 reference that is passed to the payment gateway.
-
getGatewayTransactionId
public String getGatewayTransactionId()
The transaction id that is returned by the payment gateway.- Returns:
- The transaction id that is returned by the payment gateway
-
getPaymentOwnerType
public String getPaymentOwnerType()
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.
-
getPaymentOwnerId
public String getPaymentOwnerId()
The id of the entity that owns the payment. For example, this may be a cart id, or a subscription billing cycle id.- Returns:
- The id of the entity that owns the payment.
-
getPaymentOwnerDescription
public String getPaymentOwnerDescription()
A description of the payment owner associated with this transaction- Returns:
- A description of the payment owner associated with this transaction.
-
getPaymentId
public String getPaymentId()
The Payment ID that this transaction is associated with
-
getAmount
public javax.money.MonetaryAmount getAmount()
-
isSuccessful
public boolean isSuccessful()
Whether or not the transaction on the gateway was successful. This should be provided by the gateway alone.
-
isValid
public boolean isValid()
Whether or not this response was tampered with. This used to verify that the response that was received on the endpoint (which is intended to only be invoked from the payment gateway) actually came from the gateway and was not otherwise maliciously invoked by a 3rd-party.
-
isAwaitingAsyncResults
public boolean isAwaitingAsyncResults()
Declares whether the transaction was executed synchronously, or if the transaction results will be provided asynchronously.In the case of an
DefaultTransactionTypes.AUTHORIZE_AND_CAPTUREtransaction, the authorize transaction may be executed synchronously, but the capture transaction's results will be communicated asynchronously. In that case, a successfulDefaultTransactionTypes.AUTHORIZE_AND_CAPTUREtransaction's PaymentResponse should includesuccessful= true and awaitingAsyncResults = true. If theDefaultTransactionTypes.AUTHORIZE_AND_CAPTUREtransaction is not successful, then the PaymentResponse should includesuccessful= false and awaitingAsyncResults = false.
-
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
-
getMessage
public String getMessage()
Message describing the result of the transaction- Returns:
- Message describing the result of the transaction
-
getPaymentMethodProperties
public Map<String,String> getPaymentMethodProperties()
Map to capture any information about the payment method needed to perform gateway transactions. This map should be empty unless a transaction also included the creation of a multi-use payment method.- Returns:
- Map to capture any information about the payment method needed to perform gateway transactions
-
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.
-
getFailureType
public String getFailureType()
The type of transaction failure (TransactionFailureType).- Returns:
- The type of transaction failure
-
getDeclineType
public String getDeclineType()
The type of transaction decline (hard vs soft decline)- Returns:
- The type of transaction decline (hard vs soft decline)
-
getDateRecorded
public Instant getDateRecorded()
The timestamp when this transaction response was recorded- Returns:
- The timestamp when this transaction response was recorded
-
isCompleteCheckoutOnCallback
public boolean isCompleteCheckoutOnCallback()
Sets whether or not this module should complete checkout on callback. In most Credit Card gateway implementation, this should be set to 'TRUE' and should not be configurable as the gateway expects it to tbe the final step in the checkout process.
In gateways where it does not expect to be the last step in the checkout process, for example BLC Gift Card Module, PayPal Express Checkout, etc... The callback from the gateway can be configured whether or not to complete checkout.
-
getRawResponse
public String getRawResponse()
A string representation of the response that came from the gateway. This should be a string serialization ofresponseMap.
-
getResponseMap
public Map<String,String> getResponseMap()
A more convenient representation ofrawResponseto hold the response from the gateway.
-
-