Class BasePaymentMethod
java.lang.Object
sk.iway.iwcm.components.basket.payment_methods.rest.BasePaymentMethod
- Direct Known Subclasses:
CashOnDeliveryService
,GoPayService
,MoneyTransferService
Contain logic for payment methods. Once class extends this class and is annotated with PaymentMethod, it will be considered as payment method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
adminLogError
(Class<?> currentClass, String message, javax.servlet.http.HttpServletRequest request) protected String
adminLogError
(String message, javax.servlet.http.HttpServletRequest request) static Long
adminLogErrorLong
(Class<?> currentClass, String message, javax.servlet.http.HttpServletRequest request) protected Long
adminLogErrorLong
(String message, javax.servlet.http.HttpServletRequest request) static PaymentState
adminLogErrorState
(Class<?> currentClass, Long invoiceId, String message, javax.servlet.http.HttpServletRequest request) protected PaymentState
adminLogErrorState
(Long invoiceId, String message, javax.servlet.http.HttpServletRequest request) protected void
beforeSave
(PaymentMethodEntity paymentMethod, Prop prop) Before save abstract method, to allow user do before save control or changes.protected void
clearPaymentMethodConfiguration
(PaymentMethodRepository paymentMethodRepositor) Clear payment method configuration by removing configured payment method columns from DB.protected abstract RefundationState
doPaymentRefund
(BigDecimal refundAmount, BasketInvoicePaymentEntity paymentEntity, javax.servlet.http.HttpServletRequest request) Do refundation of payment.protected String
encryptKey
(String key) Return encrypted given key.protected PaymentMethodEntity
getPayment
(Long id, PaymentMethodRepository paymentMethodRepositor, ProcessItemAction action, Prop prop) Return prepared payment method, with set fields by annotation and status.protected abstract BasketInvoiceItemEntity
getPaymentMethodCost
(BasketInvoiceItemEntity entity, PaymentMethodEntity paymentMethod) Get payment method cost.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.protected abstract PaymentState
getPaymentState
(javax.servlet.http.HttpServletRequest request) Get payemnt state after payment is done.protected abstract boolean
isEditableByAdmin
(PaymentMethodEntity paymentMethod) protected final boolean
isPaymentMethodConfigured
(PaymentMethodEntity paymentMethod) Check if payment method is configured.protected final void
removeInvoicePayment
(Long paymentId) protected final Long
saveBasketInvoicePayment
(Long invoiceId, javax.servlet.http.HttpServletRequest request) protected PaymentMethodEntity
savePaymentMethod
(PaymentMethodEntity paymentMethod, PaymentMethodRepository paymentMethodRepositor, Prop prop) Save payment method.protected final void
setToMapIfConfigured
(PaymentMethodEntity paymentMethod, Map<String, String> paymentMethods, Prop prop) Set payment method to map paymentMethods - if it's configured.protected void
validateEditorValues
(PaymentMethodEntity paymentMethod, org.springframework.validation.Errors errors, Prop prop)
-
Field Details
-
MERCHANT_ID_TEXT
- See Also:
-
PRIVATE_KEY_TEXT
- See Also:
-
HASH_PRIVATE_KEY_TEXT
- See Also:
-
BANK_URL_TEXT
- See Also:
-
CONST_SYMBOL_TEXT
- See Also:
-
NOTIF_EMAIL_TEXT
- See Also:
-
ENABLE_TATRA_PAY_TEXT
- See Also:
-
ENABLE_CARD_PAY_TEXT
- See Also:
-
REFUNDATION_TITLE
- See Also:
-
REFUNDATION_SUCCESS
- See Also:
-
NON_REFUNDABLE_METHOD
- See Also:
-
REFUNDATION_FAILED
- See Also:
-
REFUNDATION_AMOUNT_TOO_HIGH
- See Also:
-
REFUNDATION_AMOUNT_TOO_LOW
- See Also:
-
NON_REFUNDABLE_PAYMENT
- See Also:
-
CANT_REFUND_NOT_CONFIRMED
- See Also:
-
CANT_REFUND_REFUNDATION
- See Also:
-
PAYMENT_METHOD_REPOSITORY
- See Also:
-
-
Constructor Details
-
BasePaymentMethod
public BasePaymentMethod()
-
-
Method Details
-
encryptKey
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
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
Before save abstract method, to allow user do before save control or changes.- Parameters:
paymentMethod
-prop
-
-
isPaymentMethodConfigured
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
-
adminLogError
-
adminLogErrorLong
-
adminLogErrorLong
-
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
-
removeInvoicePayment
-
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
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
-