collectUPIPayment method

Future<String> collectUPIPayment(
  1. String url,
  2. String vpa
)

Implementation

Future<String> collectUPIPayment(String url, String vpa) async {
  final response = await httpClient.post(Uri.parse(url),
      body: {"virtual_address": vpa},
      headers: {"Content-Type": "application/x-www-form-urlencoded"},
      encoding: Encoding.getByName("utf-8"));

  String result = response.body;

  if (!isSuccessful(response.statusCode)) {
    throw Exception('error creating order');
  } else if (response.statusCode == 400) {
    result = jsonEncode('{"statusCode" : 400}');
  }
  final json = jsonDecode(result);
  if (kDebugMode) {
    print(json);
  }
  return result;
}