loadPayment method
dynamic
loadPayment()
Implementation
loadPayment() async {
setState(() {
loading = true;
});
try {
Map getToken = await services.getAccessToken();
if (getToken['token'] != null) {
accessToken = getToken['token'];
final transactions = getOrderParams();
final res =
await services.createPaypalPayment(transactions, accessToken);
if (res["approvalUrl"] != null) {
setState(() {
checkoutUrl = res["approvalUrl"].toString();
navUrl = res["approvalUrl"].toString();
executeUrl = res["executeUrl"].toString();
loading = false;
pageloading = false;
loadingError = false;
});
} else {
widget.onError(res);
setState(() {
loading = false;
pageloading = false;
loadingError = true;
});
}
} else {
widget.onError("${getToken['message']}");
setState(() {
loading = false;
pageloading = false;
loadingError = true;
});
}
} catch (e) {
widget.onError(e);
setState(() {
loading = false;
pageloading = false;
loadingError = true;
});
}
}