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

    Constructors
    Constructor
    Description
    DefaultCheckoutComTransactionLookupService(CheckoutApiInitService checkoutApiInitService, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse
    buildPaymentResponse(@NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse, @NonNull com.checkout.CheckoutApi api)
    Builds a PaymentResponse based on the given GetPaymentResponse.
    protected String
    buildRawResponse(@NonNull com.checkout.common.Resource resource)
     
    protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier
    buildTransactionIdentifier(@NonNull com.checkout.payments.response.GetPaymentResponse getPaymentResponse)
    Builds a TransactionIdentifier based on the given GetPaymentResponse.
    protected javax.money.MonetaryAmount
    getAmountInMajorUnits(@NonNull Long amount, @NonNull String currencyCode)
    Gets the MonetaryAmount in major units from the given amount and currencyCode.
     
    protected String
    getCheckoutPaymentId(@NonNull com.broadleafcommerce.paymentgateway.domain.TransactionLookupRequest transactionLookupRequest)
    Gets the id of the Checkout.com payment from the given TransactionLookupRequest.
     
    protected Optional<String>
    getStringValue(com.checkout.payments.response.source.AlternativePaymentSourceResponse response, String key)
     
    protected String
    getTenantId(@NonNull com.checkout.payments.response.GetPaymentResponse getPaymentResponse)
    Gets the tenant id from the given GetPaymentResponse.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.TypeFactory
     
    protected boolean
    isKnetPayment(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse)
    Determines if the payment type is KNET for the given PaymentResponse.
    protected boolean
    isKnetPayment(@NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse)
    Determines if the payment type is KNET for the given ResponseSource.
    protected boolean
    knetTransactionResultsAreAvailable(@NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse)
    Determines if the KNET transaction results are available for the given ResponseSource.
    com.broadleafcommerce.paymentgateway.domain.PaymentResponse
    lookupTransactionDetails(@NonNull com.broadleafcommerce.paymentgateway.domain.TransactionLookupRequest transactionLookupRequest, String tenantId, String applicationId)
     
    protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse
    populate3DSData(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull com.checkout.payments.ThreeDSData threeDSData)
    Populates the 3DS data for the given PaymentResponse.
    protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse
    populateActionData(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull com.checkout.payments.response.GetPaymentResponse checkoutComPayment, @NonNull com.checkout.CheckoutApi api)
    Identifies a Checkout.com PaymentAction using the PaymentResponse.getTransactionReferenceId() & adds data from the PaymentAction to the PaymentResponse.
    protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse
    populatePaymentResponseForKNET(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse)
    Populates the KNET data for the given PaymentResponse.
    protected void
    populateTransactionTypeIfPossible(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull com.checkout.payments.PaymentAction paymentAction)
    Populates the PaymentResponse.getTransactionType() with the given PaymentAction if possible.
    protected boolean
    transactionResultsAreAvailable(@NonNull com.checkout.payments.response.GetPaymentResponse checkoutPaymentResponse)
    Determines if the 3DS transaction results are available for the given GetPaymentResponse.
    void
    validateRequestParams(@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, wait

    Methods 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:
      validateRequestParams in interface com.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:
      getTransactionDetails in interface com.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:
      lookupTransactionDetails in interface com.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 given ResponseSource.
      Parameters:
      checkoutPaymentResponse - the ResponseSource to 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 given ResponseSource.
      Parameters:
      checkoutPaymentResponse - the ResponseSource to 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 given GetPaymentResponse.
      Parameters:
      checkoutPaymentResponse - the GetPaymentResponse to 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 a TransactionIdentifier based on the given GetPaymentResponse.
      Parameters:
      getPaymentResponse - the GetPaymentResponse to build the TransactionIdentifier from
      Returns:
      a TransactionIdentifier based on the given GetPaymentResponse
    • getTenantId

      protected String getTenantId(@NonNull @NonNull com.checkout.payments.response.GetPaymentResponse getPaymentResponse)
      Gets the tenant id from the given GetPaymentResponse.getMetadata().
      Parameters:
      getPaymentResponse - the GetPaymentResponse to 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 a PaymentResponse based on the given GetPaymentResponse.
      Parameters:
      checkoutPaymentResponse - the GetPaymentResponse to build the PaymentResponse from
      api - the CheckoutApi used to gather the latest action data for the GetPaymentResponse with
      Returns:
      a PaymentResponse based on the given GetPaymentResponse
    • buildRawResponse

      protected String buildRawResponse(@NonNull @NonNull com.checkout.common.Resource resource)
    • 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 given PaymentResponse.
      Parameters:
      paymentResponse - the PaymentResponse to populate the KNET data for
      checkoutPaymentResponse - the ResponseSource to populate the KNET data from
      Returns:
      the PaymentResponse with the populated KNET data
    • getStringValue

      protected Optional<String> getStringValue(com.checkout.payments.response.source.AlternativePaymentSourceResponse response, String key)
    • getAmountInMajorUnits

      protected javax.money.MonetaryAmount getAmountInMajorUnits(@NonNull @NonNull Long amount, @NonNull @NonNull String currencyCode)
      Gets the MonetaryAmount in major units from the given amount and currencyCode.
      Parameters:
      amount - the amount to convert to MonetaryAmount in major units from
      currencyCode - the currency code of the MonetaryAmount
      Returns:
      the MonetaryAmount in major units from the given amount and currencyCode
      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 given PaymentResponse.
      Parameters:
      paymentResponse - the PaymentResponse to populate the 3DS data for
      threeDSData - the ThreeDSData to populate the 3DS data from
      Returns:
      the PaymentResponse with 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.com PaymentAction using the PaymentResponse.getTransactionReferenceId() & adds data from the PaymentAction to the PaymentResponse.
      Parameters:
      paymentResponse - the PaymentResponse to populate the action data for
      checkoutComPayment - the GetPaymentResponse correlates to the Checkout.com payment
      api - the CheckoutApi to get the payment actions from
      Returns:
      the PaymentResponse with 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 the PaymentResponse.getTransactionType() with the given PaymentAction if possible.
      Parameters:
      paymentResponse - the PaymentResponse to populate the transaction type for
      paymentAction - the PaymentAction to 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 given PaymentResponse.
      Parameters:
      paymentResponse - the PaymentResponse to 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 given TransactionLookupRequest.

      Note that this is not the id of the Broadleaf payment.

      Parameters:
      transactionLookupRequest - the TransactionLookupRequest to get the Checkout.com payment id from
      Returns:
      the id of the Checkout.com payment from the given TransactionLookupRequest
    • getGatewayType

      public String getGatewayType()
      Specified by:
      getGatewayType in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
    • getCheckoutApiInitService

      protected CheckoutApiInitService getCheckoutApiInitService()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()