conform method

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

Implementation

conform(
    {required String id,
    required String apiKey,
    required bool testMode,
    required void Function(ConformPaymentModel data) onDone,
    required void Function(Map<String, dynamic> data) onError}) {
  String url = testMode
      ? "https://uatcheckout.thawani.om/api/v1/payment_intents/$id/confirm"
      : 'https://checkout.thawani.om/api/v1/payment_intents/$id/confirm';
  Request.post(url: url, data: {}, headers: {
    'Content-Type': "application/json",
    'thawani-api-key': apiKey
  }).then((value) {
    if (value['status'] == 200) {
      ConformPaymentModel model = ConformPaymentModel.fromJson(value['data']);
      onDone(model);
    } else {
      onError(value['data']);
    }
  });
}