checkMerchant method

Future<PaywayPartnerCheckMerchantResponse> checkMerchant({
  1. required PaywayPartnerCheckMerchant merchant,
  2. bool enabledLogger = false,
})

checkMerchant

check a status merchant

merchant : this information must be field in correctly

Usage:

final merchant = PaywayPartnerCheckMerchant(
  register_ref: "Merchant003",
);
var checkResponse = await service.checkMerchant(merchant: merchant);

Implementation

Future<PaywayPartnerCheckMerchantResponse> checkMerchant({
  required PaywayPartnerCheckMerchant merchant,
  bool enabledLogger = false,
}) async {
  var res = PaywayPartnerCheckMerchantResponse(
      data: "",
      status: PaywayPartnerCheckMerchantResponseStatus(
          code: "PTL46", message: "Merchant not found"));
  final clientService =
      PaywayPartnerClientFormRequestService(partner: partner);
  Map<String, dynamic> map =
      clientService.generateCheckMerchantFormData(merchant);

  var formData = FormData.fromMap(map);
  try {
    final client = helper.client;

    if (enabledLogger) {
      debugPrint(json.encode(map));
      client.interceptors.add(dioLoggerInterceptor);
    }

    Response<String> response =
        await client.post("/api/merchant-portal/online-self-activation/get-mc-credential-info", data: formData);

    var _map = json.decode(response.data!) as Map<String, dynamic>;
    res = PaywayPartnerCheckMerchantResponse.fromMap(_map);
  } catch (error, stacktrace) {
    if (enabledLogger) {
      debugPrint("Exception occured: $error stackTrace: $stacktrace");
    }

    res = res.copyWith(
        status: res.status.copyWith(
            code: "PTL46",
            message: PaywayPartnerClientService.handleResponseError(error)));
  }
  return res;
}