verifyPayment static method

Future<RequestResponse> verifyPayment(
  1. String invoiceId,
  2. BuildContext context
)

Implementation

static Future<RequestResponse> verifyPayment(
  String invoiceId,
  BuildContext context,
) async {
  final Map<String, dynamic> requestData = {
    'invoice_id': invoiceId,
  };

  final controller = Get.put(PaymentController());

  final http.Response response = await http.post(
    Uri.parse(
      '${controller.panelURL.value}${Endpoints.verifyPayment}',
    ),
    headers: <String, String>{
      'Content-Type': 'application/json',
      'Accept': 'application/json',
    },
    body: jsonEncode(requestData),
  );

  if (response.statusCode == 200) {
    if (kDebugMode) {
      print(response.body);
    }
    return requestResponseFromJson(response.body);
  } else {
    final decoded = jsonDecode(response.body);
    snackBar(decoded['message'], context);
    throw Exception(decoded['message']);
  }
}