update code resolve conflict
This commit is contained in:
@@ -151,5 +151,9 @@ public class BBPSConstant {
|
||||
public static final long BILL_FETCH_DELAY_MS = 5000L; // used after initiate bill fetch
|
||||
public static final long BILL_VALIDATE_DELAY_MS = 12000L; // used after initiate bill validate
|
||||
public static final long PAYMENT_STATUS_DELAY_MS = 9000L; // used after initiate payment
|
||||
|
||||
|
||||
public static final String enckey="zk52olsyr9fl95h50eus8bhtyhoo5lp7";
|
||||
public static final String mid="Test-By-Aditya-1001";
|
||||
public static final String callbackurl= "https://checkout.solwio.in/PGPayU/payu/callback";
|
||||
public static final String companyName= "techwork technology";
|
||||
}
|
||||
@@ -43,12 +43,14 @@ import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.PaymentStartUserRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ClientReqIdResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ComplaintResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.PaymentStartApiResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.PlanResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsResponse;
|
||||
@@ -85,6 +87,7 @@ import com.billpaymentservice.bbps.entites.CustomerParamBill;
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamBillValidation;
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamGroupById;
|
||||
import com.billpaymentservice.bbps.entites.GroupParam;
|
||||
import com.billpaymentservice.bbps.entites.PaymentStartRecord;
|
||||
import com.billpaymentservice.bbps.entites.Plan;
|
||||
import com.billpaymentservice.bbps.entites.PlanCategorySubType;
|
||||
import com.billpaymentservice.bbps.entites.PlanResponses;
|
||||
@@ -109,11 +112,14 @@ import com.billpaymentservice.bbps.repository.ComplaintStatusRepository;
|
||||
import com.billpaymentservice.bbps.repository.ContactMasterDataRepository;
|
||||
import com.billpaymentservice.bbps.repository.CustomerParamGroupByBillerIdRepository;
|
||||
import com.billpaymentservice.bbps.repository.FetchBillValidateRepository;
|
||||
import com.billpaymentservice.bbps.repository.PaymentStartRecordRepository;
|
||||
import com.billpaymentservice.bbps.repository.PlanResponseRepository;
|
||||
import com.billpaymentservice.bbps.repository.ReOpenComplaintRepository;
|
||||
import com.billpaymentservice.bbps.repository.TicketDispositionRepository;
|
||||
import com.billpaymentservice.bbps.repository.ViewAllComplainTicketDetailRepository;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
|
||||
@Component
|
||||
public class BillerMapperHelper {
|
||||
|
||||
@@ -139,6 +145,7 @@ public class BillerMapperHelper {
|
||||
private final BillMasterRepository billMasterRepository;
|
||||
private final BillValidationRepository billValidationRepository;
|
||||
private final ComplaintResponseRepository complaintResponseRepository;
|
||||
private final PaymentStartRecordRepository paymentStartRecordRepository;
|
||||
|
||||
public BillerMapperHelper(BillerCategoryWiseRepository billerRepo,
|
||||
CustomerParamGroupByBillerIdRepository customerParamGroupByBillerIdRepo,
|
||||
@@ -154,8 +161,10 @@ public class BillerMapperHelper {
|
||||
ViewAllComplainTicketDetailRepository viewAllComplainTicketDetailRepository,
|
||||
ContactMasterDataRepository contactMasterDataRepository, BBPSMasterDataRepo bbpsMasterDataRepo,
|
||||
BillerDataRepository billerDataRespository, BillMasterRepository billMasterRepository,
|
||||
BillValidationRepository billValidationRepository,
|
||||
ComplaintResponseRepository complaintResponseRepository) {
|
||||
BillValidationRepository billValidationRepository, ComplaintResponseRepository complaintResponseRepository,
|
||||
PaymentStartRecordRepository paymentStartRecordRepository) {
|
||||
|
||||
this.paymentStartRecordRepository = paymentStartRecordRepository;
|
||||
this.billerRepo = billerRepo;
|
||||
this.customerParamGroupByBillerIdRepo = customerParamGroupByBillerIdRepo;
|
||||
this.amountOptionByBillerIdRepository = amountOptionByBillerIdRepository;
|
||||
@@ -1071,6 +1080,23 @@ public class BillerMapperHelper {
|
||||
return forward;
|
||||
}
|
||||
|
||||
public void savePaymentStartRecord(PaymentStartUserRequest request, PaymentStartApiResponse apiResponse,
|
||||
String txnId, String orderNo) {
|
||||
PaymentStartRecord record = new PaymentStartRecord();
|
||||
record.setOrderNo(orderNo);
|
||||
record.setRequestId(request.getReqId());
|
||||
record.setClientMid(request.getMid());
|
||||
record.setClientUserId(request.getClientUserId());
|
||||
record.setInternalTxnId(txnId);
|
||||
record.setAmount(apiResponse.getResponseData().getAmount());
|
||||
record.setMid(apiResponse.getResponseData().getMid());
|
||||
record.setTxnId(apiResponse.getResponseData().getTxnId());
|
||||
record.setQrString(apiResponse.getResponseData().getQrString());
|
||||
record.setCreatedOn(apiResponse.getResponseData().getCreatedOn());
|
||||
|
||||
paymentStartRecordRepository.save(record);
|
||||
}
|
||||
|
||||
public TransactionHistoryMasterDTO toDTO(TransactionMaster transactionMaster) {
|
||||
if (transactionMaster == null) {
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.billpaymentservice.bbps.util;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class EncryptionUtil {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(EncryptionUtil.class);
|
||||
|
||||
/**
|
||||
* Encrypts plaintext using AES/CBC/PKCS5Padding.
|
||||
* If the provided key length is not 16/24/32 bytes it will be adjusted to 16 bytes (padded/truncated).
|
||||
* NOTE: This follows the algorithm snippet provided by the user but pads/truncates the key to avoid
|
||||
* common runtime errors when key lengths are incorrect.
|
||||
*/
|
||||
public String encryptMData(String plaintext, String encryptKey) {
|
||||
try {
|
||||
// Ensure key length is 16 bytes (AES-128). If callers provide a longer key this will truncate.
|
||||
byte[] keyBytes = normalizeKey(encryptKey);
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
|
||||
|
||||
byte[] ivBytes = cipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV();
|
||||
byte[] encryptedData = cipher.doFinal(plaintext.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
byte[] combinedBytes = new byte[ivBytes.length + encryptedData.length];
|
||||
System.arraycopy(ivBytes, 0, combinedBytes, 0, ivBytes.length);
|
||||
System.arraycopy(encryptedData, 0, combinedBytes, ivBytes.length, encryptedData.length);
|
||||
return Base64.getEncoder().encodeToString(combinedBytes);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Exception in encrypt() : encryptMData- {} : Message- {}", encryptKey, e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private byte[] normalizeKey(String encryptKey) {
|
||||
if (encryptKey == null) {
|
||||
encryptKey = "";
|
||||
}
|
||||
byte[] bytes = encryptKey.getBytes(StandardCharsets.UTF_8);
|
||||
int targetLen = 16; // AES-128
|
||||
if (bytes.length == targetLen || bytes.length == 24 || bytes.length == 32) {
|
||||
return bytes;
|
||||
}
|
||||
byte[] normalized = new byte[targetLen];
|
||||
for (int i = 0; i < targetLen; i++) {
|
||||
if (i < bytes.length) {
|
||||
normalized[i] = bytes[i];
|
||||
} else {
|
||||
normalized[i] = 0; // pad with zeros
|
||||
}
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
@@ -183,5 +183,14 @@ public class Helper {
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public <T> T convertJsonToObject(String json, Class<T> clazz) {
|
||||
try {
|
||||
return objectMapper.readValue(json, clazz);
|
||||
} catch (Exception e) {
|
||||
throw new CustomException("Invalid JSON from payment API", "FAILED", 400, json);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user