Class ValidateAndConfirmPaymentActivity

java.lang.Object
org.broadleafcommerce.core.workflow.BaseActivity<ProcessContext<CheckoutSeed>>
org.broadleafcommerce.core.checkout.service.workflow.ValidateAndConfirmPaymentActivity
All Implemented Interfaces:
Activity<ProcessContext<CheckoutSeed>>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.core.Ordered

@Component("blValidateAndConfirmPaymentActivity") public class ValidateAndConfirmPaymentActivity extends BaseActivity<ProcessContext<CheckoutSeed>>

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.AUTHORIZE and PaymentTransactionType.AUTHORIZE_AND_CAPTURE and PaymentTransactionType.PENDING transactions.
  • "Confirm" any PaymentTransactionType.UNCONFIRMED transactions that exist on an OrderPayment. This can mean different things depending on the type of Order Payment and is handled by the OrderPaymentConfirmationStrategy
  • 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)
  • Field Details

    • ORDER

      public static final int ORDER
      See Also:
    • ROLLBACK_TRANSACTIONS

      public static final String ROLLBACK_TRANSACTIONS

      Used by the ConfirmPaymentsRollbackHandler to roll back transactions that this activity confirms.

      This could also contain failed transactions that still need to be rolled back

      See Also:
    • FAILED_RESPONSES

      public static final String 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

      protected OrderToPaymentRequestDTOService orderToPaymentRequestService
    • orderPaymentService

      protected OrderPaymentService orderPaymentService
    • paymentGatewayCheckoutService

      protected org.broadleafcommerce.common.payment.service.PaymentGatewayCheckoutService paymentGatewayCheckoutService
    • orderPaymentConfirmationStrategy

      protected OrderPaymentConfirmationStrategy orderPaymentConfirmationStrategy
    • orderPaymentStatusService

      protected OrderPaymentStatusService orderPaymentStatusService
  • Constructor Details

    • ValidateAndConfirmPaymentActivity

      @Autowired public ValidateAndConfirmPaymentActivity(@Qualifier("blConfirmPaymentsRollbackHandler") ConfirmPaymentsRollbackHandler rollbackHandler)
  • Method Details

    • execute

      Description copied from interface: Activity
      Called 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)