Class BillingProcessingRequestInitializer<P extends InitializeBillingProcessingRequests>
java.lang.Object
com.broadleafcommerce.billing.job.module.BillingProcessingRequestInitializer<P>
public class BillingProcessingRequestInitializer<P extends InitializeBillingProcessingRequests>
extends Object
Receives the newly generated billing processing requests and adds the required payment
information for each request.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BillingEventAddressService<BillingEventAddress>protected BillingEventPaymentService<BillingEventPayment,BillingEventPaymentWithEvent, BillingEventDTO, BillingEventPaymentWithTransaction> protected BillingEventPricingService<BillingEventDTO,BillingEvent, BillingEventAdjustment, BillingEventItemWithTaxDetails, BillingEventPaymentWithTransaction> protected BillingJobPropertiesprotected BillingProcessRequestService<BillingProcessingRequest,BillingProcessingRequestWithFullDetails> protected BillingRetryScheduleService<BillingRetrySchedule>protected BillingJobMessageSenderprotected com.broadleafcommerce.common.extension.TypeFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildRequestWithBillingEventDTO(BillingProcessingRequest request, BillingProcessingRequestWithFullDetails requestWithFullDetails) Builds a composite object from theBillingProcessingRequestand the relatedBillingEventDTOprotected PaymentAccountProcessingRequestcreatePaymentAccountProcessingRequestForCharge(BillingProcessingRequestWithFullDetails billingProcessingRequestDetails, PaymentAccount paymentAccount) protected PaymentAccountProcessingRequestcreatePaymentAccountProcessingRequestForRefund(BillingProcessingRequestWithFullDetails billingProcessingRequestDetails) protected List<BillingProcessingRequestWithFullDetails>filterOutWrongStatuses(List<BillingProcessingRequestWithFullDetails> billingProcessingRequestWithFullDetails) protected BillingEventAddressgetBillingEventAddress(PaymentAccount paymentAccount) protected voidhandleNoPaymentAccountsOnCharge(BillingProcessingRequest request, List<String> idsToSendToFinalizer) Handles changes to theBillingProcessingRequestfor CHARGE-type requests with no payment accountsprotected voidhandleRequestForPaymentProcessor(BillingProcessingRequest request, List<BillingProcessingRequest> sendToPaymentProcessor) Handles changes to a request to prepare for it being sent to a payment processorprotected StringhashTransactionReferenceID(String transactionReferenceId) Some gateways only allow transaction reference ids shorter than 50 characters.protected voidinitializeRequests(List<BillingProcessingRequestWithFullDetails> requestsWithFullDetails, Map<String, WalletWithPaymentAccounts> walletsWithPaymentAccounts, List<BillingProcessingRequest> allInitializedRequests, List<String> idsToSendToFinalizer, List<BillingProcessingRequest> sendToPaymentProcessor, List<BillingProcessingRequestWithBillingEventDTO> sendToTaxHandler) Handles initializing given requests and sorting them to their next destinations depending on their state and external configuration propertiesprotected booleanisBillingAddressPresent(BillingEventDTO billingEventDTO) protected booleanisPaymentAborted(BillingProcessingRequestWithFullDetails requestDetails) protected booleanisTaxCalculated(BillingProcessingRequest billingProcessingRequest) protected voidpopulateAccounts(BillingProcessingRequestWithFullDetails billingProcessingRequestDetails, List<PaymentAccount> paymentAccounts) protected voidprotected voidprepareValidRequestsForNextSteps(BillingProcessingRequest request, BillingProcessingRequestWithFullDetails requestWithFullDetails, BillingProcessingRequestWithBillingEventDTO requestWithBillingEventDTO, List<PaymentAccount> activePaymentAccounts, List<BillingProcessingRequestWithBillingEventDTO> sendToTaxHandler, List<BillingProcessingRequest> sendToPaymentProcessor) Handles preparing valid requests for their next step, either to be sent to a payment processor or a tax handler.voidDeprecated.voidprocess(P requestsToInitialize, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected List<BillingProcessingRequestWithFullDetails>readRequestsWithFullDetailsInCorrectStatuses(P request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Readsrequests with detailsfor given ids and filters out those already processed or not in NEW statusprotected Map<String,WalletWithPaymentAccounts> readWalletsWithPaymentAccounts(List<BillingProcessingRequestWithFullDetails> requestsWithFullDetails, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads wallets for the provided requests.protected booleanrequestShouldHaveAccountsButHasNone(BillingProcessingTransactionTypeEnum transactionType, List<PaymentAccount> activePaymentAccounts) Checks whether a given request should have active payment accounts to effectively proceed, but has none instead.protected List<PaymentAccount>retrieveActiveAccounts(BillingProcessingRequest request, Map<String, WalletWithPaymentAccounts> walletsWithPaymentAccounts) Retrieves active payment accounts for the given requestprotected voidsetAddressForTaxCalculationIfMissing(BillingProcessingRequestWithBillingEventDTO billingProcessingRequestWithBillingEventDTO, List<PaymentAccount> activePaymentAccounts) This method sets the billing address from a payment account onto the request for tax calculation if the request does not previously contain a billing addressprotected voidsetPaymentProcessingRequest(BillingProcessingRequestWithFullDetails requestWithFullDetails) Build and set aPaymentAccountProcessingRequestin theBillingProcessingRequestWithFullDetails
-
Field Details
-
sender
-
billingProcessRequestService
@Autowired protected BillingProcessRequestService<BillingProcessingRequest,BillingProcessingRequestWithFullDetails> billingProcessRequestService -
billingEventService
@Autowired protected BillingEventService<BillingEvent,BillingEventDTO, billingEventServiceCreateBillingEventRequest> -
refundEventDetailService
@Autowired protected RefundEventDetailService<RefundEventDetail,RefundDetailsWithRefundAndBillingEvent> refundEventDetailService -
billingEventPaymentService
@Autowired protected BillingEventPaymentService<BillingEventPayment,BillingEventPaymentWithEvent, billingEventPaymentServiceBillingEventDTO, BillingEventPaymentWithTransaction> -
billingRetryScheduleService
-
billingJobProperties
-
billingEventPricingService
@Autowired protected BillingEventPricingService<BillingEventDTO,BillingEvent, billingEventPricingServiceBillingEventAdjustment, BillingEventItemWithTaxDetails, BillingEventPaymentWithTransaction> -
billingEventItemService
@Autowired protected BillingEventItemService<BillingEventItem,BillingEventItemWithTaxDetails> billingEventItemService -
walletService
@Autowired protected WalletService<WalletWithPaymentAccounts,BillingProcessingRequestWithFullDetails> walletService -
billingEventPaymentFinder
@Autowired protected BillingEventPaymentFinder<BillingEventPaymentWithEvent> billingEventPaymentFinder -
billingProcessingRequestGenerator
@Autowired protected BillingProcessingRequestGenerator<BillingProcessingRequest> billingProcessingRequestGenerator -
billingEventAddressService
-
typeFactory
@Autowired protected com.broadleafcommerce.common.extension.TypeFactory typeFactory
-
-
Constructor Details
-
BillingProcessingRequestInitializer
public BillingProcessingRequestInitializer()
-
-
Method Details
-
process
Deprecated. -
process
public void process(P requestsToInitialize, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
readWalletsWithPaymentAccounts
@Nullable protected Map<String,WalletWithPaymentAccounts> readWalletsWithPaymentAccounts(List<BillingProcessingRequestWithFullDetails> requestsWithFullDetails, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads wallets for the provided requests. This is a hook point to override for situations where no payment accounts are necessary for billing, such as using an external invoicing system. -
initializeRequests
protected void initializeRequests(List<BillingProcessingRequestWithFullDetails> requestsWithFullDetails, @Nullable Map<String, WalletWithPaymentAccounts> walletsWithPaymentAccounts, List<BillingProcessingRequest> allInitializedRequests, List<String> idsToSendToFinalizer, List<BillingProcessingRequest> sendToPaymentProcessor, List<BillingProcessingRequestWithBillingEventDTO> sendToTaxHandler) Handles initializing given requests and sorting them to their next destinations depending on their state and external configuration properties- Parameters:
requestsWithFullDetails- requests with full detailswalletsWithPaymentAccounts- map of wallets gathered for these requestsallInitializedRequests- list that will contain all initialized requests regardless of next destinationidsToSendToFinalizer- list that will contain ids of requests to be sent to the finalizersendToPaymentProcessor- list that will contain requests to be sent to the payment processorsendToTaxHandler- list that will contain requests to be sent to the payment handler
-
buildRequestWithBillingEventDTO
protected BillingProcessingRequestWithBillingEventDTO buildRequestWithBillingEventDTO(BillingProcessingRequest request, BillingProcessingRequestWithFullDetails requestWithFullDetails) Builds a composite object from theBillingProcessingRequestand the relatedBillingEventDTO -
setPaymentProcessingRequest
protected void setPaymentProcessingRequest(BillingProcessingRequestWithFullDetails requestWithFullDetails) Build and set aPaymentAccountProcessingRequestin theBillingProcessingRequestWithFullDetails -
retrieveActiveAccounts
protected List<PaymentAccount> retrieveActiveAccounts(BillingProcessingRequest request, @Nullable Map<String, WalletWithPaymentAccounts> walletsWithPaymentAccounts) Retrieves active payment accounts for the given request- Parameters:
request- the given requestwalletsWithPaymentAccounts- map of wallets for all request- Returns:
- retrieved active accounts
-
requestShouldHaveAccountsButHasNone
protected boolean requestShouldHaveAccountsButHasNone(BillingProcessingTransactionTypeEnum transactionType, @Nullable List<PaymentAccount> activePaymentAccounts) Checks whether a given request should have active payment accounts to effectively proceed, but has none instead. -
readRequestsWithFullDetailsInCorrectStatuses
protected List<BillingProcessingRequestWithFullDetails> readRequestsWithFullDetailsInCorrectStatuses(P request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Readsrequests with detailsfor given ids and filters out those already processed or not in NEW status -
handleNoPaymentAccountsOnCharge
protected void handleNoPaymentAccountsOnCharge(BillingProcessingRequest request, List<String> idsToSendToFinalizer) Handles changes to theBillingProcessingRequestfor CHARGE-type requests with no payment accounts -
prepareValidRequestsForNextSteps
protected void prepareValidRequestsForNextSteps(BillingProcessingRequest request, BillingProcessingRequestWithFullDetails requestWithFullDetails, BillingProcessingRequestWithBillingEventDTO requestWithBillingEventDTO, @Nullable List<PaymentAccount> activePaymentAccounts, List<BillingProcessingRequestWithBillingEventDTO> sendToTaxHandler, List<BillingProcessingRequest> sendToPaymentProcessor) Handles preparing valid requests for their next step, either to be sent to a payment processor or a tax handler. -
handleRequestForPaymentProcessor
protected void handleRequestForPaymentProcessor(BillingProcessingRequest request, List<BillingProcessingRequest> sendToPaymentProcessor) Handles changes to a request to prepare for it being sent to a payment processor -
isPaymentAborted
-
filterOutWrongStatuses
protected List<BillingProcessingRequestWithFullDetails> filterOutWrongStatuses(List<BillingProcessingRequestWithFullDetails> billingProcessingRequestWithFullDetails) -
populateTransactionReferenceIds
protected void populateTransactionReferenceIds(BillingProcessingRequestWithFullDetails requestDetails) -
createPaymentAccountProcessingRequestForRefund
protected PaymentAccountProcessingRequest createPaymentAccountProcessingRequestForRefund(BillingProcessingRequestWithFullDetails billingProcessingRequestDetails) -
createPaymentAccountProcessingRequestForCharge
protected PaymentAccountProcessingRequest createPaymentAccountProcessingRequestForCharge(BillingProcessingRequestWithFullDetails billingProcessingRequestDetails, PaymentAccount paymentAccount) -
populateAccounts
protected void populateAccounts(BillingProcessingRequestWithFullDetails billingProcessingRequestDetails, List<PaymentAccount> paymentAccounts) -
isTaxCalculated
-
isBillingAddressPresent
-
getBillingEventAddress
-
setAddressForTaxCalculationIfMissing
protected void setAddressForTaxCalculationIfMissing(BillingProcessingRequestWithBillingEventDTO billingProcessingRequestWithBillingEventDTO, List<PaymentAccount> activePaymentAccounts) This method sets the billing address from a payment account onto the request for tax calculation if the request does not previously contain a billing address- Parameters:
billingProcessingRequestWithBillingEventDTO- composite object containing the requestactivePaymentAccounts- the billing address of the first account from this list will be used for tax calculation
-
hashTransactionReferenceID
Some gateways only allow transaction reference ids shorter than 50 characters. We hash the given value to the MD5 digest.
-
process(InitializeBillingProcessingRequests, ContextInfo)instead