Class DefaultSavedPaymentMethodManagementService
java.lang.Object
com.broadleafcommerce.paymenttransaction.service.DefaultSavedPaymentMethodManagementService
- All Implemented Interfaces:
SavedPaymentMethodManagementService
public class DefaultSavedPaymentMethodManagementService
extends Object
implements SavedPaymentMethodManagementService
The default implementation of
SavedPaymentMethodManagementService, driven by
SavedPaymentMethod and SavedPaymentMethodService.- Author:
- Sunny Yu
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSavedPaymentMethodManagementService(com.broadleafcommerce.common.extension.TypeFactory typeFactory, SavedPaymentMethodService<SavedPaymentMethod> savedPaymentMethodService) -
Method Summary
Modifier and TypeMethodDescriptionprotected OwnershipSummarybuildOwnershipSummary(@NonNull SavedPaymentMethod savedPaymentMethod) Builds theOwnershipSummarybased on the givenSavedPaymentMethod.protected SavedPaymentMethodbuildSavedPaymentMethod(@NonNull Payment payment) voidcreateSavedPaymentMethodForFutureUse(@NonNull Payment payment, com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates a saved payment method for future use from the givenPaymentandPaymentResponse.protected InstantgetLastSuccessfulTransactionDate(@NonNull Payment payment) Gets the last successful transaction date from the givenPayment.protected StringgetLastSuccessfulTransactionGatewayResponseCode(@NonNull Payment payment) Gets the last successful transaction gateway response code from the givenPayment.protected PaymentTransactiongetLatestSuccessfulTransaction(@NonNull Payment payment) Gets the latest successfulPaymentTransactionfrom the givenPayment.Lazy injectedSavedPaymentMethodAccessValidationServicesince this service is itself a service component.getSavedPaymentMethodOwnership(@NonNull String savedPaymentMethodId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets anOwnershipSummaryof the saved payment method.protected SavedPaymentMethodService<SavedPaymentMethod>protected com.broadleafcommerce.common.extension.TypeFactorypopulatePaymentFromSavedPaymentMethod(@NonNull Payment payment, @NonNull String savedPaymentMethodId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the givenPaymentwith the saved payment method specified inPayment.getSavedPaymentMethodId().voidsetSavedPaymentMethodAccessValidationService(SavedPaymentMethodAccessValidationService savedPaymentMethodAccessValidationService) Lazy injectedSavedPaymentMethodAccessValidationServicesince this service is itself a service component.voidupdateSavedPaymentMethodBasedOnPaymentResponse(@NonNull String savedPaymentMethodId, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the saved payment method from the givenPaymentResponse.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.paymenttransaction.service.SavedPaymentMethodManagementService
createSavedPaymentMethodForFutureUse
-
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:SavedPaymentMethodManagementServiceCreates a saved payment method for future use from the givenPaymentandPaymentResponse.- Specified by:
createSavedPaymentMethodForFutureUsein interfaceSavedPaymentMethodManagementService- Parameters:
payment- the payment that should be savedpaymentResponse- thePaymentResponsefrom the transaction execution if there's anycontextInfo- 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:SavedPaymentMethodManagementServiceUpdates the saved payment method from the givenPaymentResponse.This is typically used to update the last transaction date and response on a saved payment method after executing a transaction.
- Specified by:
updateSavedPaymentMethodBasedOnPaymentResponsein interfaceSavedPaymentMethodManagementService- Parameters:
savedPaymentMethodId- the id of the saved payment method to updatepaymentResponse- thePaymentResponsefrom the transaction executioncontextInfo- 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:SavedPaymentMethodManagementServicePopulates the givenPaymentwith the saved payment method specified inPayment.getSavedPaymentMethodId().- Specified by:
populatePaymentFromSavedPaymentMethodin interfaceSavedPaymentMethodManagementService- Parameters:
payment- thePaymentto populate forsavedPaymentMethodId- the saved payment method id to retrieve the saved payment method fromcontextInfo- context information surrounding multitenant state- Returns:
- the
Paymentpopulated 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:SavedPaymentMethodManagementServiceGets anOwnershipSummaryof the saved payment method.- Specified by:
getSavedPaymentMethodOwnershipin interfaceSavedPaymentMethodManagementService- Parameters:
savedPaymentMethodId- the saved payment method id to retrieve the saved payment method fromcontextInfo- context information surrounding multitenant state- Returns:
- an
OwnershipSummarydescribing the ownership details of the saved payment method
-
buildOwnershipSummary
protected OwnershipSummary buildOwnershipSummary(@NonNull @NonNull SavedPaymentMethod savedPaymentMethod) Builds theOwnershipSummarybased on the givenSavedPaymentMethod.- Parameters:
savedPaymentMethod- theSavedPaymentMethodto build theOwnershipSummaryfor- Returns:
- the
OwnershipSummarybased on the givenSavedPaymentMethod
-
buildSavedPaymentMethod
Builds aSavedPaymentMethodfrom the givenPayment, to be later populated using aPaymentResponse. Note: TheSavedPaymentMethod.paymentMethodPropertiesare intentionally not populated using thePayment.getPaymentMethodProperties(). Instead, we expect all of these values to come from thePaymentResponse- Parameters:
payment- thePaymentto build theSavedPaymentMethodfrom- Returns:
- a
SavedPaymentMethodfrom the givenPayment
-
getLastSuccessfulTransactionDate
Gets the last successful transaction date from the givenPayment. -
getLastSuccessfulTransactionGatewayResponseCode
@Nullable protected String getLastSuccessfulTransactionGatewayResponseCode(@NonNull @NonNull Payment payment) Gets the last successful transaction gateway response code from the givenPayment. -
getLatestSuccessfulTransaction
@Nullable protected PaymentTransaction getLatestSuccessfulTransaction(@NonNull @NonNull Payment payment) Gets the latest successfulPaymentTransactionfrom the givenPayment.- Parameters:
payment- thePaymentto get the latest successfulPaymentTransactionfrom- Returns:
- the latest successful
PaymentTransactionfrom the givenPayment
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getSavedPaymentMethodService
-
getSavedPaymentMethodAccessValidationService
Lazy injectedSavedPaymentMethodAccessValidationServicesince this service is itself a service component.This avoids circular dependency exceptions
-
setSavedPaymentMethodAccessValidationService
@Autowired @Lazy public void setSavedPaymentMethodAccessValidationService(SavedPaymentMethodAccessValidationService savedPaymentMethodAccessValidationService) Lazy injectedSavedPaymentMethodAccessValidationServicesince this service is itself a service component.This avoids circular dependency exceptions
-