Class DefaultCheckoutComTransactionLookupService
java.lang.Object
com.broadleafcommerce.payment.service.gateway.DefaultCheckoutComTransactionLookupService
- All Implemented Interfaces:
CheckoutComTransactionLookupService,com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionLookupService,com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
public class DefaultCheckoutComTransactionLookupService
extends Object
implements CheckoutComTransactionLookupService
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCheckoutComTransactionLookupService(CheckoutApiInitService checkoutApiInitService, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.paymentgateway.domain.PaymentResponsebuildPaymentResponse(@NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse, @NonNull com.checkout.CheckoutApi api) Builds aPaymentResponsebased on the givenGetPaymentResponse.protected StringbuildRawResponse(@NonNull com.checkout.common.Resource resource) protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifierbuildTransactionIdentifier(@NonNull com.checkout.payments.response.GetPaymentResponse getPaymentResponse) Builds aTransactionIdentifierbased on the givenGetPaymentResponse.protected javax.money.MonetaryAmountgetAmountInMajorUnits(@NonNull Long amount, @NonNull String currencyCode) protected CheckoutApiInitServiceprotected StringgetCheckoutPaymentId(@NonNull com.broadleafcommerce.paymentgateway.domain.TransactionLookupRequest transactionLookupRequest) Gets the id of the Checkout.com payment from the givenTransactionLookupRequest.getStringValue(com.checkout.payments.response.source.AlternativePaymentSourceResponse response, String key) protected StringgetTenantId(@NonNull com.checkout.payments.response.GetPaymentResponse getPaymentResponse) Gets the tenant id from the givenGetPaymentResponse.getMetadata().org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> getTransactionDetails(@NonNull Map<String, String> requestParams, String tenantId, String applicationId) protected com.broadleafcommerce.common.extension.TypeFactoryprotected booleanisKnetPayment(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Determines if the payment type is KNET for the givenPaymentResponse.protected booleanisKnetPayment(@NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse) Determines if the payment type is KNET for the givenResponseSource.protected booleanknetTransactionResultsAreAvailable(@NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse) Determines if the KNET transaction results are available for the givenResponseSource.com.broadleafcommerce.paymentgateway.domain.PaymentResponselookupTransactionDetails(@NonNull com.broadleafcommerce.paymentgateway.domain.TransactionLookupRequest transactionLookupRequest, String tenantId, String applicationId) protected com.broadleafcommerce.paymentgateway.domain.PaymentResponsepopulate3DSData(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull com.checkout.payments.ThreeDSData threeDSData) Populates the 3DS data for the givenPaymentResponse.protected com.broadleafcommerce.paymentgateway.domain.PaymentResponsepopulateActionData(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull com.checkout.payments.response.GetPaymentResponse checkoutComPayment, @NonNull com.checkout.CheckoutApi api) Identifies a Checkout.comPaymentActionusing thePaymentResponse.getTransactionReferenceId()& adds data from thePaymentActionto thePaymentResponse.protected com.broadleafcommerce.paymentgateway.domain.PaymentResponsepopulatePaymentResponseForKNET(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse) Populates the KNET data for the givenPaymentResponse.protected voidpopulateTransactionTypeIfPossible(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull com.checkout.payments.PaymentAction paymentAction) Populates thePaymentResponse.getTransactionType()with the givenPaymentActionif possible.protected booleantransactionResultsAreAvailable(@NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse) Determines if the 3DS transaction results are available for the givenGetPaymentResponse.voidvalidateRequestParams(@NonNull Map<String, String> requestParams, String tenantId, String applicationId) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionLookupService
validateRequestParams
-
Constructor Details
-
DefaultCheckoutComTransactionLookupService
public DefaultCheckoutComTransactionLookupService(CheckoutApiInitService checkoutApiInitService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
validateRequestParams
public void validateRequestParams(@NonNull @NonNull Map<String, String> requestParams, @Nullable String tenantId, @Nullable String applicationId) - Specified by:
validateRequestParamsin interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionLookupService
-
getTransactionDetails
public org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> getTransactionDetails(@NonNull @NonNull Map<String, String> requestParams, @Nullable String tenantId, @Nullable String applicationId) - Specified by:
getTransactionDetailsin interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionLookupService
-
lookupTransactionDetails
public com.broadleafcommerce.paymentgateway.domain.PaymentResponse lookupTransactionDetails(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.TransactionLookupRequest transactionLookupRequest, @Nullable String tenantId, @Nullable String applicationId) - Specified by:
lookupTransactionDetailsin interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayTransactionLookupService
-
isKnetPayment
protected boolean isKnetPayment(@NonNull @NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse) Determines if the payment type is KNET for the givenResponseSource.- Parameters:
checkoutPaymentResponse- theResponseSourceto check the payment type- Returns:
- true if the payment type is KNET for the given
ResponseSource, otherwise false
-
knetTransactionResultsAreAvailable
protected boolean knetTransactionResultsAreAvailable(@NonNull @NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse) Determines if the KNET transaction results are available for the givenResponseSource.- Parameters:
checkoutPaymentResponse- theResponseSourceto determine if the knet transaction results are available- Returns:
- true if the knet transaction results are available for the given
ResponseSource, otherwise false
-
transactionResultsAreAvailable
protected boolean transactionResultsAreAvailable(@NonNull @NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse) Determines if the 3DS transaction results are available for the givenGetPaymentResponse.- Parameters:
checkoutPaymentResponse- theGetPaymentResponseto determine if the 3DS transaction results are available- Returns:
- true if the 3DS transaction results are available for the given
GetPaymentResponse, otherwise false
-
buildTransactionIdentifier
protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier buildTransactionIdentifier(@NonNull @NonNull com.checkout.payments.response.GetPaymentResponse getPaymentResponse) Builds aTransactionIdentifierbased on the givenGetPaymentResponse.- Parameters:
getPaymentResponse- theGetPaymentResponseto build theTransactionIdentifierfrom- Returns:
- a
TransactionIdentifierbased on the givenGetPaymentResponse
-
getTenantId
protected String getTenantId(@NonNull @NonNull com.checkout.payments.response.GetPaymentResponse getPaymentResponse) Gets the tenant id from the givenGetPaymentResponse.getMetadata().- Parameters:
getPaymentResponse- theGetPaymentResponseto get the tenant id from- Returns:
- the tenant id from the given
GetPaymentResponse.getMetadata()
-
buildPaymentResponse
protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse buildPaymentResponse(@NonNull @NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse, @NonNull @NonNull com.checkout.CheckoutApi api) Builds aPaymentResponsebased on the givenGetPaymentResponse.- Parameters:
checkoutPaymentResponse- theGetPaymentResponseto build thePaymentResponsefromapi- theCheckoutApiused to gather the latest action data for theGetPaymentResponsewith- Returns:
- a
PaymentResponsebased on the givenGetPaymentResponse
-
buildRawResponse
-
populatePaymentResponseForKNET
protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse populatePaymentResponseForKNET(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse) Populates the KNET data for the givenPaymentResponse.- Parameters:
paymentResponse- thePaymentResponseto populate the KNET data forcheckoutPaymentResponse- theResponseSourceto populate the KNET data from- Returns:
- the
PaymentResponsewith the populated KNET data
-
getStringValue
-
getAmountInMajorUnits
protected javax.money.MonetaryAmount getAmountInMajorUnits(@NonNull @NonNull Long amount, @NonNull @NonNull String currencyCode) - Parameters:
amount- the amount to convert toMonetaryAmountin major units fromcurrencyCode- the currency code of theMonetaryAmount- Returns:
- the
MonetaryAmountin major units from the givenamountandcurrencyCode - See Also:
-
Money.ofMinor(CurrencyUnit, long)
-
populate3DSData
protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse populate3DSData(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull com.checkout.payments.ThreeDSData threeDSData) Populates the 3DS data for the givenPaymentResponse.- Parameters:
paymentResponse- thePaymentResponseto populate the 3DS data forthreeDSData- theThreeDSDatato populate the 3DS data from- Returns:
- the
PaymentResponsewith the populated 3DS data
-
populateActionData
protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse populateActionData(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull com.checkout.payments.response.GetPaymentResponse checkoutComPayment, @NonNull @NonNull com.checkout.CheckoutApi api) Identifies a Checkout.comPaymentActionusing thePaymentResponse.getTransactionReferenceId()& adds data from thePaymentActionto thePaymentResponse.- Parameters:
paymentResponse- thePaymentResponseto populate the action data forcheckoutComPayment- theGetPaymentResponsecorrelates to the Checkout.com paymentapi- theCheckoutApito get the payment actions from- Returns:
- the
PaymentResponsewith the payment action data included
-
populateTransactionTypeIfPossible
protected void populateTransactionTypeIfPossible(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull com.checkout.payments.PaymentAction paymentAction) Populates thePaymentResponse.getTransactionType()with the givenPaymentActionif possible.- Parameters:
paymentResponse- thePaymentResponseto populate the transaction type forpaymentAction- thePaymentActionto populate the transaction type from. This is typically the latest payment action
-
isKnetPayment
protected boolean isKnetPayment(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Determines if the payment type is KNET for the givenPaymentResponse.- Parameters:
paymentResponse- thePaymentResponseto check against- Returns:
- true if the payment type is KNET for the given
PaymentResponse, otherwise false
-
getCheckoutPaymentId
@Nullable protected String getCheckoutPaymentId(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.TransactionLookupRequest transactionLookupRequest) Gets the id of the Checkout.com payment from the givenTransactionLookupRequest.Note that this is not the id of the Broadleaf payment.
- Parameters:
transactionLookupRequest- theTransactionLookupRequestto get the Checkout.com payment id from- Returns:
- the id of the Checkout.com payment from the given
TransactionLookupRequest
-
getGatewayType
- Specified by:
getGatewayTypein interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
-
getCheckoutApiInitService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-