Version Description
(2020-06-11) = - Adds in error handling, and the ability to retry, for Stripe payments in RTU - Adds in options for bigger time intervals - Updated CSS for the admin settings pages - Localizing dates in the view bookings form
Download this release
Release Info
Developer | Rustaurius |
Plugin | Restaurant Reservations |
Version | 2.1.9 |
Comparing to | |
See all releases |
Code changes from version 2.1.8 to 2.1.9
- assets/css/admin.css +7 -1
- assets/js/booking-form.js +8 -6
- includes/Booking.class.php +12 -6
- includes/CustomPostTypes.class.php +25 -0
- includes/Settings.class.php +5 -0
- includes/WP_List_Table.BookingsTable.class.php +11 -0
- includes/template-functions.php +47 -19
- readme.txt +6 -0
- restaurant-reservations.php +1 -1
assets/css/admin.css
CHANGED
@@ -1887,7 +1887,8 @@ body.toplevel_page_rtb-bookings .rtb-admin-header-menu {
|
|
1887 |
z-index: 2;
|
1888 |
}
|
1889 |
.bookings_page_rtb-settings .wrap form .form-table {
|
1890 |
-
width:
|
|
|
1891 |
margin: 0 auto 16px;
|
1892 |
box-shadow: 0 1px 12px #ddd;
|
1893 |
display: block;
|
@@ -2594,3 +2595,8 @@ NEW STYLING FOR ADD/DELETE AREAS LIKE CUSTOM FIELDS
|
|
2594 |
margin-top: 12px;
|
2595 |
cursor: pointer;
|
2596 |
}
|
|
|
|
|
|
|
|
|
|
1887 |
z-index: 2;
|
1888 |
}
|
1889 |
.bookings_page_rtb-settings .wrap form .form-table {
|
1890 |
+
width: 100%;
|
1891 |
+
box-sizing: border-box;
|
1892 |
margin: 0 auto 16px;
|
1893 |
box-shadow: 0 1px 12px #ddd;
|
1894 |
display: block;
|
2595 |
margin-top: 12px;
|
2596 |
cursor: pointer;
|
2597 |
}
|
2598 |
+
|
2599 |
+
.bookings_page_rtb-settings .wrap form .form-table .sap-infinite-table input[type="number"],
|
2600 |
+
.bookings_page_rtb-settings .wrap form .form-table .sap-infinite-table input[type="text"] {
|
2601 |
+
width: 64px;
|
2602 |
+
}
|
assets/js/booking-form.js
CHANGED
@@ -175,7 +175,9 @@ jQuery(document).ready(function ($) {
|
|
175 |
|
176 |
$( '#rtb-party' ).on( 'change', function() {
|
177 |
rtb_booking_form.update_possible_tables();
|
178 |
-
})
|
|
|
|
|
179 |
}
|
180 |
};
|
181 |
|
@@ -473,9 +475,9 @@ jQuery(document).ready(function ($) {
|
|
473 |
}
|
474 |
}
|
475 |
|
476 |
-
rtb_booking_form.update_possible_tables = function() {
|
477 |
|
478 |
-
if ( rtb_pickadate.enable_tables ) {
|
479 |
|
480 |
var table_select = $('#rtb-table'),
|
481 |
party = $('#rtb-party').val(),
|
@@ -506,7 +508,7 @@ jQuery(document).ready(function ($) {
|
|
506 |
|
507 |
response = jQuery.parseJSON(response);
|
508 |
|
509 |
-
var available_tables = response.available_tables;
|
510 |
|
511 |
table_select.prop('disabled', false);
|
512 |
|
@@ -514,9 +516,9 @@ jQuery(document).ready(function ($) {
|
|
514 |
|
515 |
jQuery.each(available_tables, function(index, element) {
|
516 |
|
517 |
-
if ( index.indexOf( ',' ) === -1 ) { table_select.find('> option[value="' + index + '"]').show();
|
518 |
else {
|
519 |
-
table_select.append( '<option value="' + index + '">' + element + '</option>' );
|
520 |
}
|
521 |
|
522 |
});
|
175 |
|
176 |
$( '#rtb-party' ).on( 'change', function() {
|
177 |
rtb_booking_form.update_possible_tables();
|
178 |
+
});
|
179 |
+
|
180 |
+
rtb_booking_form.update_possible_tables();
|
181 |
}
|
182 |
};
|
183 |
|
475 |
}
|
476 |
}
|
477 |
|
478 |
+
rtb_booking_form.update_possible_tables = function() {
|
479 |
|
480 |
+
if ( rtb_pickadate.enable_tables ) {
|
481 |
|
482 |
var table_select = $('#rtb-table'),
|
483 |
party = $('#rtb-party').val(),
|
508 |
|
509 |
response = jQuery.parseJSON(response);
|
510 |
|
511 |
+
var available_tables = response.available_tables;
|
512 |
|
513 |
table_select.prop('disabled', false);
|
514 |
|
516 |
|
517 |
jQuery.each(available_tables, function(index, element) {
|
518 |
|
519 |
+
if ( index.indexOf( ',' ) === -1 ) { table_select.find('> option[value="' + index + '"]').show(); }
|
520 |
else {
|
521 |
+
table_select.append( '<option value="' + index + '">' + element + '</option>' );
|
522 |
}
|
523 |
|
524 |
});
|
includes/Booking.class.php
CHANGED
@@ -84,6 +84,7 @@ class rtbBooking {
|
|
84 |
'consent_acquired' => '',
|
85 |
'deposit' => '0',
|
86 |
'table' => '',
|
|
|
87 |
'receipt_id' => '',
|
88 |
'reminder_sent' => false,
|
89 |
'late_arrival_sent' => false,
|
@@ -106,6 +107,7 @@ class rtbBooking {
|
|
106 |
$this->consent_acquired = $meta['consent_acquired'];
|
107 |
$this->deposit = $meta['deposit'];
|
108 |
$this->table = $meta['table'];
|
|
|
109 |
$this->receipt_id = $meta['receipt_id'];
|
110 |
$this->late_arrival_sent = $meta['late_arrival_sent'];
|
111 |
$this->reminder_sent = $meta['reminder_sent'];
|
@@ -482,7 +484,7 @@ class rtbBooking {
|
|
482 |
|
483 |
// Table
|
484 |
$table = empty( $_POST['rtb-table'] ) ? array() : explode( ',', sanitize_text_field( stripslashes_deep( $_POST['rtb-table'] ) ) );
|
485 |
-
$this->table = is_array( $table ) ? array_map( '
|
486 |
|
487 |
$table_required = $rtb_controller->settings->get_setting( 'require-table' );
|
488 |
if ( $table_required && empty( $this->table ) ) {
|
@@ -518,7 +520,7 @@ class rtbBooking {
|
|
518 |
|
519 |
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secret_key) . '&response=' . urlencode($captcha);
|
520 |
$json_response = file_get_contents( $url );
|
521 |
-
$response = json_decode( $json_response );
|
522 |
|
523 |
if ( ! $response->success ) {
|
524 |
$this->validation_errors[] = array(
|
@@ -697,7 +699,7 @@ class rtbBooking {
|
|
697 |
if ( ! $this->table or ! is_array( $this->table ) ) { return false; }
|
698 |
|
699 |
$valid_tables = rtb_get_valid_tables( $this->date );
|
700 |
-
|
701 |
return $this->table == array_intersect( $this->table, $valid_tables );
|
702 |
}
|
703 |
|
@@ -745,7 +747,7 @@ class rtbBooking {
|
|
745 |
$current_times = array();
|
746 |
foreach ( $times as $time ) {
|
747 |
$current_times[] = $time;
|
748 |
-
|
749 |
if ( reset( $current_times ) < ($time - $dining_block_seconds) ) { array_shift( $current_times ); }
|
750 |
|
751 |
// Check if we've reached 1 below the max confirmation number, since adding the current booking will put us at the threshold
|
@@ -918,12 +920,16 @@ class rtbBooking {
|
|
918 |
$meta['logs'] = $this->logs;
|
919 |
}
|
920 |
|
|
|
|
|
|
|
|
|
921 |
if ( !empty( $this->deposit ) ) {
|
922 |
$meta['deposit'] = $this->deposit;
|
923 |
}
|
924 |
|
925 |
-
if ( !empty( $this->
|
926 |
-
$meta['
|
927 |
}
|
928 |
|
929 |
if ( !empty( $this->receipt_id ) ) {
|
84 |
'consent_acquired' => '',
|
85 |
'deposit' => '0',
|
86 |
'table' => '',
|
87 |
+
'payment_failure_message' => '',
|
88 |
'receipt_id' => '',
|
89 |
'reminder_sent' => false,
|
90 |
'late_arrival_sent' => false,
|
107 |
$this->consent_acquired = $meta['consent_acquired'];
|
108 |
$this->deposit = $meta['deposit'];
|
109 |
$this->table = $meta['table'];
|
110 |
+
$this->payment_failure_message = $meta['payment_failure_message'];
|
111 |
$this->receipt_id = $meta['receipt_id'];
|
112 |
$this->late_arrival_sent = $meta['late_arrival_sent'];
|
113 |
$this->reminder_sent = $meta['reminder_sent'];
|
484 |
|
485 |
// Table
|
486 |
$table = empty( $_POST['rtb-table'] ) ? array() : explode( ',', sanitize_text_field( stripslashes_deep( $_POST['rtb-table'] ) ) );
|
487 |
+
$this->table = is_array( $table ) ? array_map( 'sanitize_text_field', $table ) : array();
|
488 |
|
489 |
$table_required = $rtb_controller->settings->get_setting( 'require-table' );
|
490 |
if ( $table_required && empty( $this->table ) ) {
|
520 |
|
521 |
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secret_key) . '&response=' . urlencode($captcha);
|
522 |
$json_response = file_get_contents( $url );
|
523 |
+
$response = json_decode( $json_response );
|
524 |
|
525 |
if ( ! $response->success ) {
|
526 |
$this->validation_errors[] = array(
|
699 |
if ( ! $this->table or ! is_array( $this->table ) ) { return false; }
|
700 |
|
701 |
$valid_tables = rtb_get_valid_tables( $this->date );
|
702 |
+
|
703 |
return $this->table == array_intersect( $this->table, $valid_tables );
|
704 |
}
|
705 |
|
747 |
$current_times = array();
|
748 |
foreach ( $times as $time ) {
|
749 |
$current_times[] = $time;
|
750 |
+
|
751 |
if ( reset( $current_times ) < ($time - $dining_block_seconds) ) { array_shift( $current_times ); }
|
752 |
|
753 |
// Check if we've reached 1 below the max confirmation number, since adding the current booking will put us at the threshold
|
920 |
$meta['logs'] = $this->logs;
|
921 |
}
|
922 |
|
923 |
+
if ( !empty( $this->table ) ) {
|
924 |
+
$meta['table'] = $this->table;
|
925 |
+
}
|
926 |
+
|
927 |
if ( !empty( $this->deposit ) ) {
|
928 |
$meta['deposit'] = $this->deposit;
|
929 |
}
|
930 |
|
931 |
+
if ( !empty( $this->payment_failure_message ) ) {
|
932 |
+
$meta['payment_failure_message'] = $this->payment_failure_message;
|
933 |
}
|
934 |
|
935 |
if ( !empty( $this->receipt_id ) ) {
|
includes/CustomPostTypes.class.php
CHANGED
@@ -25,6 +25,7 @@ class rtbCustomPostTypes {
|
|
25 |
add_action( 'init', array( $this, 'set_booking_statuses' ) );
|
26 |
add_filter( 'rtb_post_statuses_args' , array( $this, 'add_arrived_status' ) );
|
27 |
add_filter( 'rtb_post_statuses_args' , array( $this, 'add_cancelled_status' ) );
|
|
|
28 |
|
29 |
// Display the count of pending bookings
|
30 |
add_action( 'admin_footer', array( $this, 'show_pending_count' ) );
|
@@ -203,6 +204,30 @@ class rtbCustomPostTypes {
|
|
203 |
return $booking_statuses;
|
204 |
}
|
205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
/**
|
207 |
* Print an HTML element to select a booking status
|
208 |
* @since 0.0.1
|
25 |
add_action( 'init', array( $this, 'set_booking_statuses' ) );
|
26 |
add_filter( 'rtb_post_statuses_args' , array( $this, 'add_arrived_status' ) );
|
27 |
add_filter( 'rtb_post_statuses_args' , array( $this, 'add_cancelled_status' ) );
|
28 |
+
add_filter( 'rtb_post_statuses_args' , array( $this, 'add_payment_failed_status' ) );
|
29 |
|
30 |
// Display the count of pending bookings
|
31 |
add_action( 'admin_footer', array( $this, 'show_pending_count' ) );
|
204 |
return $booking_statuses;
|
205 |
}
|
206 |
|
207 |
+
/**
|
208 |
+
* @since 2.1.9
|
209 |
+
* Adds in a "Payment Failed" status if the option to require deposits when
|
210 |
+
* booking a reservation has been toggled on.
|
211 |
+
*/
|
212 |
+
public function add_payment_failed_status( $booking_statuses = array() ) {
|
213 |
+
global $rtb_controller;
|
214 |
+
|
215 |
+
if ( $rtb_controller->settings->get_setting( 'require-deposit' ) ) {
|
216 |
+
$booking_statuses['payment_failed'] = array(
|
217 |
+
'label' => _x( 'Payment Failed', 'The guest has tried to make a payment but it was declined.', 'restaurant-reservations' ),
|
218 |
+
'default' => false, // Whether or not this status is part of WP Core
|
219 |
+
'user_selectable' => false, // Whether or not a user can set a booking to this status
|
220 |
+
'public' => false,
|
221 |
+
'exclude_from_search' => true,
|
222 |
+
'show_in_admin_all_list' => true,
|
223 |
+
'show_in_admin_status_list' => true,
|
224 |
+
'label_count' => _n_noop( 'Payment Failed <span class="count">(%s)</span>', 'Payment Failed <span class="count">(%s)</span>', 'restaurant-reservations' )
|
225 |
+
);
|
226 |
+
}
|
227 |
+
|
228 |
+
return $booking_statuses;
|
229 |
+
}
|
230 |
+
|
231 |
/**
|
232 |
* Print an HTML element to select a booking status
|
233 |
* @since 0.0.1
|
includes/Settings.class.php
CHANGED
@@ -789,6 +789,11 @@ If you were not the one to cancel this booking, please contact us.
|
|
789 |
'description' => __( 'Select the number of minutes between each available time.', 'restaurant-reservations' ),
|
790 |
'blank_option' => false,
|
791 |
'options' => array(
|
|
|
|
|
|
|
|
|
|
|
792 |
'' => __( 'Every 30 minutes', 'restaurant-reservations' ),
|
793 |
'15' => __( 'Every 15 minutes', 'restaurant-reservations' ),
|
794 |
'10' => __( 'Every 10 minutes', 'restaurant-reservations' ),
|
789 |
'description' => __( 'Select the number of minutes between each available time.', 'restaurant-reservations' ),
|
790 |
'blank_option' => false,
|
791 |
'options' => array(
|
792 |
+
'180' => __( 'Every 180 minutes', 'restaurant-reservations' ),
|
793 |
+
'120' => __( 'Every 120 minutes', 'restaurant-reservations' ),
|
794 |
+
'90' => __( 'Every 90 minutes', 'restaurant-reservations' ),
|
795 |
+
'60' => __( 'Every 60 minutes', 'restaurant-reservations' ),
|
796 |
+
'45' => __( 'Every 45 minutes', 'restaurant-reservations' ),
|
797 |
'' => __( 'Every 30 minutes', 'restaurant-reservations' ),
|
798 |
'15' => __( 'Every 15 minutes', 'restaurant-reservations' ),
|
799 |
'10' => __( 'Every 10 minutes', 'restaurant-reservations' ),
|
includes/WP_List_Table.BookingsTable.class.php
CHANGED
@@ -286,6 +286,10 @@ class rtbBookingsTable extends WP_List_Table {
|
|
286 |
'trash' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( 'status' => 'trash', 'paged' => FALSE ), $this->query_string ) ), $current === 'trash' ? ' class="current"' : '', __( 'Trash', 'restaurant-reservations' ) . ' <span class="count">(' . $this->booking_counts['trash'] . ')</span>' ),
|
287 |
);
|
288 |
|
|
|
|
|
|
|
|
|
289 |
return apply_filters( 'rtb_bookings_table_views_status', $views );
|
290 |
}
|
291 |
|
@@ -479,6 +483,13 @@ class rtbBookingsTable extends WP_List_Table {
|
|
479 |
);
|
480 |
}
|
481 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
$details = apply_filters( 'rtb_bookings_table_column_details', $details, $booking );
|
483 |
|
484 |
if ( !empty( $details ) ) {
|
286 |
'trash' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( 'status' => 'trash', 'paged' => FALSE ), $this->query_string ) ), $current === 'trash' ? ' class="current"' : '', __( 'Trash', 'restaurant-reservations' ) . ' <span class="count">(' . $this->booking_counts['trash'] . ')</span>' ),
|
287 |
);
|
288 |
|
289 |
+
if ( isset( $this->booking_counts['payment_failed'] ) and $this->booking_counts['payment_failed'] > 0 ) {
|
290 |
+
array_splice($views, 3, 0, array( 'payment_failed' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array( 'status' => 'payment_failed', 'paged' => FALSE ), $this->query_string ) ), $current === 'payment_failed' ? ' class="current"' : '', __( 'Payment Failed', 'restaurant-reservations' ) . ' <span class="count">(' . $this->booking_counts['payment_failed'] . ')</span>' ), ) );
|
291 |
+
}
|
292 |
+
|
293 |
return apply_filters( 'rtb_bookings_table_views_status', $views );
|
294 |
}
|
295 |
|
483 |
);
|
484 |
}
|
485 |
|
486 |
+
if ( $booking->post_status == 'payment_failed' ) {
|
487 |
+
$details[] = array(
|
488 |
+
'label' => 'Payment Failure Reason',
|
489 |
+
'value' => isset( $booking->payment_failure_message ) ? $booking->payment_failure_message : 'Unknown payment failure reason. Check with payment processor.'
|
490 |
+
);
|
491 |
+
}
|
492 |
+
|
493 |
$details = apply_filters( 'rtb_bookings_table_column_details', $details, $booking );
|
494 |
|
495 |
if ( !empty( $details ) ) {
|
includes/template-functions.php
CHANGED
@@ -99,8 +99,10 @@ function rtb_print_booking_form( $args = array() ) {
|
|
99 |
<div class="rtb-booking-form">
|
100 |
<?php if ( ( $rtb_controller->request->request_inserted === true and ! $rtb_controller->settings->get_setting( 'require-deposit' ) ) or ( isset($_GET['payment']) and $_GET['payment'] == 'paid' ) ) : ?>
|
101 |
|
|
|
|
|
102 |
<?php
|
103 |
-
if ( $
|
104 |
if( $rtb_controller->settings->get_setting('confirmed-redirect-page') != '' ){
|
105 |
header( 'Location:' . $rtb_controller->settings->get_setting('confirmed-redirect-page') );
|
106 |
}
|
@@ -126,14 +128,15 @@ function rtb_print_booking_form( $args = array() ) {
|
|
126 |
}
|
127 |
?>
|
128 |
|
129 |
-
<?php elseif ( $rtb_controller->request->request_inserted === true ) : ?>
|
130 |
-
<?php rtb_print_payment_form(); ?>
|
131 |
<?php elseif ( isset($_POST['stripeToken']) ) : ?>
|
132 |
<?php rtb_process_stripe_payment(); ?>
|
133 |
-
<?php elseif ( isset($_GET['payment']) ) : ?>
|
134 |
-
|
135 |
-
<
|
136 |
-
|
|
|
|
|
|
|
137 |
<?php elseif ( isset($_GET['bookingCancelled']) and $_GET['bookingCancelled'] == 'success') : ?>
|
138 |
<div class="rtb-message">
|
139 |
<p><?php _e( 'Your reservation has been successfully cancelled.', 'restaurant-reservations' ) ?></p>
|
@@ -251,7 +254,7 @@ function rtb_print_payment_form( $args = array() ) {
|
|
251 |
<input type='submit' class='submit-button' value='Pay via PayPal' />
|
252 |
</form>
|
253 |
<?php } else {
|
254 |
-
wp_enqueue_script( 'rtb-stripe',
|
255 |
wp_enqueue_script( 'rtb-stripe-payment', RTB_PLUGIN_URL . '/assets/js/stripe-payment.js', array( 'jquery', 'rtb-stripe' ), RTB_VERSION, true );
|
256 |
|
257 |
wp_localize_script(
|
@@ -263,12 +266,18 @@ function rtb_print_payment_form( $args = array() ) {
|
|
263 |
'test_publishable_key' => $rtb_controller->settings->get_setting( 'rtb-stripe-test-publishable' ),
|
264 |
)
|
265 |
);
|
|
|
|
|
|
|
|
|
266 |
|
267 |
-
$payment_amount = $rtb_controller->settings->get_setting( 'rtb-currency-symbol-location' ) == 'before' ? $rtb_controller->settings->get_setting( 'rtb-stripe-currency-symbol' ) . $
|
268 |
?>
|
269 |
|
270 |
<h2><?php echo __('Deposit Required: ', 'restaurant-reservations' ) . $payment_amount; ?></h2>
|
271 |
|
|
|
|
|
272 |
<form action='#' method='POST' id='stripe-payment-form'>
|
273 |
<div class='form-row'>
|
274 |
<label><?php _e('Card Number', 'restaurant-reservations'); ?></label>
|
@@ -286,8 +295,8 @@ function rtb_print_payment_form( $args = array() ) {
|
|
286 |
</div>
|
287 |
<input type='hidden' name='action' value='rtb_stripe_booking_payment'/>
|
288 |
<input type='hidden' name='currency' value='<?php echo $rtb_controller->settings->get_setting( 'rtb-currency' ); ?>' data-stripe='currency' />
|
289 |
-
<input type='hidden' name='payment_amount' value='<?php echo $
|
290 |
-
<input type='hidden' name='booking_id' value='<?php echo $
|
291 |
<button type='submit' id='stripe-submit'><?php _e( 'Make Deposit', 'restaurant-reservations'); ?></button>
|
292 |
</form>
|
293 |
<?php }
|
@@ -324,6 +333,10 @@ function rtb_process_stripe_payment() {
|
|
324 |
|
325 |
$stripe_secret = $rtb_controller->settings->get_setting( 'rtb-stripe-mode' ) == 'test' ? $rtb_controller->settings->get_setting( 'rtb-stripe-test-secret' ) : $rtb_controller->settings->get_setting( 'rtb-stripe-live-secret' );
|
326 |
|
|
|
|
|
|
|
|
|
327 |
try {
|
328 |
\Stripe\Stripe::setApiKey( $stripe_secret );
|
329 |
$charge = \Stripe\Charge::create(array(
|
@@ -333,10 +346,6 @@ function rtb_process_stripe_payment() {
|
|
333 |
)
|
334 |
);
|
335 |
|
336 |
-
require_once( RTB_PLUGIN_DIR . '/includes/Booking.class.php' );
|
337 |
-
$booking = new rtbBooking();
|
338 |
-
$booking->load_post( $booking_id );
|
339 |
-
|
340 |
$booking->deposit = ( $rtb_controller->settings->get_setting( 'rtb-currency' ) != "JPY" ? $payment_amount / 100 : $payment_amount );
|
341 |
$booking->receipt_id = $charge->id;
|
342 |
|
@@ -345,11 +354,30 @@ function rtb_process_stripe_payment() {
|
|
345 |
$booking->insert_post_data();
|
346 |
|
347 |
// redirect on successful payment
|
348 |
-
$redirect = add_query_arg(
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
|
350 |
-
} catch (Exception $e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
// redirect on failed payment
|
352 |
-
$redirect = add_query_arg(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
}
|
354 |
|
355 |
// redirect back to our previous page with the added query variable
|
@@ -571,7 +599,7 @@ function rtb_print_view_bookings_form( $args = array() ) {
|
|
571 |
<select class='rtb-view-bookings-form-date-selector'>
|
572 |
<?php for ( $i=0; $i<7; $i++ ) { ?>
|
573 |
<?php $timestamp = time() + $i * 3600*24; ?>
|
574 |
-
<option value='<?php echo
|
575 |
<?php } ?>
|
576 |
</select>
|
577 |
</div>
|
99 |
<div class="rtb-booking-form">
|
100 |
<?php if ( ( $rtb_controller->request->request_inserted === true and ! $rtb_controller->settings->get_setting( 'require-deposit' ) ) or ( isset($_GET['payment']) and $_GET['payment'] == 'paid' ) ) : ?>
|
101 |
|
102 |
+
<?php $post_status = isset($_GET['booking_id']) ? get_post_status( intval( $_GET['booking_id'] ) ) : $rtb_controller->request->post_status; ?>
|
103 |
+
|
104 |
<?php
|
105 |
+
if ( $post_status == 'confirmed' ) {
|
106 |
if( $rtb_controller->settings->get_setting('confirmed-redirect-page') != '' ){
|
107 |
header( 'Location:' . $rtb_controller->settings->get_setting('confirmed-redirect-page') );
|
108 |
}
|
128 |
}
|
129 |
?>
|
130 |
|
|
|
|
|
131 |
<?php elseif ( isset($_POST['stripeToken']) ) : ?>
|
132 |
<?php rtb_process_stripe_payment(); ?>
|
133 |
+
<?php elseif ( $rtb_controller->request->request_inserted === true or isset($_GET['payment']) ) : ?>
|
134 |
+
<?php if ( isset($_GET['payment']) ) { ?>
|
135 |
+
<div class="rtb-message">
|
136 |
+
<p><?php printf( __( 'Your reservation deposit payment has failed with the following message "%s" Please contact the site administrator for assistance.', 'restaurant-reservations' ), isset( $_GET['error_code'] ) ? esc_html( urldecode( $_GET['error_code'] ) ) : ' unknown error.' ); ?></p>
|
137 |
+
</div>
|
138 |
+
<?php } ?>
|
139 |
+
<?php rtb_print_payment_form(); ?>
|
140 |
<?php elseif ( isset($_GET['bookingCancelled']) and $_GET['bookingCancelled'] == 'success') : ?>
|
141 |
<div class="rtb-message">
|
142 |
<p><?php _e( 'Your reservation has been successfully cancelled.', 'restaurant-reservations' ) ?></p>
|
254 |
<input type='submit' class='submit-button' value='Pay via PayPal' />
|
255 |
</form>
|
256 |
<?php } else {
|
257 |
+
wp_enqueue_script( 'rtb-stripe', 'https://js.stripe.com/v2/', array( 'jquery' ), RTB_VERSION, true );
|
258 |
wp_enqueue_script( 'rtb-stripe-payment', RTB_PLUGIN_URL . '/assets/js/stripe-payment.js', array( 'jquery', 'rtb-stripe' ), RTB_VERSION, true );
|
259 |
|
260 |
wp_localize_script(
|
266 |
'test_publishable_key' => $rtb_controller->settings->get_setting( 'rtb-stripe-test-publishable' ),
|
267 |
)
|
268 |
);
|
269 |
+
|
270 |
+
require_once( RTB_PLUGIN_DIR . '/includes/Booking.class.php' );
|
271 |
+
$booking = new rtbBooking();
|
272 |
+
$booking->load_post( isset( $_GET['booking_id'] ) ? intval( $_GET['booking_id'] ) : $rtb_controller->request->ID );
|
273 |
|
274 |
+
$payment_amount = $rtb_controller->settings->get_setting( 'rtb-currency-symbol-location' ) == 'before' ? $rtb_controller->settings->get_setting( 'rtb-stripe-currency-symbol' ) . $booking->calculate_deposit() : $booking->calculate_deposit() . $rtb_controller->settings->get_setting( 'rtb-stripe-currency-symbol' );
|
275 |
?>
|
276 |
|
277 |
<h2><?php echo __('Deposit Required: ', 'restaurant-reservations' ) . $payment_amount; ?></h2>
|
278 |
|
279 |
+
<div class='payment-errors'></div>
|
280 |
+
|
281 |
<form action='#' method='POST' id='stripe-payment-form'>
|
282 |
<div class='form-row'>
|
283 |
<label><?php _e('Card Number', 'restaurant-reservations'); ?></label>
|
295 |
</div>
|
296 |
<input type='hidden' name='action' value='rtb_stripe_booking_payment'/>
|
297 |
<input type='hidden' name='currency' value='<?php echo $rtb_controller->settings->get_setting( 'rtb-currency' ); ?>' data-stripe='currency' />
|
298 |
+
<input type='hidden' name='payment_amount' value='<?php echo $booking->calculate_deposit(); ?>' />
|
299 |
+
<input type='hidden' name='booking_id' value='<?php echo $booking->ID; ?>' />
|
300 |
<button type='submit' id='stripe-submit'><?php _e( 'Make Deposit', 'restaurant-reservations'); ?></button>
|
301 |
</form>
|
302 |
<?php }
|
333 |
|
334 |
$stripe_secret = $rtb_controller->settings->get_setting( 'rtb-stripe-mode' ) == 'test' ? $rtb_controller->settings->get_setting( 'rtb-stripe-test-secret' ) : $rtb_controller->settings->get_setting( 'rtb-stripe-live-secret' );
|
335 |
|
336 |
+
require_once( RTB_PLUGIN_DIR . '/includes/Booking.class.php' );
|
337 |
+
$booking = new rtbBooking();
|
338 |
+
$booking->load_post( $booking_id );
|
339 |
+
|
340 |
try {
|
341 |
\Stripe\Stripe::setApiKey( $stripe_secret );
|
342 |
$charge = \Stripe\Charge::create(array(
|
346 |
)
|
347 |
);
|
348 |
|
|
|
|
|
|
|
|
|
349 |
$booking->deposit = ( $rtb_controller->settings->get_setting( 'rtb-currency' ) != "JPY" ? $payment_amount / 100 : $payment_amount );
|
350 |
$booking->receipt_id = $charge->id;
|
351 |
|
354 |
$booking->insert_post_data();
|
355 |
|
356 |
// redirect on successful payment
|
357 |
+
$redirect = add_query_arg(
|
358 |
+
array(
|
359 |
+
'payment' => 'paid',
|
360 |
+
'booking_id' => $booking_id
|
361 |
+
),
|
362 |
+
$booking_page
|
363 |
+
);
|
364 |
|
365 |
+
} catch (Exception $e) {
|
366 |
+
|
367 |
+
$booking->post_status = 'payment_failed';
|
368 |
+
$booking->payment_failure_message = $e->getDeclineCode();
|
369 |
+
|
370 |
+
$booking->insert_post_data();
|
371 |
+
|
372 |
// redirect on failed payment
|
373 |
+
$redirect = add_query_arg(
|
374 |
+
array(
|
375 |
+
'payment' => 'failed',
|
376 |
+
'booking_id' => $booking_id,
|
377 |
+
'error_code' => urlencode( $e->getDeclineCode() )
|
378 |
+
),
|
379 |
+
$booking_page
|
380 |
+
);
|
381 |
}
|
382 |
|
383 |
// redirect back to our previous page with the added query variable
|
599 |
<select class='rtb-view-bookings-form-date-selector'>
|
600 |
<?php for ( $i=0; $i<7; $i++ ) { ?>
|
601 |
<?php $timestamp = time() + $i * 3600*24; ?>
|
602 |
+
<option value='<?php echo date_i18n('Y-m-d', $timestamp); ?>' <?php echo ( date_i18n('Y-m-d', $timestamp) == $args['date'] ? 'selected="selected"' : '' ); ?> ><?php echo date_i18n('l, F jS', $timestamp); ?></option>
|
603 |
<?php } ?>
|
604 |
</select>
|
605 |
</div>
|
readme.txt
CHANGED
@@ -196,6 +196,12 @@ Find answers to even more questions in the [FAQ](http://doc.fivestarplugins.com/
|
|
196 |
|
197 |
== Changelog ==
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
= 2.1.8 (2020-06-08) =
|
200 |
- Fixes an invalid foreach warning that was displaying
|
201 |
- Fixes an pagination issue on the Bookings admin page
|
196 |
|
197 |
== Changelog ==
|
198 |
|
199 |
+
= 2.1.9 (2020-06-11) =
|
200 |
+
- Adds in error handling, and the ability to retry, for Stripe payments in RTU
|
201 |
+
- Adds in options for bigger time intervals
|
202 |
+
- Updated CSS for the admin settings pages
|
203 |
+
- Localizing dates in the view bookings form
|
204 |
+
|
205 |
= 2.1.8 (2020-06-08) =
|
206 |
- Fixes an invalid foreach warning that was displaying
|
207 |
- Fixes an pagination issue on the Bookings admin page
|
restaurant-reservations.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Five Star Restaurant Reservations - WordPress Booking Plugin
|
4 |
* Plugin URI: http://www.fivestarplugins.com/plugins/five-star-restaurant-reservations/
|
5 |
* Description: Restaurant reservations made easy. Accept bookings online. Quickly confirm or reject reservations, send email notifications, set booking times and more.
|
6 |
-
* Version: 2.1.
|
7 |
* Author: FiveStarPlugins
|
8 |
* Author URI: https://profiles.wordpress.org/fivestarplugins/
|
9 |
* Text Domain: restaurant-reservations
|
3 |
* Plugin Name: Five Star Restaurant Reservations - WordPress Booking Plugin
|
4 |
* Plugin URI: http://www.fivestarplugins.com/plugins/five-star-restaurant-reservations/
|
5 |
* Description: Restaurant reservations made easy. Accept bookings online. Quickly confirm or reject reservations, send email notifications, set booking times and more.
|
6 |
+
* Version: 2.1.9
|
7 |
* Author: FiveStarPlugins
|
8 |
* Author URI: https://profiles.wordpress.org/fivestarplugins/
|
9 |
* Text Domain: restaurant-reservations
|