makePayment method
dynamic
makePayment(
- dynamic context
Implementation
makePayment(context) {
PaymentController paymentController = PaymentController(widget.public_key,
widget.private_key, widget.secret_key, widget.merchant_key);
paymentController
.initPayment(
widget.public_key,
widget.amount,
widget.sandbox,
widget.currency,
widget.store_name,
widget.template,
widget.color,
widget.logo_url)
.then((value) async {
dynamic result = value["result"];
if (result["error"] == false) {
dynamic transaction =
await paymentController.getTransaction(result["transaction_id"]);
transaction = transaction["result"];
if (transaction["error"] == false) {
for (int i = 0; i < transaction["means_of_paiements"].length; i++) {
switch (transaction["means_of_paiements"][i]["_type"]) {
case "Mobile":
mobile_means_of_paiements
.add(transaction["means_of_paiements"][i]);
break;
case "Banque":
bank_means_of_paiements
.add(transaction["means_of_paiements"][i]);
break;
}
}
transaction_result = transaction;
transaction_object = transaction["transaction"];
loadAmount();
setState(() {
page = "make_pay";
});
} else {
setState(() {
page = "error";
});
}
widget.initPaymentResultAction(
{"success": true, "transaction": result["transaction_id"]});
} else {
setState(() {
page = "error";
});
widget.initPaymentResultAction({"success": false, "transaction": null});
}
});
}