Class ValidateAndConfirmPaymentActivity
- All Implemented Interfaces:
Activity<ProcessContext<CheckoutSeed>>,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.core.Ordered
This activity is responsible for validating and processing several aspects of an order's payment so that it may successfully complete the checkout workflow. This activity will:
- Verify that there is enough payment on the order via the successful amount on
PaymentTransactionType.AUTHORIZEandPaymentTransactionType.AUTHORIZE_AND_CAPTUREandPaymentTransactionType.PENDINGtransactions. - "Confirm" any
PaymentTransactionType.UNCONFIRMEDtransactions that exist on anOrderPayment. This can mean different things depending on the type of Order Payment and is handled by theOrderPaymentConfirmationStrategy - If there is an exception (either in this activity or later downstream) the confirmed payments are rolled back via
ConfirmPaymentsRollbackHandler. It will also by default attempt to mark the payment as "ARCHIVED" so that the user may attempt to re-enter their payment details.
- Author:
- Phillip Verheyden (phillipuniverse), Elbert Bautista (elbertbautista)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected static final org.apache.commons.logging.Logstatic final intprotected OrderPaymentConfirmationStrategyprotected OrderPaymentServiceprotected OrderPaymentStatusServiceprotected OrderToPaymentRequestDTOServiceprotected org.broadleafcommerce.common.payment.service.PaymentGatewayConfigurationServiceProviderprotected org.broadleafcommerce.common.payment.service.PaymentGatewayCheckoutServicestatic final StringUsed by theConfirmPaymentsRollbackHandlerto roll back transactions that this activity confirms.Fields inherited from class org.broadleafcommerce.core.workflow.BaseActivity
automaticallyRegisterRollbackHandler, beanName, errorHandler, order, rollbackHandler, rollbackRegion, stateConfigurationFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionValidateAndConfirmPaymentActivity(ConfirmPaymentsRollbackHandler rollbackHandler) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.broadleafcommerce.profile.core.domain.CustomerPaymentcreateCustomerPaymentToken(PaymentTransaction transaction) execute(ProcessContext<CheckoutSeed> context) Called by the encompassing processor to activate the execution of the Activityprotected voidhandleUnsuccessfulTransactions(List<ValidateAndConfirmPaymentActivity.ResponseTransactionPair> failedTransactions, ProcessContext<CheckoutSeed> context) Default implementation is to throw a generic CheckoutException which will be caught and displayed on the Checkout Page where the Customer can try again.protected booleanshouldRollbackFailedTransaction(ValidateAndConfirmPaymentActivity.ResponseTransactionPair failedTransactionPair) Methods inherited from class org.broadleafcommerce.core.workflow.BaseActivity
getAutomaticallyRegisterRollbackHandler, getBeanName, getErrorHandler, getOrder, getRollbackHandler, getRollbackRegion, getStateConfiguration, setAutomaticallyRegisterRollbackHandler, setBeanName, setErrorHandler, setOrder, setRollbackHandler, setRollbackRegion, setStateConfiguration, shouldExecute
-
Field Details
-
ORDER
public static final int ORDER- See Also:
-
ROLLBACK_TRANSACTIONS
Used by the
ConfirmPaymentsRollbackHandlerto roll back transactions that this activity confirms.This could also contain failed transactions that still need to be rolled back
- See Also:
-
FAILED_RESPONSES
- See Also:
-
LOG
protected static final org.apache.commons.logging.Log LOG -
paymentConfigurationServiceProvider
@Autowired(required=false) @Qualifier("blPaymentGatewayConfigurationServiceProvider") protected org.broadleafcommerce.common.payment.service.PaymentGatewayConfigurationServiceProvider paymentConfigurationServiceProvider -
orderToPaymentRequestService
-
orderPaymentService
-
paymentGatewayCheckoutService
protected org.broadleafcommerce.common.payment.service.PaymentGatewayCheckoutService paymentGatewayCheckoutService -
orderPaymentConfirmationStrategy
-
orderPaymentStatusService
-
-
Constructor Details
-
ValidateAndConfirmPaymentActivity
@Autowired public ValidateAndConfirmPaymentActivity(@Qualifier("blConfirmPaymentsRollbackHandler") ConfirmPaymentsRollbackHandler rollbackHandler)
-
-
Method Details
-
execute
Description copied from interface:ActivityCalled by the encompassing processor to activate the execution of the Activity- Parameters:
context- - process context for this workflow- Returns:
- resulting process context
- Throws:
Exception
-
handleUnsuccessfulTransactions
protected void handleUnsuccessfulTransactions(List<ValidateAndConfirmPaymentActivity.ResponseTransactionPair> failedTransactions, ProcessContext<CheckoutSeed> context) throws Exception Default implementation is to throw a generic CheckoutException which will be caught and displayed on the Checkout Page where the Customer can try again. In many cases, this is sufficient as it is usually recommended to display a generic Error Message to prevent Credit Card fraud.
The configured payment gateway may return a more specific error. Each gateway is different and will often times return different error codes based on the acquiring bank as well. In that case, you may override this method to decipher these errors and handle it appropriately based on your business requirements.
- Throws:
Exception
-
shouldRollbackFailedTransaction
protected boolean shouldRollbackFailedTransaction(ValidateAndConfirmPaymentActivity.ResponseTransactionPair failedTransactionPair) -
createCustomerPaymentToken
protected org.broadleafcommerce.profile.core.domain.CustomerPayment createCustomerPaymentToken(PaymentTransaction transaction)
-