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 Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringadminLogError(Class<?> currentClass, String message, javax.servlet.http.HttpServletRequest request) protected StringadminLogError(String message, javax.servlet.http.HttpServletRequest request) static LongadminLogErrorLong(Class<?> currentClass, String message, javax.servlet.http.HttpServletRequest request) protected LongadminLogErrorLong(String message, javax.servlet.http.HttpServletRequest request) static PaymentStateadminLogErrorState(Class<?> currentClass, Long invoiceId, String message, javax.servlet.http.HttpServletRequest request) protected PaymentStateadminLogErrorState(Long invoiceId, String message, javax.servlet.http.HttpServletRequest request) protected voidbeforeSave(PaymentMethodEntity paymentMethod, Prop prop) Before save abstract method, to allow user do before save control or changes.protected voidclearPaymentMethodConfiguration(PaymentMethodRepository paymentMethodRepositor) Clear payment method configuration by removing configured payment method columns from DB.protected abstract RefundationStatedoPaymentRefund(BigDecimal refundAmount, BasketInvoicePaymentEntity paymentEntity, javax.servlet.http.HttpServletRequest request) Do refundation of payment.protected StringencryptKey(String key) Return encrypted given key.protected PaymentMethodEntitygetPayment(Long id, PaymentMethodRepository paymentMethodRepositor, ProcessItemAction action, Prop prop) Return prepared payment method, with set fields by annotation and status.protected abstract BasketInvoiceItemEntitygetPaymentMethodCost(BasketInvoiceItemEntity entity, PaymentMethodEntity paymentMethod) Get payment method cost.protected abstract StringgetPaymentResponse(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 PaymentStategetPaymentState(javax.servlet.http.HttpServletRequest request) Get payemnt state after payment is done.protected abstract booleanisEditableByAdmin(PaymentMethodEntity paymentMethod) protected final booleanisPaymentMethodConfigured(PaymentMethodEntity paymentMethod) Check if payment method is configured.protected final voidremoveInvoicePayment(Long paymentId) protected final LongsaveBasketInvoicePayment(Long invoiceId, javax.servlet.http.HttpServletRequest request) protected PaymentMethodEntitysavePaymentMethod(PaymentMethodEntity paymentMethod, PaymentMethodRepository paymentMethodRepositor, Prop prop) Save payment method.protected final voidsetToMapIfConfigured(PaymentMethodEntity paymentMethod, Map<String, String> paymentMethods, Prop prop) Set payment method to map paymentMethods - if it's configured.protected voidvalidateEditorValues(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
-