check method

dynamic check({
  1. required String id,
  2. required String apiKey,
  3. required bool testMode,
  4. required void onDone(
    1. CheckPaymentModel data
    ),
  5. required void onError(
    1. Map<String, dynamic> data
    ),
})

Implementation

check(
    {required String id,
    required String apiKey,
    required bool testMode,
    required void Function(CheckPaymentModel data) onDone,
    required void Function(Map<String, dynamic> data) onError}) {
  String url = testMode
      ? "https://uatcheckout.thawani.om/api/v1/payment_intents/$id"
      : "https://checkout.thawani.om/api/v1/payment_intents/$id";

  Request.get(url: url, headers: {
    'Content-Type': "application/json",
    'thawani-api-key': apiKey
  }).then((value) => {
        if (value['code'] == 2000)
          {onDone(CheckPaymentModel.fromJson(value))}
        else
          {onError(value)}
      });
}