getPaymentStatus method

Future<ApiResponse<Payment>> getPaymentStatus(
  1. String paymentCode
)

Get Payment Status of a bill from WeBirr Servers paymentCode is the number that WeBirr Payment Gateway returns on createBill. Check if(ApiResponse.error == null) to see if there are errors. ApiResponse.res will have Payment object on success (will be null otherwise!) ApiResponse.res?.isPaid ?? false -> will return true if the bill is paid (payment completed) ApiResponse.res?.data ?? null -> will have PaymentDetail object

Implementation

Future<ApiResponse<Payment>> getPaymentStatus(String paymentCode) async {
  var client = RetryClient(http.Client());
  try {
    var resp = await client.get(Uri.parse(
        '${_baseAddress}/einvoice/api/getPaymentStatus?api_key=${_apiKey}&wbc_code=$paymentCode'));
    if (resp.statusCode == 200) {
      var map = jsonDecode(resp.body) as Map<String, dynamic>;
      return ApiResponse<Payment>(
          error: map['error'],
          errorCode: map['errorCode'],
          res: map['res'] != null ? Payment.fromJson(map['res']) : null);
    } else {
      return new ApiResponse<Payment>(
          error: 'http error ${resp.statusCode} ${resp.reasonPhrase}');
    }
  } finally {
    client.close();
  }
}