submitBankReceipt method

void submitBankReceipt()

Implementation

void submitBankReceipt() async {
  if (receiptUrl.value == null) {
    CustomFlashWidget.showFlashMessage(
        title: 'Error',
        message: 'Please upload the file first',
        type: FlashType.error);

    return;
  }

  if (transferIdController.text.isEmpty) {
    CustomFlashWidget.showFlashMessage(
        type: FlashType.error,
        title: 'Error',
        message: 'Please enter the transfer ID');
    return;
  }

  try {
    var response = await Requests.getDio().patch(
      'payments/bank-transfer/update-pof',
      data: {
        'receipt_url': receiptUrl.value,
        'note': transferIdController.text,
        'paymentId': paymentId.value,
      },
    );

    if (response.statusCode == 200) {
      CustomFlashWidget.showFlashMessage(
        type: FlashType.success,
        title: "Success",
        message:
            "Payment will be confirmed by our team, and your subscription will be activate as soon as we receive the amount in our account.",
      );
    } else {
      CustomFlashWidget.showFlashMessage(
        type: FlashType.error,
        title: "Error",
        message: response.data['message'] ??
            "Something unexpected happened. Please try again later!",
      );
    }
  } catch (e) {
    CustomFlashWidget.showFlashMessage(
      type: FlashType.error,
      title: "Error",
      message: "Something unexpected happened. Please try again later!",
    );
  }
}