Skip to content

Commit cc1ca14

Browse files
committed
Bug fixes
1 parent 99344e3 commit cc1ca14

File tree

3 files changed

+47
-34
lines changed

3 files changed

+47
-34
lines changed

includes/class-paystack-forms-activator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?php
2-
32
class Kkd_Pff_Paystack_Activator {
43

54
public static function activate() {
65
global $wpdb;
76
$table_name = $wpdb->prefix . 'paystack_forms_payments';
87

9-
$sql = "CREATE TABLE IF NOT EXISTS `".$table_name."` (
8+
$sql = "CREATE TABLE `".$table_name."` (
109
id int(11) NOT NULL AUTO_INCREMENT,
1110
post_id int(11) NOT NULL,
1211
user_id int(11) NOT NULL,
@@ -24,6 +23,7 @@ public static function activate() {
2423
);";
2524
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
2625
dbDelta($sql);
26+
2727
}
2828

2929

paystack-forms.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
}
1616
define( 'KKD_PFF_PAYSTACK_PLUGIN_PATH', plugins_url( __FILE__ ) );
1717
define( 'KKD_PFF_PAYSTACK_MAIN_FILE', __FILE__ );
18+
define( 'KKD_PFF_PAYSTACK_VERSION', '1.0.4' );
19+
20+
1821
// fix some badly enqueued scripts with no sense of HTTPS
1922
add_action('wp_print_scripts', 'kkd_pff_paystack_enqueueScriptsFix', 100);
2023
add_action('wp_print_styles', 'kkd_pff_paystack_enqueueStylesFix', 100);
@@ -53,7 +56,7 @@ function kkd_pff_paystack_enqueueStylesFix() {
5356

5457
function kkd_pff_paystack_activate_paystack_forms() {
5558
require_once plugin_dir_path( __FILE__ ) . 'includes/class-paystack-forms-activator.php';
56-
Paystack_Forms_Activator::activate();
59+
Kkd_Pff_Paystack_Activator::activate();
5760
}
5861

5962
register_activation_hook( __FILE__, 'kkd_pff_paystack_activate_paystack_forms' );

public/class-paystack-forms-public.php

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,8 @@ function kkd_pff_paystack_form_shortcode($atts) {
614614
<div class="input">';
615615
if ($recur == 'plan') {
616616
echo '<input type="text" name="pf-amount" value="'.$planamount.'" id="pf-amount" readonly required/>';
617+
}elseif($recur == 'optional'){
618+
echo '<input type="text" name="pf-amount" class="pf-number" id="pf-amount" required/>';
617619
}else{
618620
if ($amount == 0) {
619621
echo '<input type="text" name="pf-amount" class="pf-number" id="pf-amount" required/>';
@@ -627,30 +629,29 @@ function kkd_pff_paystack_form_shortcode($atts) {
627629
echo '</div>
628630
</div>';
629631

630-
if ($recur != 'no') {
631-
if ($recur == 'optional') {
632-
echo '<div class="span12 unit">
633-
<label class="label">Recuring Payment</label>
634-
<div class="select">
635-
<select class="form-control" name="pf-interval" >
636-
<option value="no">None</option>
637-
<option value="hourly">Hourly</option>
638-
<option value="daily">Daily</option>
639-
<option value="weekly">Weekly</option>
640-
<option value="monthly">Monthly</option>
641-
<option value="annually">Annually</option>
642-
</select>
643-
<i></i>
644-
</div>
645-
</div>';
646-
}else{
647-
echo '<input type="hidden" name="pf-plancode" value="' . $recurplan. '" />';
648-
echo '<div class="span12 unit">
649-
<label class="label" style="font-size:18px;font-weight:600;line-height: 20px;">'.$plan->data->name.' '.$plan->data->interval. ' recuring payment - '.$plan->data->currency.' '.number_format($planamount).'</label>
650-
</div>';
651-
}
632+
if ($recur == 'optional') {
633+
echo '<div class="span12 unit">
634+
<label class="label">Recuring Payment</label>
635+
<div class="select">
636+
<select class="form-control" name="pf-interval" >
637+
<option value="no">None</option>
638+
<option value="hourly">Hourly</option>
639+
<option value="daily">Daily</option>
640+
<option value="weekly">Weekly</option>
641+
<option value="monthly">Monthly</option>
642+
<option value="annually">Annually</option>
643+
</select>
644+
<i></i>
645+
</div>
646+
</div>';
647+
}elseif($recur == 'plan'){
648+
echo '<input type="hidden" name="pf-plancode" value="' . $recurplan. '" />';
649+
echo '<div class="span12 unit">
650+
<label class="label" style="font-size:18px;font-weight:600;line-height: 20px;">'.$plan->data->name.' '.$plan->data->interval. ' recuring payment - '.$plan->data->currency.' '.number_format($planamount).'</label>
651+
</div>';
652+
}
653+
652654

653-
}
654655
echo(do_shortcode($obj->post_content));
655656

656657
// echo '<br /><p>Transaction charge:'.$currency.'<b class="txn_charge">13,000</b></p>';
@@ -1021,6 +1022,7 @@ function kkd_pff_paystack_confirm_payment() {
10211022

10221023
$payment_array = $record[0];
10231024
$amount = get_post_meta($payment_array->post_id,'_amount',true);
1025+
$recur = get_post_meta($payment_array->post_id,'_recur',true);
10241026
$currency = get_post_meta($payment_array->post_id,'_currency',true);
10251027

10261028

@@ -1044,25 +1046,33 @@ function kkd_pff_paystack_confirm_payment() {
10441046
if ( 'success' == $paystack_response->data->status ) {
10451047
$amount_paid = $paystack_response->data->amount / 100;
10461048
$paystack_ref = $paystack_response->data->reference;
1047-
1048-
if ($amount == 0) {
1049+
if ($recur == 'optional' || $recur == 'plan') {
10491050
$wpdb->update( $table, array( 'paid' => 1,'amount' =>$amount_paid),array('txn_code'=>$paystack_ref));
10501051
$thankyou = get_post_meta($payment_array->post_id,'_successmsg',true);
10511052
$message = $thankyou;
10521053
$result = "success";
1053-
// kkd_pff_paystack_send_receipt($currency,$amount,$name,$payment_array->email,$code,$metadata)
10541054
}else{
1055-
if( $amount != $amount_paid ) {
1056-
$message = "Invalid amount Paid. Amount required is ".$currency."<b>".number_format($amount)."</b>";
1057-
$result = "failed";
1058-
}else{
10591055

1060-
$wpdb->update( $table, array( 'paid' => 1),array('txn_code'=>$paystack_ref));
1056+
if ($amount == 0) {
1057+
$wpdb->update( $table, array( 'paid' => 1,'amount' =>$amount_paid),array('txn_code'=>$paystack_ref));
10611058
$thankyou = get_post_meta($payment_array->post_id,'_successmsg',true);
10621059
$message = $thankyou;
10631060
$result = "success";
1061+
// kkd_pff_paystack_send_receipt($currency,$amount,$name,$payment_array->email,$code,$metadata)
1062+
}else{
1063+
if( $amount != $amount_paid ) {
1064+
$message = "Invalid amount Paid. Amount required is ".$currency."<b>".number_format($amount)."</b>";
1065+
$result = "failed";
1066+
}else{
1067+
1068+
$wpdb->update( $table, array( 'paid' => 1),array('txn_code'=>$paystack_ref));
1069+
$thankyou = get_post_meta($payment_array->post_id,'_successmsg',true);
1070+
$message = $thankyou;
1071+
$result = "success";
1072+
}
10641073
}
10651074
}
1075+
10661076
}else {
10671077
$message = "Transaction Failed/Invalid Code";
10681078
$result = "failed";

0 commit comments

Comments
 (0)