added pollbackpayment status
This commit is contained in:
@@ -8,6 +8,9 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -332,10 +335,15 @@ public class PaymentStartServiceImpl implements PaymentStartService {
|
||||
httpService.postFormRequest(uatPaymentUrlweb, formPayload);
|
||||
|
||||
LOGGER.info("Payment Start Response: {}", responseMap);
|
||||
|
||||
|
||||
int httpCode = Integer.parseInt(responseMap.getOrDefault("respCode", "500"));
|
||||
String respBody = responseMap.getOrDefault("data", "");
|
||||
|
||||
/*
|
||||
* Map<String, String> parsedHtml = parseHtmlResponse(respBody);
|
||||
*
|
||||
* for(Map.Entry<String, String> entry : parsedHtml.entrySet()) {
|
||||
* LOGGER.info("Parsed HTML - {} : {}", entry.getKey(), entry.getValue()); }
|
||||
*/
|
||||
helper.updateOutboundLogResponse(outboundLog, respBody);
|
||||
|
||||
// ---- HTTP FAILURE ----
|
||||
@@ -356,7 +364,7 @@ public class PaymentStartServiceImpl implements PaymentStartService {
|
||||
// Save record with HTML (persist original request and HTML response)
|
||||
String responseTypeWeb = "HTML";
|
||||
String rawResponseWeb = respBody == null ? "" : respBody;
|
||||
// bbpsMapperHelper.savePaymentStartRecord(request, null, txnId, orderNo, requestJson, rawResponseWeb, responseTypeWeb);
|
||||
bbpsMapperHelper.savePaymentStartRecord(request, null, txnId, orderNo, requestJson, rawResponseWeb, responseTypeWeb);
|
||||
|
||||
// Return HTML directly in API response
|
||||
Map<String, String> result = new HashMap<>();
|
||||
@@ -373,7 +381,7 @@ public class PaymentStartServiceImpl implements PaymentStartService {
|
||||
@Override
|
||||
public ResponseModel handleStartCallback(CallbackRequest callbackRequest) {
|
||||
String apiName = "HANDLE_START_CALLBACK";
|
||||
LOGGER.info("[{}] START | payload={}", apiName, callbackRequest);
|
||||
LOGGER.info("[{}] START ", apiName);
|
||||
|
||||
if (callbackRequest == null) {
|
||||
LOGGER.warn("Callback payload is null");
|
||||
@@ -391,7 +399,7 @@ public class PaymentStartServiceImpl implements PaymentStartService {
|
||||
return new ResponseModel("Decryption failed", "207", 200, null);
|
||||
}
|
||||
|
||||
LOGGER.info("Decrypted callback data: {}", decrypted);
|
||||
LOGGER.info("Decrypted data");
|
||||
|
||||
// Parse decrypted JSON
|
||||
Map<String, Object> payloadMap;
|
||||
@@ -468,6 +476,29 @@ public class PaymentStartServiceImpl implements PaymentStartService {
|
||||
|
||||
return new ResponseModel("Callback processed", merchantStatus, 200, null);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, String> parseHtmlResponse(String html) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
try {
|
||||
Document doc = Jsoup.parse(html);
|
||||
|
||||
Element txnId = doc.selectFirst("input[name=txnId]");
|
||||
Element amount = doc.selectFirst("input[name=amount]");
|
||||
Element mid = doc.selectFirst("input[name=mid]");
|
||||
|
||||
if (txnId != null) map.put("txnId", txnId.attr("value"));
|
||||
if (amount != null) map.put("amount", amount.attr("value"));
|
||||
if (mid != null) map.put("mid", mid.attr("value"));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user