Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.flipkart.affordability.bnpl.tijori.service.businesslogic.lender.kissht;
- import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.TransactionStatus;
- import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.CompleteTransactionResponse;
- import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.FetchTxnStatusResponse;
- import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.InitiateTransactionResponse;
- import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.KisshtBaseResponse;
- import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.PaybackForwardResponse;
- import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.RefundTransactionResponse;
- import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.UpgradeTransactionResponse;
- import com.flipkart.affordability.bnpl.tijori.service.externalclient.KisshtClientConfig;
- import com.flipkart.affordability.bnpl.tijori.service.util.IdGeneratorUtil;
- import com.google.inject.Inject;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import java.math.BigDecimal;
- /**
- * @author Pradyot H Adavi 09/08/18
- */
- public class KisshtMock {
- private final KisshtClientConfig kisshtClientConfig;
- private final Logger logger = LoggerFactory.getLogger(KisshtMock.class);
- @Inject
- public KisshtMock(KisshtClientConfig kisshtClientConfig) {
- this.kisshtClientConfig = kisshtClientConfig;
- }
- public InitiateTransactionResponse getInitiateTransactionResponse() {
- try {
- Thread.sleep(kisshtClientConfig.getInitiateTransactionPathLatency());
- } catch (InterruptedException e) {
- logger.error("Exception in getInitiateTransactionResponse : {}",e);
- }
- InitiateTransactionResponse initiateTransactionResponse = new InitiateTransactionResponse();
- initiateTransactionResponse.setSuccess(true);
- initiateTransactionResponse.setKisshtTxnId(IdGeneratorUtil.generateKisshtPerfTransactionId());
- initiateTransactionResponse.setSkipOtp(false);
- return initiateTransactionResponse;
- }
- public KisshtBaseResponse getValidateTransaction() {
- try {
- Thread.sleep(kisshtClientConfig.getValidateOtpPathLatency());
- } catch (InterruptedException e) {
- logger.error("Exception in getValidateTransaction : {}",e);
- }
- KisshtBaseResponse kisshtBaseResponse = new KisshtBaseResponse();
- kisshtBaseResponse.setSuccess(true);
- return kisshtBaseResponse;
- }
- public CompleteTransactionResponse getCompleteTransaction() {
- try {
- Thread.sleep(kisshtClientConfig.getCompleteTxnPathLatency());
- } catch (InterruptedException e) {
- logger.error("Exception in getCompleteTransaction : {}",e);
- }
- CompleteTransactionResponse completeTransactionResponse = new CompleteTransactionResponse();
- completeTransactionResponse.setSuccess(true);
- completeTransactionResponse.setAvailableLimit(new BigDecimal(10000));
- return completeTransactionResponse;
- }
- public RefundTransactionResponse getRefundTransaction() {
- try {
- Thread.sleep(kisshtClientConfig.getRefundTxnPathLatency());
- } catch (InterruptedException e) {
- logger.error("Exception in getRefundTransaction : {}",e);
- }
- RefundTransactionResponse refundTransactionResponse = new RefundTransactionResponse();
- refundTransactionResponse.setSuccess(true);
- refundTransactionResponse.setKisshtTransactionId(IdGeneratorUtil.generateKisshtPerfTransactionId());
- refundTransactionResponse.setAvailableLimit(new BigDecimal(10000));
- return refundTransactionResponse;
- }
- public PaybackForwardResponse getBillPayment() {
- try {
- Thread.sleep(kisshtClientConfig.getBillPaymentPathLatency());
- } catch (InterruptedException e) {
- logger.error("Exception in getBillPayment : {}",e);
- }
- PaybackForwardResponse paybackForwardResponse = new PaybackForwardResponse();
- paybackForwardResponse.setSuccess(true);
- paybackForwardResponse.setAvailableLimit(new BigDecimal(10000));
- paybackForwardResponse.setPaymentReferenceNum(IdGeneratorUtil.generateKisshtPerfTransactionId());
- return paybackForwardResponse;
- }
- public KisshtBaseResponse getSkipOtpValidationTransaction() {
- try {
- Thread.sleep(kisshtClientConfig.getSendOtpPathLatency());
- } catch (InterruptedException e) {
- logger.error("Exception in getSkipOtpValidationTransaction : {}",e);
- }
- KisshtBaseResponse kisshtBaseResponse = new KisshtBaseResponse();
- kisshtBaseResponse.setSuccess(true);
- return kisshtBaseResponse;
- }
- public KisshtBaseResponse getSendOtp() {
- try {
- Thread.sleep(kisshtClientConfig.getSendOtpPathLatency());
- } catch (InterruptedException e) {
- logger.error("Exception in getSendOtp : {}",e);
- }
- KisshtBaseResponse kisshtBaseResponse = new KisshtBaseResponse();
- kisshtBaseResponse.setSuccess(true);
- return kisshtBaseResponse;
- }
- public UpgradeTransactionResponse getUpgradeTransaction() {
- try {
- Thread.sleep(kisshtClientConfig.getBnplToEfaUpgradePathLatency());
- } catch (InterruptedException e) {
- logger.error("Exception in getUpgradeTransaction : {}",e);
- }
- UpgradeTransactionResponse upgradeTransactionResponse = new UpgradeTransactionResponse();
- upgradeTransactionResponse.setSuccess(true);
- upgradeTransactionResponse.setAvailableLimit(new BigDecimal(50000.5));
- upgradeTransactionResponse.setKisshtTxnId(IdGeneratorUtil.generateKisshtPerfTransactionId());
- return upgradeTransactionResponse;
- }
- public FetchTxnStatusResponse getTxnStatus() {
- try {
- Thread.sleep(kisshtClientConfig.getFetchTransactionPathLatency());
- } catch (InterruptedException e) {
- logger.error("Exception in fetchTransactionStatus : {}",e);
- }
- FetchTxnStatusResponse fetchTxnStatusResponse = new FetchTxnStatusResponse();
- fetchTxnStatusResponse.setSuccess(true);
- fetchTxnStatusResponse.setTransactionStatus(TransactionStatus.FINAL_APPROVED);
- fetchTxnStatusResponse.setKisshtTxnId(IdGeneratorUtil.generateKisshtPerfTransactionId());
- return fetchTxnStatusResponse;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement