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
ConstructorDescriptionDefaultSavedPaymentMethodManagementService
(com.broadleafcommerce.common.extension.TypeFactory typeFactory, SavedPaymentMethodService<SavedPaymentMethod> savedPaymentMethodService) -
Method Summary
Modifier and TypeMethodDescriptionprotected OwnershipSummary
buildOwnershipSummary
(@NonNull SavedPaymentMethod savedPaymentMethod) Builds theOwnershipSummary
based on the givenSavedPaymentMethod
.protected SavedPaymentMethod
buildSavedPaymentMethod
(@NonNull Payment payment) void
createSavedPaymentMethodForFutureUse
(@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 givenPayment
andPaymentResponse
.protected Instant
getLastSuccessfulTransactionDate
(@NonNull Payment payment) Gets the last successful transaction date from the givenPayment
.protected String
getLastSuccessfulTransactionGatewayResponseCode
(@NonNull Payment payment) Gets the last successful transaction gateway response code from the givenPayment
.protected PaymentTransaction
getLatestSuccessfulTransaction
(@NonNull Payment payment) Gets the latest successfulPaymentTransaction
from the givenPayment
.Lazy injectedSavedPaymentMethodAccessValidationService
since this service is itself a service component.getSavedPaymentMethodOwnership
(@NonNull String savedPaymentMethodId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets anOwnershipSummary
of the saved payment method.protected SavedPaymentMethodService<SavedPaymentMethod>
protected com.broadleafcommerce.common.extension.TypeFactory
populatePaymentFromSavedPaymentMethod
(@NonNull Payment payment, @NonNull String savedPaymentMethodId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the givenPayment
with the saved payment method specified inPayment.getSavedPaymentMethodId()
.void
setSavedPaymentMethodAccessValidationService
(SavedPaymentMethodAccessValidationService savedPaymentMethodAccessValidationService) Lazy injectedSavedPaymentMethodAccessValidationService
since this service is itself a service component.void
updateSavedPaymentMethodBasedOnPaymentResponse
(@NonNull SavedPaymentMethod savedPaymentMethod, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the saved payment method from the givenPaymentResponse
.void
updateSavedPaymentMethodBasedOnPaymentResponse
(@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
.protected void
updateSavedPaymentMethodStatus
(@NonNull SavedPaymentMethod savedPaymentMethod, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Updates the status of the saved payment method from the givenPaymentResponse.getRecommendedSavedPaymentMethodStatus()
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:SavedPaymentMethodManagementService
Creates a saved payment method for future use from the givenPayment
andPaymentResponse
.- Specified by:
createSavedPaymentMethodForFutureUse
in interfaceSavedPaymentMethodManagementService
- Parameters:
payment
- the payment that should be savedpaymentResponse
- thePaymentResponse
from 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:SavedPaymentMethodManagementService
Updates 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:
updateSavedPaymentMethodBasedOnPaymentResponse
in interfaceSavedPaymentMethodManagementService
- Parameters:
savedPaymentMethodId
- the id of the saved payment method to updatepaymentResponse
- thePaymentResponse
from the transaction executioncontextInfo
- context information related to multitenancy
-
updateSavedPaymentMethodBasedOnPaymentResponse
public void updateSavedPaymentMethodBasedOnPaymentResponse(@NonNull @NonNull SavedPaymentMethod savedPaymentMethod, @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 givenPaymentResponse
.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 interfaceSavedPaymentMethodManagementService
- Parameters:
savedPaymentMethod
- the saved payment method to updatepaymentResponse
- thePaymentResponse
from the transaction executioncontextInfo
- context information related to multitenancy
-
updateSavedPaymentMethodStatus
protected void updateSavedPaymentMethodStatus(@NonNull @NonNull SavedPaymentMethod savedPaymentMethod, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Updates the status of the saved payment method from the givenPaymentResponse.getRecommendedSavedPaymentMethodStatus()
.By default, it doesn't update the status if the current saved payment method status is
DefaultSavedPaymentMethodStatuses.ACTION_FAILED
orDefaultSavedPaymentMethodStatuses.INVALID_PAYMENT_METHOD
.- Parameters:
savedPaymentMethod
- the saved payment method to updatepaymentResponse
- thePaymentResponse
from the transaction execution- See Also:
-
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 givenPayment
with the saved payment method specified inPayment.getSavedPaymentMethodId()
.- Specified by:
populatePaymentFromSavedPaymentMethod
in interfaceSavedPaymentMethodManagementService
- Parameters:
payment
- thePayment
to populate forsavedPaymentMethodId
- the saved payment method id to retrieve the saved payment method fromcontextInfo
- 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 anOwnershipSummary
of the saved payment method.- Specified by:
getSavedPaymentMethodOwnership
in interfaceSavedPaymentMethodManagementService
- Parameters:
savedPaymentMethodId
- the saved payment method id to retrieve the saved payment method fromcontextInfo
- 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 theOwnershipSummary
based on the givenSavedPaymentMethod
.- Parameters:
savedPaymentMethod
- theSavedPaymentMethod
to build theOwnershipSummary
for- Returns:
- the
OwnershipSummary
based on the givenSavedPaymentMethod
-
buildSavedPaymentMethod
Builds aSavedPaymentMethod
from the givenPayment
, to be later populated using aPaymentResponse
. Note: TheSavedPaymentMethod.paymentMethodProperties
are intentionally not populated using thePayment.getPaymentMethodProperties()
. Instead, we expect all of these values to come from thePaymentResponse
- Parameters:
payment
- thePayment
to build theSavedPaymentMethod
from- Returns:
- a
SavedPaymentMethod
from 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 successfulPaymentTransaction
from the givenPayment
.- Parameters:
payment
- thePayment
to get the latest successfulPaymentTransaction
from- Returns:
- the latest successful
PaymentTransaction
from the givenPayment
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getSavedPaymentMethodService
-
getSavedPaymentMethodAccessValidationService
Lazy injectedSavedPaymentMethodAccessValidationService
since this service is itself a service component.This avoids circular dependency exceptions
-
setSavedPaymentMethodAccessValidationService
@Autowired @Lazy public void setSavedPaymentMethodAccessValidationService(SavedPaymentMethodAccessValidationService savedPaymentMethodAccessValidationService) Lazy injectedSavedPaymentMethodAccessValidationService
since this service is itself a service component.This avoids circular dependency exceptions
-