initializePayment method

Future<InitPaymentResponse?> initializePayment(
  1. dynamic publicKey
)

Executes network call to initiate transactions

Implementation

Future<InitPaymentResponse?> initializePayment(publicKey) async {

  InitPaymentResponse? initPaymentResponse = InitPaymentResponse();

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

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

  final responseBody = jsonDecode(response.body);
  initPaymentResponse = InitPaymentResponse.fromJson(responseBody);

  return initPaymentResponse;
}