public class DefaultPaymentTransactionService extends Object implements PaymentTransactionService
Constructor and Description |
---|
DefaultPaymentTransactionService(CartProvider cartProvider,
com.broadleafcommerce.common.extension.TypeFactory typeFactory) |
Modifier and Type | Method and Description |
---|---|
org.apache.commons.lang3.tuple.Triple<com.broadleafcommerce.cart.client.domain.Cart,com.broadleafcommerce.order.common.domain.Payment,com.broadleafcommerce.order.common.domain.PaymentTransaction> |
createPaymentTransaction(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
@NonNull com.broadleafcommerce.order.common.domain.Payment payment,
@NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType,
@NonNull javax.money.MonetaryAmount amount,
@NonNull String requestId,
com.broadleafcommerce.order.common.domain.PaymentTransaction parentTransaction,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Creates a pending
PaymentTransaction & saves it to the provided cart payment. |
protected String |
determineTransactionStatus(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response)
Determines the new status of the
PaymentTransaction based on the contents of the
PaymentResponse |
protected CartProvider |
getCartProvider() |
protected com.broadleafcommerce.common.extension.TypeFactory |
getTypeFactory() |
protected boolean |
isIndeterminateResult(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response)
Determines whether or not the payment response represents an indeterminate result.
|
com.broadleafcommerce.cart.client.domain.Cart |
recordTransactionResponse(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
@NonNull com.broadleafcommerce.order.common.domain.Payment payment,
@NonNull com.broadleafcommerce.order.common.domain.PaymentTransaction transaction,
@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Interprets the payment gateway's
PaymentResponse & records the results on the given
Payment & PaymentTransaction . |
protected boolean |
shouldArchivePaymentDueToFailedTransaction(@NonNull com.broadleafcommerce.order.common.domain.Payment payment,
@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response)
Determines whether or not the
Payment should be archived due to the failed
transaction that is described by the provided PaymentResponse . |
protected com.broadleafcommerce.order.common.domain.Payment |
updatePaymentForAuthAndCaptureTransaction(@NonNull com.broadleafcommerce.order.common.domain.Payment payment,
@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response,
@NonNull String requestId)
Based on the results of the payment gateway authorize and capture transaction, update the
payment.
|
protected com.broadleafcommerce.order.common.domain.Payment |
updatePaymentForAuthTransaction(@NonNull com.broadleafcommerce.order.common.domain.Payment payment,
@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response,
@NonNull String requestId)
Based on the results of the payment gateway authorize transaction, update the payment.
|
protected void |
validateTransactionAmount(@NonNull com.broadleafcommerce.order.common.domain.Payment payment,
@NonNull javax.money.MonetaryAmount transactionAmount)
Validate that the transaction amount is not greater than the payment amount
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createPaymentTransaction, createPaymentTransaction
public DefaultPaymentTransactionService(CartProvider cartProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
public org.apache.commons.lang3.tuple.Triple<com.broadleafcommerce.cart.client.domain.Cart,com.broadleafcommerce.order.common.domain.Payment,com.broadleafcommerce.order.common.domain.PaymentTransaction> createPaymentTransaction(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.order.common.domain.Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType, @NonNull @NonNull javax.money.MonetaryAmount amount, @NonNull @NonNull String requestId, @Nullable com.broadleafcommerce.order.common.domain.PaymentTransaction parentTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
PaymentTransactionService
PaymentTransaction
& saves it to the provided cart payment. This
transaction is meant to record our intention to send a request to the payment gateway & it
creates a PaymentTransaction.getTransactionReferenceId()
which would also be passed
to the gateway so that they two can be linked.createPaymentTransaction
in interface PaymentTransactionService
cart
- the owning cartpayment
- The payment that should own this transactiontransactionType
- The type of transaction that should be createdamount
- The monetary amount related to this transactionrequestId
- the id representing the customer's request to confirm their paymentsparentTransaction
- A related transaction that this created transaction should link tocontextInfo
- Context information around sandbox and multitenant state.public com.broadleafcommerce.cart.client.domain.Cart recordTransactionResponse(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.order.common.domain.Payment payment, @NonNull @NonNull com.broadleafcommerce.order.common.domain.PaymentTransaction transaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
PaymentTransactionService
PaymentResponse
& records the results on the given
Payment
& PaymentTransaction
.
Note: if the transaction failed, then the payment should also be archived so that it can no
longer contribute to a successful checkoutrecordTransactionResponse
in interface PaymentTransactionService
cart
- the owning cartpayment
- the payment that we intended to authorizetransaction
- the transaction that is to hold the results of the transactionresponse
- the payment gateway's response to our authorization attemptcontextInfo
- Context information around sandbox and multitenant state.protected void validateTransactionAmount(@NonNull @NonNull com.broadleafcommerce.order.common.domain.Payment payment, @NonNull @NonNull javax.money.MonetaryAmount transactionAmount)
payment
- The transaction's related paymenttransactionAmount
- The transaction amountprotected String determineTransactionStatus(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response)
PaymentTransaction
based on the contents of the
PaymentResponse
response
- the payment gateway's response to the executed transactionPaymentTransaction
based on the contents of the
PaymentResponse
protected com.broadleafcommerce.order.common.domain.Payment updatePaymentForAuthTransaction(@NonNull @NonNull com.broadleafcommerce.order.common.domain.Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @NonNull @NonNull String requestId)
payment
- the payment that is to be updated based on the authorizeresponse
- the payment gateway's response to the authorize transactionrequestId
- the id used to identify changes tied to the specific execution requestprotected com.broadleafcommerce.order.common.domain.Payment updatePaymentForAuthAndCaptureTransaction(@NonNull @NonNull com.broadleafcommerce.order.common.domain.Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response, @NonNull @NonNull String requestId)
payment
- the payment that is to be updated based on the authorizeresponse
- the payment gateway's response to the authorize transactionrequestId
- the id used to identify changes tied to the specific execution requestprotected boolean shouldArchivePaymentDueToFailedTransaction(@NonNull @NonNull com.broadleafcommerce.order.common.domain.Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response)
Payment
should be archived due to the failed
transaction that is described by the provided PaymentResponse
.
Note: Archiving the payment declares that it can no longer contribute to a successful
checkout.payment
- the payment that may be archived based on the results of this methodresponse
- the result of the executed transactionprotected boolean isIndeterminateResult(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse response)
For example, if a network error occurred, it we won't know if the transaction was completed or not on the gateway side of things.
response
- the payment gateway's response to the executed transactionprotected CartProvider getCartProvider()
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
Copyright © 2021. All rights reserved.