Interface PaymentManagementService<P extends Payment>
- All Known Implementing Classes:
DefaultPaymentManagementService
public interface PaymentManagementService<P extends Payment>
Service API for managing
payments
. Supported by PaymentService
.- Author:
- Chris Kittrell (ckittrell)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
archiveAllByOwnerTypeAndOwnerId
(String ownerType, String ownerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) ArchivesPayments
for the given owner type and owner id.void
archiveAllByOwnerTypeAndOwnerId
(String ownerType, String ownerId, PaymentLockTokens paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) ArchivesPayments
for the given owner type and owner id.void
archivePayment
(String id, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Archives thePayment
based on the provided id.blockCustomerMutability
(org.springframework.data.domain.Page<Payment> payments, PaymentLockTokens paymentLockTokens, boolean shouldMarkTransactionsIneligibleForAutomaticReversal, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finalizes the list ofpayments
provided.blockCustomerMutabilityForPaymentFinalization
(org.springframework.data.domain.Page<Payment> payments, PaymentLockTokens paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Adds theDefaultPaymentManagementAccessRestrictions.CUSTOMER_MUTABILITY_BLOCKED_FOR_PAYMENT_FINALIZATION
restriction to the Payment'sPayment.getAccessRestrictions()
.createPayment
(CreatePaymentRequest createPaymentRequest, CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates aPayment
based on the providedCreatePaymentRequest
.org.springframework.data.domain.Page<P>
readAllByOwnerTypeAndOwnerId
(String ownerType, String ownerId, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Find a page of payments for the given owner type and owner id.readAllByPaymentIds
(Iterable<String> ids, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Find a list of payments for the given payment ids.removeCustomerMutabilityBlockForPaymentFinalization
(org.springframework.data.domain.Page<Payment> payments, PaymentLockTokens paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Unlocks the payments for the customer mutability by removing theDefaultPaymentManagementAccessRestrictions.CUSTOMER_MUTABILITY_BLOCKED_FOR_PAYMENT_FINALIZATION
fromPayment.getAccessRestrictions()
.default boolean
requestOnlyIncludesSupplementaryValues
(P payment, UpdatePaymentRequest updateRequest) Determines if the update request only includes supplementary changes (i.e.transferPaymentsFromCSR
(org.springframework.data.domain.Page<Payment> payments, PaymentLockTokens paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Transfers the list ofpayments
provided from the CSR.transferPaymentsToCSR
(org.springframework.data.domain.Page<Payment> payments, PaymentLockTokens paymentLockTokens, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Transfers the list ofpayments
provided to the CSR.updatePayment
(String id, UpdatePaymentRequest updateRequest, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Updates thePayment
based on the providedUpdatePaymentRequest
.updatePaymentForCustomer
(String id, UpdatePaymentRequest updateRequest, String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Updates thePayment
for the customer based on the providedUpdatePaymentRequest
.
-
Method Details
-
createPayment
P createPayment(CreatePaymentRequest createPaymentRequest, @Nullable CustomerRef customerRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates aPayment
based on the providedCreatePaymentRequest
.- Parameters:
createPaymentRequest
- The request payload used to build a newPayment
.contextInfo
- Context information related to multitenancy.- Returns:
- A
Payment
based on the providedCreatePaymentRequest
. - Throws:
InvalidCreatePaymentRequestException
- if the create payment request produced an invalid payment.
-
readAllByPaymentIds
List<P> readAllByPaymentIds(@NonNull Iterable<String> ids, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Find a list of payments for the given payment ids.- Parameters:
ids
- , The ids of the payments.context
- Context information related to multitenancy.- Returns:
- A list of payments for the given ids.
-
readAllByOwnerTypeAndOwnerId
org.springframework.data.domain.Page<P> readAllByOwnerTypeAndOwnerId(String ownerType, String ownerId, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Find a page of payments for the given owner type and owner id.- Parameters:
ownerType
- The type of the payment's owner.ownerId
- The id of the payment's owner.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.
-
updatePaymentForCustomer
@Nullable P updatePaymentForCustomer(String id, UpdatePaymentRequest updateRequest, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Updates thePayment
for the customer based on the providedUpdatePaymentRequest
. The default implementation archives the payment ifUpdatePaymentRequest.getAmount()
is equal to zero.- Parameters:
id
- The context id for thePayment
.updateRequest
- The request payload used to update thePayment
.lockToken
- Token granted to resource that owns the payment lock.context
- Context information related to multitenancy.- Returns:
- The updated
Payment
. - Throws:
InvalidUpdatePaymentRequestException
- if the update payment request produced an invalid paymentcom.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if thePayment
cannot be found within the provided context.org.springframework.dao.OptimisticLockingFailureException
- if the payment version is out of date
-
requestOnlyIncludesSupplementaryValues
default boolean requestOnlyIncludesSupplementaryValues(P payment, UpdatePaymentRequest updateRequest) Determines if the update request only includes supplementary changes (i.e. they don't change the underlying payment method, change the amount related to the initiating transaction, etc.). These changes are deemed safe to make since they're only informative data points, rather than data points that change the function/intent of the interaction.- Parameters:
payment
- thePayment
to be updatedupdateRequest
- the candidateUpdatePaymentRequest
to be applied against the payment.- Returns:
- true if the update request only includes supplementary changes, false otherwise
-
updatePayment
@Nullable P updatePayment(String id, UpdatePaymentRequest updateRequest, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Updates thePayment
based on the providedUpdatePaymentRequest
. The default implementation archives the payment ifUpdatePaymentRequest.getAmount()
is equal to zero.- Parameters:
id
- The context id for thePayment
.updateRequest
- The request payload used to update thePayment
.lockToken
- Token granted to resource that owns the payment lock.context
- Context information related to multitenancy.- Returns:
- The updated
Payment
. - Throws:
InvalidUpdatePaymentRequestException
- if the update payment request produced an invalid paymentcom.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if thePayment
cannot be found within the provided context.org.springframework.dao.OptimisticLockingFailureException
- if the payment version is out of date
-
archivePayment
void archivePayment(String id, @Nullable String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Archives thePayment
based on the provided id.- Parameters:
id
- The context id for thePayment
.lockToken
- Token granted to resource that owns the payment lock.context
- Context information related to multitenancy.- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if thePayment
cannot be found within the provided context.org.springframework.dao.OptimisticLockingFailureException
- if the payment version is out of date.
-
archiveAllByOwnerTypeAndOwnerId
void archiveAllByOwnerTypeAndOwnerId(String ownerType, String ownerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) ArchivesPayments
for the given owner type and owner id.- Parameters:
ownerType
- The type of the payment's owner.ownerId
- The id of the payment's owner.context
- Context information related to multitenancy.
-
archiveAllByOwnerTypeAndOwnerId
void archiveAllByOwnerTypeAndOwnerId(String ownerType, String ownerId, @Nullable PaymentLockTokens paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) ArchivesPayments
for the given owner type and owner id.- Parameters:
ownerType
- The type of the payment's owner.ownerId
- The id of the payment's owner.paymentLockTokens
- Token granted to resource that owns the payment lock.context
- Context information related to multitenancy.
-
blockCustomerMutability
UpdatePaymentsResponse blockCustomerMutability(org.springframework.data.domain.Page<Payment> payments, PaymentLockTokens paymentLockTokens, boolean shouldMarkTransactionsIneligibleForAutomaticReversal, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finalizes the list ofpayments
provided.- Parameters:
payments
- the page of payments to finalizepaymentLockTokens
- the collection of payment lock tokens to grant access to the paymentsshouldMarkTransactionsIneligibleForAutomaticReversal
- whether or not to mark the payments as ineligible for automatic reversalcontext
- Context information related to multitenancy.- Returns:
- the response of successful and failed payments
-
blockCustomerMutabilityForPaymentFinalization
UpdatePaymentsResponse blockCustomerMutabilityForPaymentFinalization(org.springframework.data.domain.Page<Payment> payments, PaymentLockTokens paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Adds theDefaultPaymentManagementAccessRestrictions.CUSTOMER_MUTABILITY_BLOCKED_FOR_PAYMENT_FINALIZATION
restriction to the Payment'sPayment.getAccessRestrictions()
.- Parameters:
payments
- the page of payments to updatepaymentLockTokens
- the collection of payment lock tokens to grant access to the paymentscontext
- Context information related to multitenancy.- Returns:
- the response of successful and failed payments
-
removeCustomerMutabilityBlockForPaymentFinalization
UpdatePaymentsResponse removeCustomerMutabilityBlockForPaymentFinalization(org.springframework.data.domain.Page<Payment> payments, PaymentLockTokens paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Unlocks the payments for the customer mutability by removing theDefaultPaymentManagementAccessRestrictions.CUSTOMER_MUTABILITY_BLOCKED_FOR_PAYMENT_FINALIZATION
fromPayment.getAccessRestrictions()
.- Parameters:
payments
- the page of payments to unlockpaymentLockTokens
- the collection of payment lock tokens to grant access to the paymentscontext
- Context information related to multitenancy.- Returns:
- the response of successful and failed payments
-
transferPaymentsToCSR
UpdatePaymentsResponse transferPaymentsToCSR(org.springframework.data.domain.Page<Payment> payments, PaymentLockTokens paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Transfers the list ofpayments
provided to the CSR.- Parameters:
payments
- the page of payments to transferpaymentLockTokens
- the collection of payment lock tokens to grant access to the paymentscontextInfo
- Context information related to multitenancy.- Returns:
- the response of successful and failed payments
-
transferPaymentsFromCSR
UpdatePaymentsResponse transferPaymentsFromCSR(org.springframework.data.domain.Page<Payment> payments, PaymentLockTokens paymentLockTokens, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Transfers the list ofpayments
provided from the CSR.- Parameters:
payments
- the page of payments to transferpaymentLockTokens
- the collection of payment lock tokens to grant access to the paymentscontextInfo
- Context information related to multitenancy.- Returns:
- the response of successful and failed payments
-