Skip to content

Commit 07f73b8

Browse files
committed
recurring plan settings
1 parent 44fc2ff commit 07f73b8

File tree

2 files changed

+69
-65
lines changed

2 files changed

+69
-65
lines changed

admin/class-paystack-forms-admin.php

Lines changed: 65 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ function help_metabox_details( $post ) {
256256
function add_extra_metaboxes() {
257257

258258
add_meta_box('wpt_form_data', 'Extra Form Description', 'wpt_form_data', 'paystack_form', 'normal', 'default');
259+
add_meta_box('wpt_recur_data', 'Recurring Payment', 'wpt_recur_data', 'paystack_form', 'side', 'default');
260+
add_meta_box('wpt_email_data', 'Email Receipt Settings', 'wpt_email_data', 'paystack_form', 'normal', 'default');
259261

260262
}
261263

@@ -289,11 +291,11 @@ function wpt_form_data() {
289291
echo '<input type="number" name="_amount" value="' . $amount . '" class="widefat pf-number" />';
290292
echo '<p>Pay button Description:</p>';
291293
echo '<input type="text" name="_paybtn" value="' . $paybtn . '" class="widefat" />';
292-
// echo '<p>Transaction Charges:</p>';
293-
// echo '<select class="form-control" name="_txncharge" id="parent_id" style="width:100%;">
294-
// <option value="merchant"'.txncheck('merchant',$txncharge).'>Merchant Pays(Include in fee)</option>
295-
// <option value="customer" '.txncheck('customer',$txncharge).'>Client Pays(Extra Fee added)</option>
296-
// </select>';
294+
echo '<p>Transaction Charges:</p>';
295+
echo '<select class="form-control" name="_txncharge" id="parent_id" style="width:100%;">
296+
<option value="merchant"'.txncheck('merchant',$txncharge).'>Merchant Pays(Include in fee)</option>
297+
<option value="customer" '.txncheck('customer',$txncharge).'>Client Pays(Extra Fee added)</option>
298+
</select>';
297299
echo '<p>User logged In:</p>';
298300
echo '<select class="form-control" name="_loggedin" id="parent_id" style="width:100%;">
299301
<option value="no" '.txncheck('no',$loggedin).'>User must not be logged in</option>
@@ -305,7 +307,62 @@ function wpt_form_data() {
305307
echo '<input ttype="number" name="_filelimit" value="' . $filelimit . '" class="widefat pf-number" />';
306308

307309
}
310+
function wpt_email_data() {
311+
global $post;
312+
313+
// Noncename needed to verify where the data originated
314+
echo '<input type="hidden" name="eventmeta_noncename" id="eventmeta_noncename" value="' .
315+
wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
316+
317+
// Get the location data if its already been entered
318+
$subject = get_post_meta($post->ID, '_subject', true);
319+
$heading = get_post_meta($post->ID, '_heading', true);
320+
$message = get_post_meta($post->ID, '_message', true);
321+
$sendreceipt = get_post_meta($post->ID, '_sendreceipt', true);
322+
323+
if ($subject == "") {$subject = 'Thank you for your payment';}
324+
if ($sendreceipt == "") {$sendreceipt = 'yes';}
325+
if ($heading == "") {$heading = "We've received your payment";}
326+
if ($message == "") {$message = 'Your payment was received and we appreciate it.';}
327+
// Echo out the field
328+
echo '<p>Send Email Receipt:</p>';
329+
echo '<select class="form-control" name="_sendreceipt" id="parent_id" style="width:100%;">
330+
<option value="no" '.txncheck('no',$sendreceipt).'>Don\'t send</option>
331+
<option value="yes" '.txncheck('yes',$sendreceipt).'>Send</option>
332+
</select>';
333+
echo '<p>Email Subject:</p>';
334+
echo '<input type="text" name="_subject" value="' . $subject . '" class="widefat" />';
335+
echo '<p>Email Heading:</p>';
336+
echo '<input type="text" name="_heading" value="' . $heading . '" class="widefat" />';
337+
echo '<p>Email Body/Message:</p>';
338+
echo '<textarea rows="6" name="_message" class="widefat" >'.$message.'</textarea>';
339+
340+
}
341+
function wpt_recur_data() {
342+
global $post;
343+
344+
// Noncename needed to verify where the data originated
345+
echo '<input type="hidden" name="eventmeta_noncename" id="eventmeta_noncename" value="' .
346+
wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
347+
348+
// Get the location data if its already been entered
349+
$recur = get_post_meta($post->ID, '_recur', true);
350+
$recurplan = get_post_meta($post->ID, '_recurplan', true);
351+
352+
if ($recur == "") {$recur = 'no';}
353+
if ($recurplan == "") {$recurplan = '';}
354+
// Echo out the field
355+
echo '<p>Reccuring Payment:</p>';
356+
echo '<select class="form-control" name="_recur" id="parent_id" style="width:100%;">
357+
<option value="no" '.txncheck('no',$recur).'>None</option>
358+
<option value="custom" '.txncheck('yes',$recur).'>User Sets Interval</option>
359+
<option value="plan" '.txncheck('yes',$recur).'>Paystack Plan</option>
360+
</select>';
361+
echo '<p>Paystack Recur Plan:</p>';
362+
echo '<input type="text" name="_recurplan" value="' . $recurplan . '" class="widefat" />
363+
<small>Plan amount must match amount on extra form description.</small>';
308364

365+
}
309366
function wpt_form_data_meta($post_id, $post) {
310367

311368
if ( !wp_verify_nonce( @$_POST['eventmeta_noncename'], plugin_basename(__FILE__) )) {
@@ -329,6 +386,9 @@ function wpt_form_data_meta($post_id, $post) {
329386
$form_meta['_heading'] = $_POST['_heading'];
330387
$form_meta['_message'] = $_POST['_message'];
331388
$form_meta['_sendreceipt'] = $_POST['_sendreceipt'];
389+
///
390+
$form_meta['_recur'] = $_POST['_recur'];
391+
$form_meta['_recurplan'] = $_POST['_recurplan'];
332392

333393
// Add values of $form_meta as custom fields
334394

@@ -346,43 +406,6 @@ function wpt_form_data_meta($post_id, $post) {
346406
}
347407
add_action('save_post', 'wpt_form_data_meta', 1, 2);
348408

349-
add_action( 'add_meta_boxes', 'add_email_metaboxes' );
350-
function add_email_metaboxes() {
351-
352-
add_meta_box('wpt_email_data', 'Email Receipt Settings', 'wpt_email_data', 'paystack_form', 'normal', 'default');
353-
354-
}
355-
function wpt_email_data() {
356-
global $post;
357-
358-
// Noncename needed to verify where the data originated
359-
echo '<input type="hidden" name="eventmeta_noncename" id="eventmeta_noncename" value="' .
360-
wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
361-
362-
// Get the location data if its already been entered
363-
$subject = get_post_meta($post->ID, '_subject', true);
364-
$heading = get_post_meta($post->ID, '_heading', true);
365-
$message = get_post_meta($post->ID, '_message', true);
366-
$sendreceipt = get_post_meta($post->ID, '_sendreceipt', true);
367-
368-
if ($subject == "") {$subject = 'Thank you for your payment';}
369-
if ($sendreceipt == "") {$sendreceipt = 'yes';}
370-
if ($heading == "") {$heading = "We've received your payment";}
371-
if ($message == "") {$message = 'Your payment was received and we appreciate it.';}
372-
// Echo out the field
373-
echo '<p>Send Email Receipt:</p>';
374-
echo '<select class="form-control" name="_sendreceipt" id="parent_id" style="width:100%;">
375-
<option value="no" '.txncheck('no',$sendreceipt).'>Don\'t send</option>
376-
<option value="yes" '.txncheck('yes',$sendreceipt).'>Send</option>
377-
</select>';
378-
echo '<p>Email Subject:</p>';
379-
echo '<input type="text" name="_subject" value="' . $subject . '" class="widefat" />';
380-
echo '<p>Email Heading:</p>';
381-
echo '<input type="text" name="_heading" value="' . $heading . '" class="widefat" />';
382-
echo '<p>Email Body/Message:</p>';
383-
echo '<textarea rows="6" name="_message" class="widefat" >'.$message.'</textarea>';
384-
385-
}
386409

387410

388411

paystack-forms.php

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/*
43
Plugin Name: Payment forms for Paystack
54
Plugin URI: https://github.com/Kendysond/Wordpress-paystack-forms
@@ -49,19 +48,13 @@ function enqueueStylesFix() {
4948
}
5049

5150

52-
/**
53-
* The code that runs during plugin activation.
54-
* This action is documented in includes/class-paystack-forms-activator.php
55-
*/
51+
5652
function activate_paystack_forms() {
5753
require_once plugin_dir_path( __FILE__ ) . 'includes/class-paystack-forms-activator.php';
5854
Paystack_Forms_Activator::activate();
5955
}
6056

61-
/**
62-
* The code that runs during plugin deactivation.
63-
* This action is documented in includes/class-paystack-forms-deactivator.php
64-
*/
57+
6558
function deactivate_paystack_forms() {
6659
require_once plugin_dir_path( __FILE__ ) . 'includes/class-paystack-forms-deactivator.php';
6760
Paystack_Forms_Deactivator::deactivate();
@@ -70,21 +63,9 @@ function deactivate_paystack_forms() {
7063
register_activation_hook( __FILE__, 'activate_paystack_forms' );
7164
register_deactivation_hook( __FILE__, 'deactivate_paystack_forms' );
7265

73-
/**
74-
* The core plugin class that is used to define internationalization,
75-
* admin-specific hooks, and public-facing site hooks.
76-
*/
66+
7767
require plugin_dir_path( __FILE__ ) . 'includes/class-paystack-forms.php';
7868

79-
/**
80-
* Begins execution of the plugin.
81-
*
82-
* Since everything within the plugin is registered via hooks,
83-
* then kicking off the plugin from this point in the file does
84-
* not affect the page life cycle.
85-
*
86-
* @since 1.0.0
87-
*/
8869
function run_paystack_forms() {
8970

9071
$plugin = new Paystack_Forms();
@@ -148,7 +129,7 @@ function invoice_url_rewrite(){
148129
global $wp_rewrite;
149130
$plugin_url = plugins_url( 'includes/paystack-invoice.php', __FILE__ );
150131
$plugin_url = substr( $plugin_url, strlen( home_url() ) + 1 );
151-
$wp_rewrite->non_wp_rules['paystackinvoice$'] = $plugin_url;
132+
$wp_rewrite->non_wp_rules['paystackinvoice.php$'] = $plugin_url;
152133
file_put_contents(ABSPATH.'.htaccess', $wp_rewrite->mod_rewrite_rules() );
153134
// $wp_rewrite->add_external_rule( 'paystackinvoice$', $plugin_url );
154135
}

0 commit comments

Comments
 (0)