execute method
Executes network call to initiate transactions
Implementation
Future<StandardResponse> execute(Client client) async {
final url = Utils.getBaseUrl(this.isTestMode) + Utils.STANDARD_PAYMENT;
final uri = Uri.parse(url);
try {
final response = await client.post(uri,
headers: {
HttpHeaders.authorizationHeader: this.publicKey,
HttpHeaders.contentTypeHeader: 'application/json'
},
body: json.encode(this._toJson()));
final responseBody = json.decode(response.body);
if (responseBody["status"] == "error") {
throw TransactionError(responseBody["message"] ??
"An unexpected error occurred. Please try again.");
}
return StandardResponse.fromJson(responseBody);
} catch (error) {
throw (error);
}
}