Class PaymentReversalFulfillmentCancelledListener

    • Constructor Detail

      • PaymentReversalFulfillmentCancelledListener

        public PaymentReversalFulfillmentCancelledListener​(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentMessageService,
                                                           PaymentProvider paymentProvider,
                                                           PaymentRefundService paymentRefundService,
                                                           PaymentAuthReversalService paymentAuthReversalService,
                                                           OrderProvider<com.broadleafcommerce.order.client.domain.Order> orderProvider,
                                                           FulfillmentProvider<com.broadleafcommerce.order.client.domain.OrderFulfillment> fulfillmentProvider,
                                                           ResourceLockProvider resourceLockProvider)
    • Method Detail

      • refundPaymentForFulfillmentIfNeeded

        protected boolean refundPaymentForFulfillmentIfNeeded​(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment,
                                                              com.broadleafcommerce.order.client.domain.Order order,
                                                              String previousFulfillmentStatus,
                                                              @Nullable
                                                              com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Possibly performs a refund to cancel the fulfillment's payment. If the fulfillment has been captured, then it should be refunded.
        Parameters:
        fulfillment - the cancelled fulfillment for which to cancel payment
        order - the order containing the fulfillment
        previousFulfillmentStatus - the original status of the fulfillment before cancelled
        contextInfo - context information surrounding sandboxing and multitenant state
        Returns:
        true if the fulfillment was refunded, else false
      • getRefundableAmountOnFulfillment

        protected javax.money.MonetaryAmount getRefundableAmountOnFulfillment​(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment,
                                                                              com.broadleafcommerce.order.client.domain.Order order,
                                                                              String previousFulfillmentStatus,
                                                                              @Nullable
                                                                              com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Determine the amount that can be refunded on the fulfillment.

        Only fully successful fulfillment capture will be considered refundable. A fulfillment for which payment capture partially failed will not be considered refundable here.

        The fulfillment can only be refunded through cancelling prior to starting OrderFulfillmentStatus.FULFILLING the fulfillment.

        Parameters:
        fulfillment - the fulfillment which was cancelled
        order - the order containing the fulfillment
        previousFulfillmentStatus - the original status of the fulfillment before cancelled
        Returns:
        the amount which has been successfully captured on this fulfillment
      • hasFulfillmentBeenFullyCaptured

        protected boolean hasFulfillmentBeenFullyCaptured​(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment,
                                                          com.broadleafcommerce.order.client.domain.Order order,
                                                          @Nullable
                                                          com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Determines if the given OrderFulfillment has been fully captured.
        Parameters:
        fulfillment - the OrderFulfillment to check against
        order - the Order that the OrderFulfillment belongs to
        contextInfo - context information around sandbox and multitenant state
        Returns:
        whether the OrderFulfillment has been fully captured