Class DefaultPaymentTransactionExecutionService<P extends BillingProcessingRequest>
java.lang.Object
com.broadleafcommerce.billing.job.service.impl.DefaultPaymentTransactionExecutionService<P>
- All Implemented Interfaces:
PaymentTransactionExecutionService<P>
public class DefaultPaymentTransactionExecutionService<P extends BillingProcessingRequest>
extends Object
implements PaymentTransactionExecutionService<P>
Default implementation of the
PaymentTransactionExecutionService that's used to
communicate with Broadleaf's PaymentTransactionServices to execute AuthorizeAndCapture and/or
Refund transactions.- Author:
- Chris Kittrell (ckittrell)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultPaymentTransactionExecutionService(PaymentTransactionExecutionProvider transactionExecutionProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddNullableTransactionAdditionalField(@NonNull PaymentAccountProcessingRequest accountProcessingRequest, @NonNull String key, String value, boolean transactionWasSuccessful) Add a transactionAdditionalField while handling null safety.authorizeAndCapture(P request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Executes an AuthorizeAndCapture (aka Charge) transaction based on the providedBillingProcessingRequestbuildAuthorizeAndCaptureRequest(P request) protected TransactionExecutionRequestbuildRefundRequest(P request) protected PaymentFailureTypeEnumgetFailureType(@NonNull TransactionExecutionResponse response) protected StringgetPaymentId(P request) protected StringgetPaymentVersion(P request) protected PaymentAccountProcessingResultEnumprotected PaymentTransactionExecutionProviderprotected com.broadleafcommerce.common.extension.TypeFactoryprotected booleanisEligibleForGatewayErrorRetries(P request, TransactionExecutionResponse response) Hook point used to declare if gateway errors are eligible for automatic retries.lookupAndRecordTransactionResults(@NonNull PaymentTransactionDetail paymentTransactionDetail, P request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Looks up transaction results for the providedPaymentTransactionDetail, & if present, stores the transaction results on theBillingProcessingRequest.currentAccountProcessingRequest()protected Optional<TransactionExecutionResponse>lookupTransactionResults(@NonNull PaymentTransactionDetail paymentTransactionDetail, P request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PrecordResultOnRequest(P request, @NonNull TransactionExecutionResponse response) Executes a Refund transaction based on the providedBillingProcessingRequestprotected voidupdateAccountProcessingRequestWithResults(@NonNull PaymentAccountProcessingRequest accountProcessingRequest, P request, @NonNull TransactionExecutionResponse response) protected PupdateBillingProcessingRequestWithTransactionResults(P request, @NonNull TransactionExecutionResponse response)
-
Field Details
-
CURRENT_BILLING_ATTEMPT_NUMBER
- See Also:
-
-
Constructor Details
-
DefaultPaymentTransactionExecutionService
public DefaultPaymentTransactionExecutionService(PaymentTransactionExecutionProvider transactionExecutionProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
authorizeAndCapture
public P authorizeAndCapture(@NonNull P request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentTransactionExecutionServiceExecutes an AuthorizeAndCapture (aka Charge) transaction based on the providedBillingProcessingRequest- Specified by:
authorizeAndCapturein interfacePaymentTransactionExecutionService<P extends BillingProcessingRequest>- Parameters:
request- theBillingProcessingRequestdescribing the payment method & amount to be chargedcontextInfo- context information around multi-tenant state- Returns:
- The
BillingProcessingRequestthat includes details about the transaction result populated in the fields ofBillingProcessingRequest.currentAccountProcessingRequest()
-
refund
public P refund(@NonNull P request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentTransactionExecutionServiceExecutes a Refund transaction based on the providedBillingProcessingRequest- Specified by:
refundin interfacePaymentTransactionExecutionService<P extends BillingProcessingRequest>- Parameters:
request- theBillingProcessingRequestdescribing the payment method & amount to be refundedcontextInfo- context information around multi-tenant state- Returns:
- The
BillingProcessingRequestthat includes details about the transaction result populated in the fields ofBillingProcessingRequest.currentAccountProcessingRequest()
-
lookupAndRecordTransactionResults
public P lookupAndRecordTransactionResults(@NonNull @NonNull PaymentTransactionDetail paymentTransactionDetail, @NonNull P request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:PaymentTransactionExecutionServiceLooks up transaction results for the providedPaymentTransactionDetail, & if present, stores the transaction results on theBillingProcessingRequest.currentAccountProcessingRequest()- Specified by:
lookupAndRecordTransactionResultsin interfacePaymentTransactionExecutionService<P extends BillingProcessingRequest>- Parameters:
paymentTransactionDetail- The transaction whose result is unknown, & therefore needs to be looked uprequest- theBillingProcessingRequestdescribing the payment method & amount that was expected to be charged or refundedcontextInfo- context information around multi-tenant state- Returns:
- The
BillingProcessingRequestthat includes details about the transaction result populated in the fields ofBillingProcessingRequest.currentAccountProcessingRequest(), if the transaction results are found
-
lookupTransactionResults
protected Optional<TransactionExecutionResponse> lookupTransactionResults(@NonNull @NonNull PaymentTransactionDetail paymentTransactionDetail, @NonNull P request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
updateBillingProcessingRequestWithTransactionResults
protected P updateBillingProcessingRequestWithTransactionResults(@NonNull P request, @NonNull @NonNull TransactionExecutionResponse response) -
buildAuthorizeAndCaptureRequest
protected SavedPaymentMethodTransactionExecutionRequest buildAuthorizeAndCaptureRequest(@NonNull P request) -
getPaymentId
-
getPaymentVersion
-
buildRefundRequest
-
recordResultOnRequest
protected P recordResultOnRequest(@NonNull P request, @NonNull @NonNull TransactionExecutionResponse response) -
getFailureType
@Nullable protected PaymentFailureTypeEnum getFailureType(@NonNull @NonNull TransactionExecutionResponse response) -
addNullableTransactionAdditionalField
protected void addNullableTransactionAdditionalField(@NonNull @NonNull PaymentAccountProcessingRequest accountProcessingRequest, @NonNull @NonNull String key, @Nullable String value, boolean transactionWasSuccessful) Add a transactionAdditionalField while handling null safety. If the `transactionWasSuccessful` boolean is set to `true`, an error will be logged since a successful transaction should not have required fields as `null`. If on the other hand a field that is not required needs to be inserted safely with this method, a `false` value should be passed in instead. -
updateAccountProcessingRequestWithResults
protected void updateAccountProcessingRequestWithResults(@NonNull @NonNull PaymentAccountProcessingRequest accountProcessingRequest, @NonNull P request, @NonNull @NonNull TransactionExecutionResponse response) -
isEligibleForGatewayErrorRetries
protected boolean isEligibleForGatewayErrorRetries(P request, TransactionExecutionResponse response) Hook point used to declare if gateway errors are eligible for automatic retries.- Parameters:
request- TheBillingProcessingRequestresponse- TheTransactionExecutionResponsedescribing the transaction result.- Returns:
- If gateway errors are eligible for automatic retries.
-
getProcessingResult
protected PaymentAccountProcessingResultEnum getProcessingResult(TransactionExecutionResponse response) -
getTransactionExecutionProvider
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-