Class DefaultSavedPaymentMethodService<P extends SavedPaymentMethod>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.paymenttransaction.service.DefaultSavedPaymentMethodService<P>
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>,SavedPaymentMethodService<P>
public class DefaultSavedPaymentMethodService<P extends SavedPaymentMethod>
extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
implements SavedPaymentMethodService<P>
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSavedPaymentMethodService(SavedPaymentMethodRepository<com.broadleafcommerce.data.tracking.core.Trackable> savedPaymentMethodRepository, com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider paymentGatewayResourceProvider, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected PbuildSavedPaymentMethod(@NonNull CreateSavedPaymentMethodRequest createRequest) Builds aSavedPaymentMethodfrom the givenCreateSavedPaymentMethodRequest.createSavedPaymentMethod(@NonNull CreateSavedPaymentMethodRequest createRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates aSavedPaymentMethodfrom the givenCreateSavedPaymentMethodRequest.protected voiddeleteGatewaySavedPaymentMethod(P savedPaymentMethod, String applicationId, String tenantId) A hook method that can be used by a gateway implementation to modify the payment method properties before deleting the saved payment method.voiddeleteSavedPaymentMethod(P savedPaymentMethod, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deletes the saved payment method.protected StringgetApplicationIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtilsprotected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProviderprotected SavedPaymentMethodRepository<com.broadleafcommerce.data.tracking.core.Trackable>protected StringgetTenantIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.common.extension.TypeFactoryprotected PmodifyPaymentMethodPropertiesForCreate(@NonNull CreateSavedPaymentMethodRequest createRequest, P savedPayment, String tenantId, String applicationId) A hook method that can be used by a gateway implementation to modify the payment method properties before creation the saved payment method.protected PmodifyPaymentMethodPropertiesForUpdate(P originalSavedPaymentMethod, P updatedSavedPaymentMethod, String applicationId, String tenantId) A hook method that can be used by a gateway implementation to modify the payment method properties before updating the saved payment method.protected PpopulateSavedPaymentMethodUpdates(P savedPayment, @NonNull UpdateSavedPaymentMethodRequest updateRequest) Populates the updates fromUpdateSavedPaymentMethodRequestto the givenSavedPaymentMethod.readAllByOriginatingPaymentId(@NonNull List<String> originatingPaymentIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find all theSavedPaymentMethodsbySavedPaymentMethod.getOriginatingPaymentId()org.springframework.data.domain.Page<P>readAllByOwningUserTypeAndOwningUserId(@NonNull String ownerType, @NonNull String ownerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters) Finds all the activeSavedPaymentMethodsbased on the givenSavedPaymentMethod.getOwningUserType()andSavedPaymentMethod.getOwningUserId().org.springframework.data.domain.Page<P>readAllByOwningUserTypeAndOwningUserIdAndTenantId(String owningUserType, String owningUserId, String tenantId, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Find a page ofSavedPaymentMethodsfor the given owner type, owner id and tenant id.org.springframework.data.domain.Page<P>readAllForAccount(String accountId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find a page ofSavedPaymentMethodsfor the given account and its parent accounts This method is for B2B use cases where theSavedPaymentMethod.getOwningUserType()isDefaultSavedPaymentMethodOwningUserTypes.BLC_ACCOUNT.readByIdForAccount(String id, String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find aSavedPaymentMethodgiven its payment id, account and its parent accounts This method is for B2B use cases where theSavedPaymentMethod.getOwningUserType()isDefaultSavedPaymentMethodOwningUserTypes.BLC_ACCOUNT.readSavedPaymentMethodsByContextId(@NonNull List<String> ids, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find all theSavedPaymentMethodsbySavedPaymentMethod.getId().resetExistingDefaultPaymentFlags(String newDefaultSavedPaymentId, @NonNull String owningUserType, @NonNull String owningUserId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves any existingSavedPaymentMethodsand setSavedPaymentMethod.isDefaultForOwner()to false.voidsetAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) voidsetSavedPaymentMethodVersionValidationService(SavedPaymentMethodVersionValidationService savedPaymentMethodVersionValidationService) toUpdates(@NonNull Collection<P> savedPayments) update(@NonNull String id, P updated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) updateSavedPaymentMethod(@NonNull String savedPaymentMethodId, @NonNull UpdateSavedPaymentMethodRequest updateRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates theSavedPaymentMethodbased on the givenUpdateSavedPaymentMethodRequest.Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAllMethods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, createAll, createAllAllowingPartialSuccess, delete, getHelper, getRepository, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Constructor Details
-
DefaultSavedPaymentMethodService
public DefaultSavedPaymentMethodService(SavedPaymentMethodRepository<com.broadleafcommerce.data.tracking.core.Trackable> savedPaymentMethodRepository, com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider paymentGatewayResourceProvider, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
createSavedPaymentMethod
public P createSavedPaymentMethod(@NonNull @NonNull CreateSavedPaymentMethodRequest createRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SavedPaymentMethodServiceCreates aSavedPaymentMethodfrom the givenCreateSavedPaymentMethodRequest.- Specified by:
createSavedPaymentMethodin interfaceSavedPaymentMethodService<P extends SavedPaymentMethod>- Parameters:
createRequest- theCreateSavedPaymentMethodRequestto create aSavedPaymentMethodfromcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the newly created saved payment method
-
create
public P create(@NonNull P instance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
createin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends SavedPaymentMethod>- Overrides:
createin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends SavedPaymentMethod>
-
readAllByOwningUserTypeAndOwningUserId
public org.springframework.data.domain.Page<P> readAllByOwningUserTypeAndOwningUserId(@NonNull @NonNull String ownerType, @NonNull @NonNull String ownerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @Nullable org.springframework.data.domain.Pageable page, @Nullable cz.jirutka.rsql.parser.ast.Node filters) Description copied from interface:SavedPaymentMethodServiceFinds all the activeSavedPaymentMethodsbased on the givenSavedPaymentMethod.getOwningUserType()andSavedPaymentMethod.getOwningUserId().- Specified by:
readAllByOwningUserTypeAndOwningUserIdin interfaceSavedPaymentMethodService<P extends SavedPaymentMethod>- Parameters:
ownerType- the type of the owning userownerId- the ID of the owning usercontextInfo- context information surrounding sandboxing and multitenant statepage- the requested page of results from the databasefilters- An RSQL filter used to narrow query results. May beEmptyNodeif no filters should be applied- Returns:
- the
SavedPaymentMethodsbased on the givenSavedPaymentMethod.getOwningUserType()andSavedPaymentMethod.getOwningUserId()
-
readAllByOriginatingPaymentId
public List<P> readAllByOriginatingPaymentId(@NonNull @NonNull List<String> originatingPaymentIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SavedPaymentMethodServiceFind all theSavedPaymentMethodsbySavedPaymentMethod.getOriginatingPaymentId()- Specified by:
readAllByOriginatingPaymentIdin interfaceSavedPaymentMethodService<P extends SavedPaymentMethod>- Parameters:
originatingPaymentIds- the payment IDs to querySavedPaymentMethod.getOriginatingPaymentId()againstcontextInfo- context information regarding sandboxing and multitenant state- Returns:
- all the
SavedPaymentMethodsmatching the givenSavedPaymentMethod.getOriginatingPaymentId()
-
readSavedPaymentMethodsByContextId
public List<P> readSavedPaymentMethodsByContextId(@NonNull @NonNull List<String> ids, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SavedPaymentMethodServiceFind all theSavedPaymentMethodsbySavedPaymentMethod.getId().- Specified by:
readSavedPaymentMethodsByContextIdin interfaceSavedPaymentMethodService<P extends SavedPaymentMethod>- Parameters:
ids- the saved payment method IDs to querycontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the saved payment methods matching the given ids
-
updateSavedPaymentMethod
public P updateSavedPaymentMethod(@NonNull @NonNull String savedPaymentMethodId, @NonNull @NonNull UpdateSavedPaymentMethodRequest updateRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SavedPaymentMethodServiceUpdates theSavedPaymentMethodbased on the givenUpdateSavedPaymentMethodRequest.- Specified by:
updateSavedPaymentMethodin interfaceSavedPaymentMethodService<P extends SavedPaymentMethod>- Parameters:
savedPaymentMethodId- theSavedPaymentMethod.getId()to updateupdateRequest- theUpdateSavedPaymentMethodRequestcontaining the updatescontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the updated
SavedPaymentMethod
-
update
public P update(@NonNull @NonNull String id, @NonNull P updated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
updatein interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends SavedPaymentMethod>- Overrides:
updatein classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends SavedPaymentMethod>
-
readAllByOwningUserTypeAndOwningUserIdAndTenantId
public org.springframework.data.domain.Page<P> readAllByOwningUserTypeAndOwningUserIdAndTenantId(String owningUserType, String owningUserId, String tenantId, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:SavedPaymentMethodServiceFind a page ofSavedPaymentMethodsfor the given owner type, owner id and tenant id.- Specified by:
readAllByOwningUserTypeAndOwningUserIdAndTenantIdin interfaceSavedPaymentMethodService<P extends SavedPaymentMethod>- Parameters:
owningUserType- The type of the saved payment's owning userowningUserId- The id of the entity that owns this saved payment methodtenantId- The ID of theTenantthe payments belong to.page- The requested page of results from the database.context- Context information related to multitenancy.- Returns:
- A page of payments for the given owner type and id.
-
readAllForAccount
public org.springframework.data.domain.Page<P> readAllForAccount(String accountId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SavedPaymentMethodServiceFind a page ofSavedPaymentMethodsfor the given account and its parent accounts This method is for B2B use cases where theSavedPaymentMethod.getOwningUserType()isDefaultSavedPaymentMethodOwningUserTypes.BLC_ACCOUNT.- Specified by:
readAllForAccountin interfaceSavedPaymentMethodService<P extends SavedPaymentMethod>- Parameters:
accountId- The id of the entity's account\filters- additional filters to apply in the query.page- the requested page of results from the databasecontextInfo- the context info- Returns:
- a page of payments for the given account and parent accounts
-
readByIdForAccount
public Optional<P> readByIdForAccount(String id, String accountId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SavedPaymentMethodServiceFind aSavedPaymentMethodgiven its payment id, account and its parent accounts This method is for B2B use cases where theSavedPaymentMethod.getOwningUserType()isDefaultSavedPaymentMethodOwningUserTypes.BLC_ACCOUNT.- Specified by:
readByIdForAccountin interfaceSavedPaymentMethodService<P extends SavedPaymentMethod>- Parameters:
id- The id of the paymentaccountId- The id of the entity's accountcontextInfo- the context info- Returns:
- A payment for the given payment id, account id, and parent accounts
-
deleteSavedPaymentMethod
public void deleteSavedPaymentMethod(@NonNull P savedPaymentMethod, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SavedPaymentMethodServiceDeletes the saved payment method.- Specified by:
deleteSavedPaymentMethodin interfaceSavedPaymentMethodService<P extends SavedPaymentMethod>- Parameters:
savedPaymentMethod- the saved payment method id to deletecontextInfo- the context info
-
resetExistingDefaultPaymentFlags
protected List<P> resetExistingDefaultPaymentFlags(@Nullable String newDefaultSavedPaymentId, @NonNull @NonNull String owningUserType, @NonNull @NonNull String owningUserId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves any existingSavedPaymentMethodsand setSavedPaymentMethod.isDefaultForOwner()to false.This is typically used when creating or updating a
SavedPaymentMethodto be the default payment method.- Parameters:
newDefaultSavedPaymentId- the id of the new defaultSavedPaymentMethod. Should be null if the new defaultSavedPaymentMethodhas not yet been createdowningUserType- theSavedPaymentMethod.getOwningUserType()to identify the payments withowningUserId- theSavedPaymentMethod.getOwningUserId()to identify the payments withcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- a list of updated
SavedPaymentMethods
-
toUpdates
protected List<com.broadleafcommerce.data.tracking.core.service.Update<P>> toUpdates(@NonNull @NonNull Collection<P> savedPayments) -
buildSavedPaymentMethod
protected P buildSavedPaymentMethod(@NonNull @NonNull CreateSavedPaymentMethodRequest createRequest) Builds aSavedPaymentMethodfrom the givenCreateSavedPaymentMethodRequest.- Parameters:
createRequest- theCreateSavedPaymentMethodRequestto build theSavedPaymentMethodfrom- Returns:
- a built
SavedPaymentMethodfrom the givenCreateSavedPaymentMethodRequest
-
getApplicationIdFromContext
@Nullable protected String getApplicationIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getTenantIdFromContext
@Nullable protected String getTenantIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
modifyPaymentMethodPropertiesForCreate
protected P modifyPaymentMethodPropertiesForCreate(@NonNull @NonNull CreateSavedPaymentMethodRequest createRequest, @NonNull P savedPayment, @Nullable String tenantId, @Nullable String applicationId) A hook method that can be used by a gateway implementation to modify the payment method properties before creation the saved payment method. For example, this can be used to create a multi-use token for future use to execute transactions.- Parameters:
createRequest- theCreateSavedPaymentMethodRequestto get a single-use tokensavedPayment- aSavedPaymentMethodtenantId- the id for the current tenantapplicationId- the id for the current application- Returns:
- the saved payment method with updated payment method properties
-
modifyPaymentMethodPropertiesForUpdate
protected P modifyPaymentMethodPropertiesForUpdate(@NonNull P originalSavedPaymentMethod, @NonNull P updatedSavedPaymentMethod, @Nullable String applicationId, @Nullable String tenantId) A hook method that can be used by a gateway implementation to modify the payment method properties before updating the saved payment method. For example, this can be used to update a multi-use token for future use to execute transactions.- Parameters:
originalSavedPaymentMethod- aSavedPaymentMethodupdatedSavedPaymentMethod- theUpdateSavedPaymentMethodRequestapplicationId- the id for the current applicationtenantId- the id for the current tenant- Returns:
-
deleteGatewaySavedPaymentMethod
protected void deleteGatewaySavedPaymentMethod(@NonNull P savedPaymentMethod, @Nullable String applicationId, @Nullable String tenantId) A hook method that can be used by a gateway implementation to modify the payment method properties before deleting the saved payment method. For example, this can be used to delete a multi-use token.- Parameters:
savedPaymentMethod- aSavedPaymentMethodapplicationId- the id for the current applicationtenantId- the id for the current tenant
-
populateSavedPaymentMethodUpdates
protected P populateSavedPaymentMethodUpdates(@NonNull P savedPayment, @NonNull @NonNull UpdateSavedPaymentMethodRequest updateRequest) Populates the updates fromUpdateSavedPaymentMethodRequestto the givenSavedPaymentMethod.- Parameters:
savedPayment- theSavedPaymentMethodto updateupdateRequest- theUpdateSavedPaymentMethodRequestcontaining all theSavedPaymentMethodupdates- Returns:
- the update
SavedPaymentMethodbased on the givenUpdateSavedPaymentMethodRequest
-
getSavedPaymentMethodRepository
protected SavedPaymentMethodRepository<com.broadleafcommerce.data.tracking.core.Trackable> getSavedPaymentMethodRepository() -
getPaymentGatewayResourceProvider
protected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider getPaymentGatewayResourceProvider() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils() -
setAuthenticationUtils
@Autowired public void setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) -
getSavedPaymentMethodVersionValidationService
protected SavedPaymentMethodVersionValidationService getSavedPaymentMethodVersionValidationService() -
setSavedPaymentMethodVersionValidationService
@Autowired public void setSavedPaymentMethodVersionValidationService(SavedPaymentMethodVersionValidationService savedPaymentMethodVersionValidationService)
-