updatePanAndGetVcipUrl method

Future<String> updatePanAndGetVcipUrl(
  1. String mobile,
  2. String? companyCode
)

Implementation

Future<String> updatePanAndGetVcipUrl(String mobile, String? companyCode) async {
  final pan = panText.text.trim();
  if (pan.isEmpty) {
    throw Exception("PAN number is missing. Please verify PAN first.");
  }

  final body = {
    "mobileNumber": mobile,
    "poi": pan,
    "poiType": "pan",
    "poiVerified": true,
  };

  if (kDebugMode) {
    print("[KYC-LOG] UpdatePanDetails request: $body");
  }

 /* final fullUrl =
      "https://vcip.transactionanalysts.com/vcip/AccountHolder/UpdatePanDetails";*/

  final fullUrl = EnvConfig.vcipUpdatePanUrl;


  final response =
  await ApiService.postPlain(fullUrl: fullUrl, body: body,companyCode:companyCode);

  if (kDebugMode) {
    print("[KYC-LOG] UpdatePanDetails response: $response");
  }

  if (response == null) {
    throw Exception("Empty response from UpdatePanDetails.");
  }

  if (response["resCode"]?.toString() != "000") {
    throw Exception(
        response["resDesc"]?.toString() ?? "UpdatePanDetails failed.");
  }

  final url = response["data"]?["url"]?.toString() ?? "";

  if (url.isEmpty) {
    throw Exception("VCIP URL missing in UpdatePanDetails response.");
  }

  return url;
}