Skip to content

Commit f0149e5

Browse files
Merge pull request #78 from PaystackHQ/patch/wordpress-update
Patch/wordpress update - v3.4.0
2 parents 751f6a9 + d23f62d commit f0149e5

File tree

4 files changed

+725
-687
lines changed

4 files changed

+725
-687
lines changed

paystack-forms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Payment Forms for Paystack
44
Plugin URI: https://github.com/PaystackHQ/Wordpress-Payment-forms-for-Paystack
55
Description: Payment Forms for Paystack allows you create forms that will be used to bill clients for goods and services via Paystack.
6-
Version: 3.3.13
6+
Version: 3.4.0
77
Author: Paystack
88
Author URI: http://paystack.com
99
License: GPL-2.0+

public/class-paystack-forms-public.php

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,31 @@ public static function fetchFeeSettings()
4545

4646
public function enqueue_scripts()
4747
{
48+
global $posts;
49+
$pattern = get_shortcode_regex();
50+
preg_match('/'.$pattern.'/s', $posts[0]->post_content, $matches);
51+
4852
wp_enqueue_script('blockUI', plugin_dir_url(__FILE__) . 'js/jquery.blockUI.min.js', array('jquery'), $this->version, true, true);
4953
wp_enqueue_script('jquery-ui-core');
50-
wp_register_script('Paystack', 'https://js.paystack.co/v1/inline.js', false, '1');
51-
wp_enqueue_script('Paystack');
52-
wp_enqueue_script('paystack_frontend', plugin_dir_url(__FILE__) . 'js/paystack-forms-public.js', array('jquery'), $this->version, true, true);
53-
wp_localize_script('paystack_frontend', 'kkd_pff_settings', array('key' => Kkd_Pff_Paystack_Public::fetchPublicKey(), 'fee' => Kkd_Pff_Paystack_Public::fetchFeeSettings()), $this->version, true, true);
54+
55+
if(is_array($matches)) {
56+
if( count($matches) > 0) {
57+
if($matches[2] == 'pff-paystack') {
58+
wp_register_script('Paystack', 'https://js.paystack.co/v1/inline.js', false, '1');
59+
wp_enqueue_script('Paystack');
60+
wp_enqueue_script('paystack_frontend', plugin_dir_url(__FILE__) . 'js/paystack-forms-public.js', array('jquery'), $this->version, true, true);
61+
wp_localize_script('paystack_frontend', 'kkd_pff_settings', array('key' => Kkd_Pff_Paystack_Public::fetchPublicKey(), 'fee' => Kkd_Pff_Paystack_Public::fetchFeeSettings()), $this->version, true, true);
62+
}
63+
}
64+
}
65+
66+
67+
// wp_enqueue_script('blockUI', plugin_dir_url(__FILE__) . 'js/jquery.blockUI.min.js', array('jquery'), $this->version, true, true);
68+
// wp_enqueue_script('jquery-ui-core');
69+
// wp_register_script('Paystack', 'https://js.paystack.co/v1/inline.js', false, '1');
70+
// wp_enqueue_script('Paystack');
71+
// wp_enqueue_script('paystack_frontend', plugin_dir_url(__FILE__) . 'js/paystack-forms-public.js', array('jquery'), $this->version, true, true);
72+
// wp_localize_script('paystack_frontend', 'kkd_pff_settings', array('key' => Kkd_Pff_Paystack_Public::fetchPublicKey(), 'fee' => Kkd_Pff_Paystack_Public::fetchFeeSettings()), $this->version, true, true);
5473
}
5574
}
5675

@@ -2034,7 +2053,7 @@ function kkd_pff_paystack_form_shortcode($atts)
20342053
</div>';
20352054
echo '<div class="span12 unit">
20362055
<label class="label">Amount (' . $currency;
2037-
if ($minimum == 0 && $amount != 0 && $usequantity == 'yes') {
2056+
if (floatval($minimum) == 0 && floatval($amount) != 0 && $usequantity == 'yes') {
20382057
echo ' ' . number_format($amount);
20392058
}
20402059

@@ -2058,9 +2077,9 @@ function kkd_pff_paystack_form_shortcode($atts)
20582077
} elseif ($recur == 'optional') {
20592078
echo '<input type="text" name="pf-amount" class="pf-number" id="pf-amount" value="' . $amount . '" required/>';
20602079
} else {
2061-
if ($amount == 0) {
2080+
if (floatval($amount) == 0) {
20622081
echo '<input type="text" name="pf-amount" class="pf-number" value="0" id="pf-amount" required/>';
2063-
} elseif ($amount != 0 && $minimum == 1) {
2082+
} elseif (floatval($amount) != 0 && $minimum == 1) {
20642083
echo '<input type="text" name="pf-amount" value="' . $amount . '" id="pf-amount" required/>';
20652084
} else {
20662085
echo '<input type="text" name="pf-amount" value="' . $amount . '" id="pf-amount" readonly required/>';
@@ -2075,7 +2094,7 @@ function kkd_pff_paystack_form_shortcode($atts)
20752094
<input type="hidden" id="pf-vname" name="pf-vname" />
20762095
<input type="hidden" id="pf-amount" />
20772096
<select class="form-control" id="pf-vamount" name="pf-amount">';
2078-
$max = $quantity + 1;
2097+
$max = intval($quantity) + 1;
20792098
if ($max > ($stock + 1)) {
20802099
$max = $stock + 1;
20812100
}
@@ -2550,7 +2569,7 @@ function kkd_pff_paystack_submit_action()
25502569
$subaccount = get_post_meta($_POST["pf-id"], '_subaccount', true);
25512570
$txnbearer = get_post_meta($_POST["pf-id"], '_txnbearer', true);
25522571
$transaction_charge = get_post_meta($_POST["pf-id"], '_merchantamount', true);
2553-
$transaction_charge = $transaction_charge * 100;
2572+
$transaction_charge = intval(floatval($transaction_charge) * 100);
25542573

25552574
$txncharge = get_post_meta($_POST["pf-id"], '_txncharge', true);
25562575
$minimum = get_post_meta($_POST["pf-id"], '_minimum', true);
@@ -2562,12 +2581,12 @@ function kkd_pff_paystack_submit_action()
25622581
$quantity = 1;
25632582
$usequantity = get_post_meta($_POST["pf-id"], '_usequantity', true);
25642583

2565-
if (($recur == 'no') && ($formamount != 0)) {
2566-
$amount = (int) str_replace(' ', '', $formamount);
2584+
if (($recur == 'no') && (floatval($formamount) != 0)) {
2585+
$amount = (int) str_replace(' ', '', floatval($formamount));
25672586
}
2568-
if ($minimum == 1 && $formamount != 0) {
2569-
if ($originalamount < $formamount) {
2570-
$amount = $formamount;
2587+
if ($minimum == 1 && floatval($formamount) != 0) {
2588+
if ($originalamount < floatval($formamount)) {
2589+
$amount = floatval($formamount);
25712590
} else {
25722591
$amount = $originalamount;
25732592
}
@@ -2860,13 +2879,16 @@ function kkd_pff_paystack_confirm_payment()
28602879
$usevariableamount = get_post_meta($payment_array->post_id, '_usevariableamount', true);
28612880
$variableamount = get_post_meta($payment_array->post_id, '_variableamount', true);
28622881

2863-
if ($minimum == 1 && $amount != 0) {
2864-
if ($payment_array->amount < $formamount) {
2865-
$amount = $formamount;
2866-
} else {
2867-
$amount = $payment_array->amount;
2868-
}
2869-
}
2882+
// if ($minimum == 1 && floatval($amount) != 0) {
2883+
// if ($payment_array->amount < floatval($formamount)) {
2884+
// $amount = floatval($formamount);
2885+
// } else {
2886+
// $amount = $payment_array->amount;
2887+
// }
2888+
// }
2889+
2890+
$amount = $payment_array->amount;
2891+
28702892
$oamount = $amount;
28712893
$mode = esc_attr(get_option('mode'));
28722894
if ($mode == 'test') {

0 commit comments

Comments
 (0)