Class AbstractRequestResponseTransformer

java.lang.Object
com.broadleafcommerce.myfatoorah.service.requestresponse.AbstractRequestResponseTransformer
All Implemented Interfaces:
RequestResponseTransformer
Direct Known Subclasses:
MyFatoorahAuthorizeAndCaptureRequestResponseTransformer, MyFatoorahAuthorizeRequestResponseTransformer, MyFatoorahCaptureRequestResponseTransformer, MyFatoorahRefundRequestResponseTransformer, MyFatoorahReverseAuthorizeRequestResponseTransformer

public abstract class AbstractRequestResponseTransformer extends Object implements RequestResponseTransformer
An abstract class that creates the MyFatoorah request and populates the response with the common parameters.
Author:
Dima Myroniuk (dmyroniuk)
  • Constructor Details

    • AbstractRequestResponseTransformer

      protected AbstractRequestResponseTransformer(MyFatoorahConfigurationProperties configProperties, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • createMyFatoorahRequest

      public Map<String,Object> createMyFatoorahRequest(@NonNull @NonNull MyFatoorahPaymentRequest myFatoorahPaymentRequest)
      Description copied from interface: RequestResponseTransformer
      Creates the MyFatoorah request body based on MyFatoorahPaymentRequest.
      Specified by:
      createMyFatoorahRequest in interface RequestResponseTransformer
      Parameters:
      myFatoorahPaymentRequest - the myFatoorah payment request
      Returns:
      the MyFatoorah request body
    • populatePaymentResponse

      public com.broadleafcommerce.paymentgateway.domain.PaymentResponse populatePaymentResponse(@NonNull @NonNull MyFatoorahPaymentRequest myFatoorahPaymentRequest, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull MyFatoorahResponse myFatoorahResponse)
      Description copied from interface: RequestResponseTransformer
      Populates the payment response based on the response from the MyFatoorah API.
      Specified by:
      populatePaymentResponse in interface RequestResponseTransformer
      Parameters:
      myFatoorahPaymentRequest - the myFatoorah payment request
      paymentResponse - the payment response to populate
      myFatoorahResponse - the response from MyFatoorah API
      Returns:
      the populated payment response
    • identifyLatestTransaction

      protected MyFatoorahResponse.InvoiceTransaction identifyLatestTransaction(@NonNull @NonNull MyFatoorahResponse myFatoorahResponse)
    • getGatewayResponseCode

      protected String getGatewayResponseCode(MyFatoorahResponse.InvoiceTransaction invoiceTransaction)
    • identifyFailureType

      protected String identifyFailureType(String reasonCode, String transactionReferenceId)
    • getCurrencyCode

      @Nullable protected String getCurrencyCode(String currencyDisplayValue)
    • getTransactionAmount

      @Nullable protected javax.money.MonetaryAmount getTransactionAmount(@NonNull MyFatoorahResponse.InvoiceTransaction transaction, @NonNull @NonNull String currencyCode)
    • getInvoiceAmount

      protected javax.money.MonetaryAmount getInvoiceAmount(@NonNull MyFatoorahResponse.Data data, @NonNull @NonNull String currencyCode)
    • putIfNotBlank

      protected void putIfNotBlank(@NonNull @NonNull Map<String,String> map, @NonNull @NonNull String key, @Nullable String value)
    • getPhoneNumber

      @Nullable protected String getPhoneNumber(@NonNull @NonNull MyFatoorahPaymentRequest myFatoorahPaymentRequest)
      Gets the phone number from the customer or from the billing address and removes the phone number format. For example, if the phone number is "+(965)900-000-01" this method will return "96590000001".
    • getConfigProperties

      protected MyFatoorahConfigurationProperties getConfigProperties()
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()