1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WC_Payment_Gateway' ) ) {
class BKAP_Payment_Gateway extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'bkap-booking-gateway';
$this->icon = '';
$this->has_fields = false;
$this->method_title = __( 'Check Booking Availability', 'woocommerce-booking' );
$this->title = $this->method_title;
$this->order_button_text = __( 'Request Confirmation', 'woocommerce-booking' );
add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) );
}
public function admin_options() {
$title = ( ! empty( $this->method_title ) ) ? $this->method_title : __( 'Settings', 'woocommerce-booking' ) ;
echo '<h3>' . $title . '</h3>';
echo '<p>' . __( 'This is fictitious payment method used for bookings that require confirmation.', 'woocommerce-booking' ) . '</p>';
echo '<p>' . __( 'This gateway requires no configuration.', 'woocommerce-booking' ) . '</p>';
echo '<style>p.submit input[type="submit"] { display: none }</style>';
}
public function process_payment( $order_id ) {
$order = new WC_Order( $order_id );
update_post_meta( $order_id, '_bkap_pending_confirmation', '1' );
$order->add_order_note( __( 'This order is awaiting confirmation from the shop manager', 'woocommerce-booking' ) );
WC()->cart->empty_cart();
return array(
'result' => 'success',
'redirect' => $this->get_return_url( $order )
);
}
public function thankyou_page( $order_id ) {
$order = new WC_Order( $order_id );
if ( 'completed' == $order->get_status() ) {
echo '<p>' . __( 'Your booking has been confirmed. Thank you.', 'woocommerce-booking' ) . '</p>';
} else {
echo '<p>' . __( 'Your booking is awaiting confirmation. You will be notified by email as soon as we\'ve confirmed availability.', 'woocommerce-booking' ) . '</p>';
}
}
}
}