medicineCapturePayment method

Future medicineCapturePayment({
  1. dynamic transactionId,
  2. dynamic context,
})

Implementation

Future medicineCapturePayment({transactionId, context}) async {
  var decodedResponse;
  final ApiBody = {
    "medicine_order_id": '$getMedicineOrderID',
    "transaction_id": '$transactionId'
  };
  var body = jsonEncode(ApiBody);

  http.Response response = await http.post(
      Uri.parse('${medicine_API}api/medicine/capture-payment-details'),
      headers: {
        "Content-Type": "application/json",
        'Authorization': currentUserToken,
      },
      body: body);
  decodedResponse = json.decode(response.body);
  getCapturePaymentData = decodedResponse;

  if (decodedResponse['success'] == true) {
    Get.offAll(CommonThankYouPage(
      pageFrom: 'medicine_order',
      order_id: '$getMedicineOrderID',
    ));
  } else {
    Get.offAll(CommonThankYouPage(
      pageFrom: 'medicine_order',
      order_id: '$getMedicineOrderID',
    ));

    await showDialog(
      barrierDismissible: false,
      context: context,
      builder: (BuildContext context) {
        return MedicinePaymentSuccessPopup(
            message: " ${decodedResponse['message']}",
            ontap: () {
              Get.back();
            },
            image: '${LottiePath}Upload_Successful.json');
      },
    );
  }
}