Class BasePaymentMethod

java.lang.Object
sk.iway.iwcm.components.basket.payment_methods.rest.BasePaymentMethod
Direct Known Subclasses:
CashOnDeliveryService, GoPayService, MoneyTransferService

public abstract class BasePaymentMethod extends Object
Contain logic for payment methods. Once class extends this class and is annotated with PaymentMethod, it will be considered as payment method.
  • Field Details

  • Constructor Details

    • BasePaymentMethod

      public BasePaymentMethod()
  • Method Details

    • encryptKey

      protected String encryptKey(String key)
      Return encrypted given key.
      Parameters:
      key -
      Returns:
    • getPayment

      protected PaymentMethodEntity getPayment(Long id, PaymentMethodRepository paymentMethodRepositor, ProcessItemAction action, Prop prop)
      Return prepared payment method, with set fields by annotation and status.
      Parameters:
      id -
      paymentMethodRepositor -
      action -
      prop -
      Returns:
    • savePaymentMethod

      protected PaymentMethodEntity savePaymentMethod(PaymentMethodEntity paymentMethod, PaymentMethodRepository paymentMethodRepositor, Prop prop)
      Save payment method. If required fields by annotation are not set, it will not be saved.
      Parameters:
      paymentMethod -
      paymentMethodRepositor -
      prop -
      Returns:
    • clearPaymentMethodConfiguration

      protected void clearPaymentMethodConfiguration(PaymentMethodRepository paymentMethodRepositor)
      Clear payment method configuration by removing configured payment method columns from DB.
    • validateEditorValues

      protected void validateEditorValues(PaymentMethodEntity paymentMethod, org.springframework.validation.Errors errors, Prop prop)
    • beforeSave

      protected void beforeSave(PaymentMethodEntity paymentMethod, Prop prop)
      Before save abstract method, to allow user do before save control or changes.
      Parameters:
      paymentMethod -
      prop -
    • isPaymentMethodConfigured

      protected final boolean isPaymentMethodConfigured(PaymentMethodEntity paymentMethod)
      Check if payment method is configured. Need to in DB and have all required fields set.
      Parameters:
      paymentMethodeed -
      Returns:
    • setToMapIfConfigured

      protected final void setToMapIfConfigured(PaymentMethodEntity paymentMethod, Map<String,String> paymentMethods, Prop prop)
      Set payment method to map paymentMethods - if it's configured.
      Parameters:
      paymentMethod -
      paymentMethods -
      prop -
    • adminLogError

      protected String adminLogError(String message, javax.servlet.http.HttpServletRequest request)
    • adminLogError

      public static String adminLogError(Class<?> currentClass, String message, javax.servlet.http.HttpServletRequest request)
    • adminLogErrorLong

      protected Long adminLogErrorLong(String message, javax.servlet.http.HttpServletRequest request)
    • adminLogErrorLong

      public static Long adminLogErrorLong(Class<?> currentClass, String message, javax.servlet.http.HttpServletRequest request)
    • adminLogErrorState

      protected PaymentState adminLogErrorState(Long invoiceId, String message, javax.servlet.http.HttpServletRequest request)
    • adminLogErrorState

      public static PaymentState adminLogErrorState(Class<?> currentClass, Long invoiceId, String message, javax.servlet.http.HttpServletRequest request)
    • saveBasketInvoicePayment

      protected final Long saveBasketInvoicePayment(Long invoiceId, javax.servlet.http.HttpServletRequest request)
    • removeInvoicePayment

      protected final void removeInvoicePayment(Long paymentId)
    • getPaymentResponse

      protected abstract String getPaymentResponse(Long invoiceId, String returnUrl, javax.servlet.http.HttpServletRequest request)
      Prepare payment method and return some response to user LIKE payment instructions OR button to redirect to payment gateway.
      Parameters:
      invoiceId -
      returnUrl -
      request -
      Returns:
    • getPaymentState

      protected abstract PaymentState getPaymentState(javax.servlet.http.HttpServletRequest request)
      Get payemnt state after payment is done. Called right after user payed for order.
      Parameters:
      request -
      Returns:
    • doPaymentRefund

      protected abstract RefundationState doPaymentRefund(BigDecimal refundAmount, BasketInvoicePaymentEntity paymentEntity, javax.servlet.http.HttpServletRequest request)
      Do refundation of payment. This payment can be partial or full. Returned RefundationState will contain status of refundation with some message if needed.
      Parameters:
      refundAmount -
      paymentEntity -
      request -
      Returns:
    • getPaymentMethodCost

      protected abstract BasketInvoiceItemEntity getPaymentMethodCost(BasketInvoiceItemEntity entity, PaymentMethodEntity paymentMethod)
      Get payment method cost. This method will set item price, quantity and VAT.
      Parameters:
      entity -
      paymentMethod -
      Returns:
    • isEditableByAdmin

      protected abstract boolean isEditableByAdmin(PaymentMethodEntity paymentMethod)