Skip to content

Commit 8dcc21c

Browse files
Merge pull request #81 from Segtel1/master
Changed amount approximation to round up to 2 dp + Fixed invalid amount issues
2 parents ed825de + 9762b11 commit 8dcc21c

File tree

2 files changed

+3
-33
lines changed

2 files changed

+3
-33
lines changed

public/class-paystack-forms-public-for-old-themes.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,23 +1642,11 @@ function kkd_pff_paystack_confirm_payment()
16421642
$result = "success";
16431643
// kkd_pff_paystack_send_receipt($currency,$amount,$name,$payment_array->email,$code,$metadata)
16441644
} else {
1645-
$usequantity = get_post_meta($payment_array->post_id, '_usequantity', true);
1646-
if ($usequantity == 'no') {
1647-
$oamount = (int)str_replace(' ', '', $amount);
1648-
} else {
1649-
$quantity = $_POST["quantity"];
1650-
$unitamount = (int)str_replace(' ', '', $amount);
1651-
$oamount = $quantity*$unitamount;
1652-
}
16531645
if ($txncharge == 'customer') {
16541646
if ($minimum == 0 && $amount != 0) {
16551647
$oamount = kkd_pff_paystack_add_paystack_charge($oamount);
16561648
}
16571649
}
1658-
1659-
// if ($txncharge == 'customer') {
1660-
// $amount = kkd_pff_paystack_add_paystack_charge($amount);
1661-
// }
16621650
if ($oamount != $amount_paid) {
16631651
// echo $oamount. ' - '.$amount_paid;
16641652
$message = "Invalid amount Paid. Amount required is ".$currency."<b>".number_format($oamount)."</b>";

public/class-paystack-forms-public.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ public function add_for_kobo($amountinkobo)
137137
if ($amountinkobo > $this->flatline) {
138138
return $amountinkobo + $this->cap;
139139
} elseif ($amountinkobo > $this->crossover) {
140-
return ceil(($amountinkobo + $this->additional_charge) / $this->charge_divider);
140+
return round((($amountinkobo + $this->additional_charge) / $this->charge_divider),2);
141141
} else {
142-
return ceil($amountinkobo / $this->charge_divider);
142+
return round(($amountinkobo / $this->charge_divider),2);
143143
}
144144
}
145145

146146
public function add_for_ngn($amountinngn)
147147
{
148-
return $this->add_for_kobo(ceil($amountinngn * 100)) / 100;
148+
return $this->add_for_kobo(round(($amountinngn * 100),2)) / 100;
149149
}
150150
}
151151

@@ -2950,24 +2950,6 @@ function kkd_pff_paystack_confirm_payment()
29502950
$result = "success";
29512951
// kkd_pff_paystack_send_receipt($currency,$amount,$name,$payment_array->email,$code,$metadata)
29522952
} else {
2953-
$usequantity = get_post_meta($payment_array->post_id, '_usequantity', true);
2954-
if ($usequantity == 'no') {
2955-
$oamount = (int) str_replace(' ', '', $amount);
2956-
} else {
2957-
$quantity = $_POST["quantity"];
2958-
$unitamount = (int) str_replace(' ', '', $amount);
2959-
$oamount = $quantity * $unitamount;
2960-
}
2961-
if ($txncharge == 'customer') {
2962-
if ($minimum == 0 && $amount != 0) {
2963-
$oamount = kkd_pff_paystack_add_paystack_charge($oamount);
2964-
}
2965-
}
2966-
2967-
2968-
// if ($txncharge == 'customer') {
2969-
// $amount = kkd_pff_paystack_add_paystack_charge($amount);
2970-
// }
29712953
if ($oamount != $amount_paid) {
29722954
// echo $oamount. ' - '.$amount_paid;
29732955
$message = "Invalid amount Paid. Amount required is " . $currency . "<b>" . number_format($oamount) . "</b>";

0 commit comments

Comments
 (0)