SHARE
TWEET

Untitled

a guest Jul 16th, 2019 248 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.flipkart.affordability.bnpl.tijori.service.businesslogic.lender.kissht;
  2.  
  3. import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.TransactionStatus;
  4. import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.CompleteTransactionResponse;
  5. import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.FetchTxnStatusResponse;
  6. import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.InitiateTransactionResponse;
  7. import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.KisshtBaseResponse;
  8. import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.PaybackForwardResponse;
  9. import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.RefundTransactionResponse;
  10. import com.flipkart.affordability.bnpl.tijori.service.external.model.kissht.response.UpgradeTransactionResponse;
  11. import com.flipkart.affordability.bnpl.tijori.service.externalclient.KisshtClientConfig;
  12. import com.flipkart.affordability.bnpl.tijori.service.util.IdGeneratorUtil;
  13. import com.google.inject.Inject;
  14. import org.slf4j.Logger;
  15. import org.slf4j.LoggerFactory;
  16.  
  17. import java.math.BigDecimal;
  18.  
  19. /**
  20.  * @author Pradyot H Adavi 09/08/18
  21.  */
  22. public class KisshtMock {
  23.    
  24.     private final KisshtClientConfig kisshtClientConfig;
  25.    
  26.     private final Logger logger = LoggerFactory.getLogger(KisshtMock.class);
  27.    
  28.     @Inject
  29.     public KisshtMock(KisshtClientConfig kisshtClientConfig) {
  30.         this.kisshtClientConfig = kisshtClientConfig;
  31.     }
  32.    
  33.     public InitiateTransactionResponse getInitiateTransactionResponse() {
  34.        
  35.         try {
  36.             Thread.sleep(kisshtClientConfig.getInitiateTransactionPathLatency());
  37.         } catch (InterruptedException e) {
  38.             logger.error("Exception in getInitiateTransactionResponse : {}",e);
  39.         }
  40.         InitiateTransactionResponse initiateTransactionResponse = new InitiateTransactionResponse();
  41.         initiateTransactionResponse.setSuccess(true);
  42.         initiateTransactionResponse.setKisshtTxnId(IdGeneratorUtil.generateKisshtPerfTransactionId());
  43.         initiateTransactionResponse.setSkipOtp(false);
  44.         return initiateTransactionResponse;
  45.     }
  46.    
  47.     public KisshtBaseResponse getValidateTransaction() {
  48.        
  49.         try {
  50.             Thread.sleep(kisshtClientConfig.getValidateOtpPathLatency());
  51.         } catch (InterruptedException e) {
  52.             logger.error("Exception in getValidateTransaction : {}",e);
  53.         }
  54.         KisshtBaseResponse kisshtBaseResponse = new KisshtBaseResponse();
  55.         kisshtBaseResponse.setSuccess(true);
  56.         return kisshtBaseResponse;
  57.     }
  58.    
  59.     public CompleteTransactionResponse getCompleteTransaction() {
  60.        
  61.         try {
  62.             Thread.sleep(kisshtClientConfig.getCompleteTxnPathLatency());
  63.         } catch (InterruptedException e) {
  64.             logger.error("Exception in getCompleteTransaction : {}",e);
  65.         }
  66.         CompleteTransactionResponse completeTransactionResponse = new CompleteTransactionResponse();
  67.         completeTransactionResponse.setSuccess(true);
  68.         completeTransactionResponse.setAvailableLimit(new BigDecimal(10000));
  69.         return completeTransactionResponse;
  70.     }
  71.    
  72.     public RefundTransactionResponse getRefundTransaction() {
  73.        
  74.         try {
  75.             Thread.sleep(kisshtClientConfig.getRefundTxnPathLatency());
  76.         } catch (InterruptedException e) {
  77.             logger.error("Exception in getRefundTransaction : {}",e);
  78.         }
  79.         RefundTransactionResponse refundTransactionResponse = new RefundTransactionResponse();
  80.         refundTransactionResponse.setSuccess(true);
  81.         refundTransactionResponse.setKisshtTransactionId(IdGeneratorUtil.generateKisshtPerfTransactionId());
  82.         refundTransactionResponse.setAvailableLimit(new BigDecimal(10000));
  83.         return refundTransactionResponse;
  84.     }
  85.    
  86.     public PaybackForwardResponse getBillPayment() {
  87.        
  88.         try {
  89.             Thread.sleep(kisshtClientConfig.getBillPaymentPathLatency());
  90.         } catch (InterruptedException e) {
  91.             logger.error("Exception in getBillPayment : {}",e);
  92.         }
  93.         PaybackForwardResponse paybackForwardResponse = new PaybackForwardResponse();
  94.         paybackForwardResponse.setSuccess(true);
  95.         paybackForwardResponse.setAvailableLimit(new BigDecimal(10000));
  96.         paybackForwardResponse.setPaymentReferenceNum(IdGeneratorUtil.generateKisshtPerfTransactionId());
  97.         return paybackForwardResponse;
  98.     }
  99.    
  100.     public KisshtBaseResponse getSkipOtpValidationTransaction() {
  101.        
  102.         try {
  103.             Thread.sleep(kisshtClientConfig.getSendOtpPathLatency());
  104.         } catch (InterruptedException e) {
  105.             logger.error("Exception in getSkipOtpValidationTransaction : {}",e);
  106.         }
  107.         KisshtBaseResponse kisshtBaseResponse = new KisshtBaseResponse();
  108.         kisshtBaseResponse.setSuccess(true);
  109.         return kisshtBaseResponse;
  110.     }
  111.    
  112.     public KisshtBaseResponse getSendOtp() {
  113.        
  114.         try {
  115.             Thread.sleep(kisshtClientConfig.getSendOtpPathLatency());
  116.         } catch (InterruptedException e) {
  117.             logger.error("Exception in getSendOtp : {}",e);
  118.         }
  119.         KisshtBaseResponse kisshtBaseResponse = new KisshtBaseResponse();
  120.         kisshtBaseResponse.setSuccess(true);
  121.         return kisshtBaseResponse;
  122.     }
  123.  
  124.     public UpgradeTransactionResponse getUpgradeTransaction() {
  125.        
  126.         try {
  127.             Thread.sleep(kisshtClientConfig.getBnplToEfaUpgradePathLatency());
  128.         } catch (InterruptedException e) {
  129.             logger.error("Exception in getUpgradeTransaction : {}",e);
  130.         }
  131.         UpgradeTransactionResponse upgradeTransactionResponse = new UpgradeTransactionResponse();
  132.         upgradeTransactionResponse.setSuccess(true);
  133.         upgradeTransactionResponse.setAvailableLimit(new BigDecimal(50000.5));
  134.         upgradeTransactionResponse.setKisshtTxnId(IdGeneratorUtil.generateKisshtPerfTransactionId());
  135.         return upgradeTransactionResponse;
  136.     }
  137.  
  138.     public FetchTxnStatusResponse getTxnStatus() {
  139.         try {
  140.             Thread.sleep(kisshtClientConfig.getFetchTransactionPathLatency());
  141.         } catch (InterruptedException e) {
  142.             logger.error("Exception in fetchTransactionStatus : {}",e);
  143.         }
  144.         FetchTxnStatusResponse fetchTxnStatusResponse = new FetchTxnStatusResponse();
  145.         fetchTxnStatusResponse.setSuccess(true);
  146.         fetchTxnStatusResponse.setTransactionStatus(TransactionStatus.FINAL_APPROVED);
  147.         fetchTxnStatusResponse.setKisshtTxnId(IdGeneratorUtil.generateKisshtPerfTransactionId());
  148.         return fetchTxnStatusResponse;
  149.     }
  150. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top