Class DefaultPaymentProcessingService<P extends BillingProcessingRequest>
java.lang.Object
com.broadleafcommerce.billing.job.service.impl.DefaultPaymentProcessingService<P>
- All Implemented Interfaces:
PaymentProcessingService<P>
public class DefaultPaymentProcessingService<P extends BillingProcessingRequest>
extends Object
implements PaymentProcessingService<P>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BillingJobPropertiesprotected DeadLetterMessageSenderprotected com.fasterxml.jackson.databind.ObjectMapperprotected PaymentTransactionExecutionService<P>protected com.broadleafcommerce.common.extension.TypeFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PcallProcessorAndSaveResult(P request, PaymentTransactionDetail transactionDetail, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidcreateFailurePaymentAccountProcessingRequest(P billingProcessingRequest, String failureReason) protected voidprotected StringgetBillingEventPaymentId(P processingRequest, PaymentAccountProcessingRequest accountRequest) protected PaymentAccountProcessingResultEnumprotected voidhandleAlreadyProcessed(P request, List<P> sendToResultHandler, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidhandleExistingTransactionDetail(P request, List<P> sendToResultHandler, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanisEligibleForGatewayErrorRetries(P request) Hook point used to declare if gateway errors are eligible for automatic retries.protected StringnullablePaymentAccountId(P request) protected voidprotected voidprocessPayment(P request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method calls the payment processor implementation to process the request.processPayments(String paymentGatewayType, List<P> requests, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) For each request in the list, verifies that this is the first attempt to process the transaction by persisting a newPaymentTransactionDetail.protected PprocessTransactionResults(P processingRequest, @NonNull PaymentAccountProcessingRequest paymentAccountProcessingRequest, @NonNull String transactionId, @NonNull PaymentTransactionDetail paymentTransactionDetail, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) resolveUnknownPaymentGatewayResponses(List<P> requests, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Resolves unknown gateway responses by looking up the results from the processor.protected Optional<PaymentTransactionDetail>saveNewPaymentTransactionDetailBeforeSendingToProcessor(P processingRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidsendBPRToDeadLetterQueue(P bpr, String errorMessage, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected StringserializeObject(PaymentTransactionDetail transactionDetail) protected StringserializeObject(BillingProcessingRequest request) protected booleanprotected booleantransactionResultsNotFound(PaymentAccountProcessingRequest accountProcessingRequest) protected voidupdateTransactionDetailWithProcessingResult(P request, PaymentTransactionDetail detail, ProcessingResultEnum result)
-
Field Details
-
resultConversionMap
-
bprService
@Autowired protected BillingProcessRequestService<P extends BillingProcessingRequest,BillingProcessingRequestWithFullDetails> bprService -
paymentTransactionDetailService
@Autowired protected PaymentTransactionDetailService<PaymentTransactionDetail> paymentTransactionDetailService -
transactionExecutionService
@Autowired protected PaymentTransactionExecutionService<P extends BillingProcessingRequest> transactionExecutionService -
handlerService
@Autowired protected PaymentProcessingResultHandlerService<P extends BillingProcessingRequest,PaymentTransactionDetail> handlerService -
billingJobProperties
-
deadLetterMessageSender
-
objectMapper
@Autowired protected com.fasterxml.jackson.databind.ObjectMapper objectMapper -
typeFactory
@Autowired protected com.broadleafcommerce.common.extension.TypeFactory typeFactory
-
-
Constructor Details
-
DefaultPaymentProcessingService
public DefaultPaymentProcessingService()
-
-
Method Details
-
processPayments
public List<P> processPayments(String paymentGatewayType, List<P> requests, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentProcessingServiceFor each request in the list, verifies that this is the first attempt to process the transaction by persisting a newPaymentTransactionDetail. If a transaction has not been attempted before, calls thePaymentTransactionExecutionServiceand saves the result on the request.If this transaction has been attempted before, in certain circumstances resends the request to the next stage.
- Specified by:
processPaymentsin interfacePaymentProcessingService<P extends BillingProcessingRequest>- Parameters:
paymentGatewayType- type of gateway to execute the paymentrequests- the list ofbilling processing requestsdescribing the payment methods & amounts to be chargedcontextInfo- context information around multi-tenant state- Returns:
- The list of
billing processing requeststhat should be sent toPaymentProcessingResultHandlerService
-
resolveUnknownPaymentGatewayResponses
public List<P> resolveUnknownPaymentGatewayResponses(List<P> requests, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentProcessingServiceResolves unknown gateway responses by looking up the results from the processor. If the processor is not aware of the transaction, usesBillingJobProperties.paymentGatewayConfigconfiguration to decide whether to attempt retrying the transaction.- Specified by:
resolveUnknownPaymentGatewayResponsesin interfacePaymentProcessingService<P extends BillingProcessingRequest>- Parameters:
requests- the list ofbilling processing requestsdescribing the payment methods & billing attempts that are missing gateway responsescontextInfo- context information around multi-tenant state- Returns:
- The list of updated
billing processing requeststhat should be sent toPaymentProcessingResultHandlerService
-
ensureNoActiveTransaction
protected void ensureNoActiveTransaction() -
callProcessorAndSaveResult
protected P callProcessorAndSaveResult(P request, PaymentTransactionDetail transactionDetail, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
processPayment
protected void processPayment(P request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method calls the payment processor implementation to process the request. It then reacts to its return value, as well as any exceptions that it may throw, to fill out thePaymentAccountProcessingRequest. -
isEligibleForGatewayErrorRetries
Hook point used to declare if gateway errors are eligible for automatic retries.- Parameters:
request- TheBillingProcessingRequest
-
createFailurePaymentAccountProcessingRequest
-
nullablePaymentAccountId
-
populateAccountWithException
-
handleExistingTransactionDetail
-
sendBPRToDeadLetterQueue
-
handleAlreadyProcessed
-
saveNewPaymentTransactionDetailBeforeSendingToProcessor
protected Optional<PaymentTransactionDetail> saveNewPaymentTransactionDetailBeforeSendingToProcessor(P processingRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getBillingEventPaymentId
protected String getBillingEventPaymentId(P processingRequest, PaymentAccountProcessingRequest accountRequest) -
updateTransactionDetailWithProcessingResult
protected void updateTransactionDetailWithProcessingResult(P request, PaymentTransactionDetail detail, ProcessingResultEnum result) -
processTransactionResults
@Nullable protected P processTransactionResults(@NonNull P processingRequest, @NonNull @NonNull PaymentAccountProcessingRequest paymentAccountProcessingRequest, @NonNull @NonNull String transactionId, @NonNull @NonNull PaymentTransactionDetail paymentTransactionDetail, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
transactionResultsNotFound
protected boolean transactionResultsNotFound(PaymentAccountProcessingRequest accountProcessingRequest) -
shouldCallProcessorIfTransactionNotFound
-
getProcessingResult
protected PaymentAccountProcessingResultEnum getProcessingResult(TransactionExecutionResponse response) -
serializeObject
-
serializeObject
-