Class DefaultSavedPaymentMethodManagementService

java.lang.Object
com.broadleafcommerce.paymenttransaction.service.DefaultSavedPaymentMethodManagementService
All Implemented Interfaces:
SavedPaymentMethodManagementService

public class DefaultSavedPaymentMethodManagementService extends Object implements SavedPaymentMethodManagementService
Author:
Sunny Yu
  • Constructor Details

    • DefaultSavedPaymentMethodManagementService

      public DefaultSavedPaymentMethodManagementService(com.broadleafcommerce.common.extension.TypeFactory typeFactory, SavedPaymentMethodService<SavedPaymentMethod> savedPaymentMethodService)
  • Method Details

    • createSavedPaymentMethodForFutureUse

      public void createSavedPaymentMethodForFutureUse(@NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SavedPaymentMethodManagementService
      Creates a saved payment method for future use from the given Payment and PaymentResponse.
      Specified by:
      createSavedPaymentMethodForFutureUse in interface SavedPaymentMethodManagementService
      Parameters:
      payment - the payment that should be saved
      paymentResponse - the PaymentResponse from the transaction execution if there's any
      contextInfo - context information related to multitenancy
    • updateSavedPaymentMethodBasedOnPaymentResponse

      public void updateSavedPaymentMethodBasedOnPaymentResponse(@NonNull @NonNull String savedPaymentMethodId, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SavedPaymentMethodManagementService
      Updates the saved payment method from the given PaymentResponse.

      This is typically used to update the last transaction date and response on a saved payment method after executing a transaction.

      Specified by:
      updateSavedPaymentMethodBasedOnPaymentResponse in interface SavedPaymentMethodManagementService
      Parameters:
      savedPaymentMethodId - the id of the saved payment method to update
      paymentResponse - the PaymentResponse from the transaction execution
      contextInfo - context information related to multitenancy
    • populatePaymentFromSavedPaymentMethod

      public Payment populatePaymentFromSavedPaymentMethod(@NonNull @NonNull Payment payment, @NonNull @NonNull String savedPaymentMethodId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SavedPaymentMethodManagementService
      Populates the given Payment with the saved payment method specified in Payment.getSavedPaymentMethodId().
      Specified by:
      populatePaymentFromSavedPaymentMethod in interface SavedPaymentMethodManagementService
      Parameters:
      payment - the Payment to populate for
      savedPaymentMethodId - the saved payment method id to retrieve the saved payment method from
      contextInfo - context information surrounding multitenant state
      Returns:
      the Payment populated with the saved payment method
    • getSavedPaymentMethodOwnership

      public OwnershipSummary getSavedPaymentMethodOwnership(@NonNull @NonNull String savedPaymentMethodId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SavedPaymentMethodManagementService
      Gets an OwnershipSummary of the saved payment method.
      Specified by:
      getSavedPaymentMethodOwnership in interface SavedPaymentMethodManagementService
      Parameters:
      savedPaymentMethodId - the saved payment method id to retrieve the saved payment method from
      contextInfo - context information surrounding multitenant state
      Returns:
      an OwnershipSummary describing the ownership details of the saved payment method
    • buildOwnershipSummary

      protected OwnershipSummary buildOwnershipSummary(@NonNull @NonNull SavedPaymentMethod savedPaymentMethod)
      Builds the OwnershipSummary based on the given SavedPaymentMethod.
      Parameters:
      savedPaymentMethod - the SavedPaymentMethod to build the OwnershipSummary for
      Returns:
      the OwnershipSummary based on the given SavedPaymentMethod
    • buildSavedPaymentMethod

      protected SavedPaymentMethod buildSavedPaymentMethod(@NonNull @NonNull Payment payment)
      Builds a SavedPaymentMethod from the given Payment, to be later populated using a PaymentResponse. Note: The SavedPaymentMethod.paymentMethodProperties are intentionally not populated using the Payment.getPaymentMethodProperties(). Instead, we expect all of these values to come from the PaymentResponse
      Parameters:
      payment - the Payment to build the SavedPaymentMethod from
      Returns:
      a SavedPaymentMethod from the given Payment
    • getLastSuccessfulTransactionDate

      @Nullable protected Instant getLastSuccessfulTransactionDate(@NonNull @NonNull Payment payment)
      Gets the last successful transaction date from the given Payment.
      Parameters:
      payment - the Payment to get the last successful transaction date from
      Returns:
      the last successful transaction date of the given Payment, null if the Payment doesn't have any successful transactions
    • getLastSuccessfulTransactionGatewayResponseCode

      @Nullable protected String getLastSuccessfulTransactionGatewayResponseCode(@NonNull @NonNull Payment payment)
      Gets the last successful transaction gateway response code from the given Payment.
      Parameters:
      payment - the Payment to get the last successful transaction gateway response code from
      Returns:
      the last successful transaction gateway response code of the given Payment, null if the Payment doesn't have any successful transactions
    • getLatestSuccessfulTransaction

      @Nullable protected PaymentTransaction getLatestSuccessfulTransaction(@NonNull @NonNull Payment payment)
      Gets the latest successful PaymentTransaction from the given Payment.
      Parameters:
      payment - the Payment to get the latest successful PaymentTransaction from
      Returns:
      the latest successful PaymentTransaction from the given Payment
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getSavedPaymentMethodService

      protected SavedPaymentMethodService<SavedPaymentMethod> getSavedPaymentMethodService()
    • getSavedPaymentMethodAccessValidationService

      protected SavedPaymentMethodAccessValidationService getSavedPaymentMethodAccessValidationService()
      Lazy injected SavedPaymentMethodAccessValidationService since this service is itself a service component.

      This avoids circular dependency exceptions

    • setSavedPaymentMethodAccessValidationService

      @Autowired @Lazy public void setSavedPaymentMethodAccessValidationService(SavedPaymentMethodAccessValidationService savedPaymentMethodAccessValidationService)
      Lazy injected SavedPaymentMethodAccessValidationService since this service is itself a service component.

      This avoids circular dependency exceptions