Skip to content

Commit c9ec8e1

Browse files
Compatibility with WP 5.9 and PHP 8
1 parent 751f6a9 commit c9ec8e1

2 files changed

Lines changed: 695 additions & 680 deletions

File tree

public/class-paystack-forms-public.php

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,7 +2034,7 @@ function kkd_pff_paystack_form_shortcode($atts)
20342034
</div>';
20352035
echo '<div class="span12 unit">
20362036
<label class="label">Amount (' . $currency;
2037-
if ($minimum == 0 && $amount != 0 && $usequantity == 'yes') {
2037+
if (floatval($minimum) == 0 && floatval($amount) != 0 && $usequantity == 'yes') {
20382038
echo ' ' . number_format($amount);
20392039
}
20402040

@@ -2058,9 +2058,9 @@ function kkd_pff_paystack_form_shortcode($atts)
20582058
} elseif ($recur == 'optional') {
20592059
echo '<input type="text" name="pf-amount" class="pf-number" id="pf-amount" value="' . $amount . '" required/>';
20602060
} else {
2061-
if ($amount == 0) {
2061+
if (floatval($amount) == 0) {
20622062
echo '<input type="text" name="pf-amount" class="pf-number" value="0" id="pf-amount" required/>';
2063-
} elseif ($amount != 0 && $minimum == 1) {
2063+
} elseif (floatval($amount) != 0 && $minimum == 1) {
20642064
echo '<input type="text" name="pf-amount" value="' . $amount . '" id="pf-amount" required/>';
20652065
} else {
20662066
echo '<input type="text" name="pf-amount" value="' . $amount . '" id="pf-amount" readonly required/>';
@@ -2075,7 +2075,7 @@ function kkd_pff_paystack_form_shortcode($atts)
20752075
<input type="hidden" id="pf-vname" name="pf-vname" />
20762076
<input type="hidden" id="pf-amount" />
20772077
<select class="form-control" id="pf-vamount" name="pf-amount">';
2078-
$max = $quantity + 1;
2078+
$max = intval($quantity) + 1;
20792079
if ($max > ($stock + 1)) {
20802080
$max = $stock + 1;
20812081
}
@@ -2550,7 +2550,7 @@ function kkd_pff_paystack_submit_action()
25502550
$subaccount = get_post_meta($_POST["pf-id"], '_subaccount', true);
25512551
$txnbearer = get_post_meta($_POST["pf-id"], '_txnbearer', true);
25522552
$transaction_charge = get_post_meta($_POST["pf-id"], '_merchantamount', true);
2553-
$transaction_charge = $transaction_charge * 100;
2553+
$transaction_charge = intval(floatval($transaction_charge) * 100);
25542554

25552555
$txncharge = get_post_meta($_POST["pf-id"], '_txncharge', true);
25562556
$minimum = get_post_meta($_POST["pf-id"], '_minimum', true);
@@ -2562,12 +2562,12 @@ function kkd_pff_paystack_submit_action()
25622562
$quantity = 1;
25632563
$usequantity = get_post_meta($_POST["pf-id"], '_usequantity', true);
25642564

2565-
if (($recur == 'no') && ($formamount != 0)) {
2566-
$amount = (int) str_replace(' ', '', $formamount);
2565+
if (($recur == 'no') && (floatval($formamount) != 0)) {
2566+
$amount = (int) str_replace(' ', '', floatval($formamount));
25672567
}
2568-
if ($minimum == 1 && $formamount != 0) {
2569-
if ($originalamount < $formamount) {
2570-
$amount = $formamount;
2568+
if ($minimum == 1 && floatval($formamount) != 0) {
2569+
if ($originalamount < floatval($formamount)) {
2570+
$amount = floatval($formamount);
25712571
} else {
25722572
$amount = $originalamount;
25732573
}
@@ -2860,13 +2860,16 @@ function kkd_pff_paystack_confirm_payment()
28602860
$usevariableamount = get_post_meta($payment_array->post_id, '_usevariableamount', true);
28612861
$variableamount = get_post_meta($payment_array->post_id, '_variableamount', true);
28622862

2863-
if ($minimum == 1 && $amount != 0) {
2864-
if ($payment_array->amount < $formamount) {
2865-
$amount = $formamount;
2866-
} else {
2867-
$amount = $payment_array->amount;
2868-
}
2869-
}
2863+
// if ($minimum == 1 && floatval($amount) != 0) {
2864+
// if ($payment_array->amount < floatval($formamount)) {
2865+
// $amount = floatval($formamount);
2866+
// } else {
2867+
// $amount = $payment_array->amount;
2868+
// }
2869+
// }
2870+
2871+
$amount = $payment_array->amount;
2872+
28702873
$oamount = $amount;
28712874
$mode = esc_attr(get_option('mode'));
28722875
if ($mode == 'test') {

0 commit comments

Comments
 (0)