confirmPhonePePayment method
void
confirmPhonePePayment()
Implementation
void confirmPhonePePayment(
String appKey,
String token,
String orderId,
String paymentId,
String signature,
ConfirmPhonePePayment confirmPhonePePayment,
) async {
confirmPhonePePayment.onLoading();
final url = "https://api.plentrasphere.com/index.php";
final body = {
"appKey": appKey,
"action": "confirmPayment",
"razorpay_order_id": orderId,
"razorpay_payment_id": paymentId,
"razorpay_signature": signature,
'isMobile': "yes",
};
try {
final response = await http.post(
Uri.parse(url),
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Bearer $token",
},
body: body,
);
final data = json.decode(response.body);
int code = data['response']['code'];
String status = data['response']['status'];
if (code == 400) {
if (status == "app-expired") {
confirmPhonePePayment.onAppNotActive(data['info']['appName']);
confirmPhonePePayment.onLoadfinished();
return;
}
if (status == "session-expired") {
confirmPhonePePayment.onNotLoggedIn();
confirmPhonePePayment.onLoadfinished();
return;
}
if (status == "invalid-order") {
confirmPhonePePayment.onInvalidOrder();
confirmPhonePePayment.onLoadfinished();
return;
}
confirmPhonePePayment.onError(status);
confirmPhonePePayment.onLoadfinished();
return;
}
confirmPhonePePayment.onSuccess(status);
confirmPhonePePayment.onLoadfinished();
} catch (e) {
confirmPhonePePayment.onError(e.toString());
confirmPhonePePayment.onLoadfinished();
}
}