initializeCardPayment method

Future<CardPaymentResponse?> initializeCardPayment()

Executes network call to initiate transactions

Implementation

Future<CardPaymentResponse?> initializeCardPayment() async {

  CardPaymentResponse? cardPaymentResponse = CardPaymentResponse();

  final url = "${Utils.getBaseUrl(isTest!)}/${Utils.initializePayment}";

  final response = await http.post(Uri.parse(url),
      headers: {
        "Authorization" : "Bearer $publicKey",
        "Content-Type" : "application/json"
      },
      body: toJson()
  );

  final responseBody = jsonDecode(response.body);
  cardPaymentResponse = CardPaymentResponse.fromJson(responseBody);

  return cardPaymentResponse;
}