Making WordPress.org

Ticket #3226: 3226.patch

File 3226.patch, 13.8 KB (added by codexdemon, 7 years ago)

Fixed Issue blocking registration on Word Camp Nashik

  • inc/class-camptix-payment-methods.php

     
    8686                ?>
    8787                <tr class="tix-row-phone">
    8888                        <td class="tix-required tix-left">
    89                                 <?php _e( 'Phone Number', 'campt-indian-payment-gateway' ); ?>
     89                                <?php esc_html_e( 'Phone Number', 'campt-indian-payment-gateway' ); ?>
    9090                                <span class="tix-required-star">*</span>
    9191                        </td>
    9292                        <?php $value = isset( $form_data['tix_attendee_info'][ $current_count ]['phone'] ) ? $form_data['tix_attendee_info'][ $current_count ]['phone'] : ''; ?>
     
    176176                ?>
    177177                <tr>
    178178                        <td class="tix-required tix-left">
    179                                 <?php _e( 'Phone Number', 'campt-indian-payment-gateway' ); ?>
     179                                <?php esc_html_e( 'Phone Number', 'campt-indian-payment-gateway' ); ?>
    180180                                <span class="tix-required-star">*</span></td>
    181181                        <td class="tix-right">
    182182                                <input name="tix_ticket_info[phone]" type="text" value="<?php echo esc_attr( get_post_meta( $attendee->ID, 'tix_phone', true ) ); ?>"/>
  • inc/razorpay/class-camptix-payment-method-razorpay.php

     
    104104         * @access public
    105105         */
    106106        public function enqueue() {
     107
     108                if ( ! isset( $_GET['tix_action'] ) || ( 'attendee_info' !== $_GET['tix_action'] ) ) {
     109                        return;
     110                }
     111
     112                wp_register_script( 'camptix-indian-payments-main-razorpayjs', CAMPTIX_MULTI_URL . 'assets/js/camptix-multi-popup-razorpay.js', array( 'jquery' ), false, CAMPTIX_INDIAN_PAYMENTS_VERSION );
     113                wp_enqueue_script( 'camptix-indian-payments-main-razorpayjs' );
     114
     115                $data = apply_filters(
     116                        'camptix_indian_payments_localize_vars',
     117                        array(
     118                                'errors' => array(
     119                                        'phone' => __( 'Please fill in all required fields.', 'campt-indian-payment-gateway' ),
     120                                ),
     121                        )
     122                );
     123
     124                wp_localize_script( 'camptix-indian-payments-main-razorpayjs', 'camptix_inr_vars', $data );
     125
     126
    107127                wp_register_script( 'razorpay-js', 'https://checkout.razorpay.com/v1/checkout-new.js' );
    108128                wp_enqueue_script( 'razorpay-js' );
    109129        }
     
    513533
    514534                return $order_info;
    515535        }
    516 }
    517  No newline at end of file
     536}
  • readme.txt

     
    33Tags:              camptix, camptix payment, event ticketing, razorpay, instamojo, Indian payment, camptix Indian gateway, camptix payment gateway
    44Requires at least: 3.5
    55Tested up to:      4.8
    6 Stable tag:        1.4
     6Stable tag:        1.6
    77License:           GPLv2 or later
    88License URI:       http://www.gnu.org/licenses/gpl-2.0.html
    99
     
    46462. Razorpay Enable
    4747
    4848== Changelog ==
     49=1.5=
     50JavaScript breaks registration flow for Instamojo #41 Fixed
     51
    4952=1.4=
    5053Fixed Text domain and Language Translation Bug Fixed
    5154
  • assets/js/camptix-multi-popup.js

     
    1 /**
    2  * Give - Razorpay Popup Checkout JS
    3  */
    4 var camptix_l10n, camptix_inr_vars;
    5 
    6 /**
    7  * On document ready setup Razorpay events.
    8  */
    9 jQuery(document).ready(function ($) {
    10         // Cache donation button title early to reset it if razorpay checkout popup close.
    11         var razorpay_handler = [],
    12                 $container       = $('#tix'),
    13                 $form            = $('form', $container),
    14                 ticket_quantity  = $('.tix_tickets_table td.tix-column-quantity', $container).text(),
    15                 order_id         = $('input[name="razorpay_order_id"]', $form).val(),
    16                 receipt_id       = $('input[name="razorpay_receipt_id"]', $form).val();
    17 
    18         /**
    19          * Validate extra attendee information fields.
    20          *
    21          * @returns {boolean}
    22          */
    23         var validate_fields = function () {
    24                 for (var i = 1; i <= ticket_quantity; i++) {
    25                         if (!$('input[name="tix_attendee_info[' + i + '][phone]"]', $form).val()) {
    26                                 return false;
    27                         }
    28                 }
    29                 return true;
    30         };
    31 
    32         /**
    33          * Show errors.
    34          *
    35          * @param error_html
    36          */
    37         var show_errors = function (error_html) {
    38                 var $errors = '';
    39 
    40                 // Remove old errors html.
    41                 $('#tix-errors', $container).remove();
    42 
    43                 // Set new error html.
    44                 $errors = $('<div id="tix-errors"></div>').html(error_html);
    45                 $container.prepend($errors);
    46 
    47                 // Scroll to error div.
    48                 $('html,body').animate({
    49                                 scrollTop: $container.offset().top
    50                         },
    51                         'slow'
    52                 );
    53         };
    54 
    55         /**
    56          * Show/ Hide extra attendee fields.
    57          *
    58          * @param show
    59          */
    60         var show_custom_attendee_fields = function (show) {
    61                 var $field_container;
    62 
    63                 for (var i = 1; i <= 2; i++) {
    64                         $field_container = $('input[name="tix_attendee_info[' + i + '][phone]"]', $form).closest('tr');
    65 
    66                         if (show) {
    67                                 $field_container.show();
    68                         } else {
    69                                 $field_container.hide();
    70                         }
    71                 }
    72         };
    73 
    74         /**
    75          * Show extra attendee fields only if razorpay selected
    76          */
    77         $('select[name="tix_payment_method"]', $form).on('change', function () {
    78                
    79         }).change();
    80 
    81         /**
    82          * Increase razorpay's z-index to appear above of all content.
    83          */
    84         $('.razorpay-container').css('z-index', '2147483543');
    85 
    86         /**
    87          * On form submit prevent submission for Razorpay only.
    88          */
    89         $form.on('submit', function (e) {
    90            
    91             var phone = $('.mobile').val();
    92         console.log(phone);
    93         phone = phone.replace(/[^0-9]/g,'');
    94 
    95         if(!($.isNumeric(phone))){
    96                 console.log('test');
    97             $('.message').text('Please Enter Only Numbers');
    98             $('.message').css('color','red');
    99             $('.mobile').val('');
    100             $('.mobile').focus();
    101             e.preventDefault();
    102                 return false;
    103         }else
    104         if (phone.length < 10 )
    105         {
    106                 console.log('test');
    107             //alert('Phone number must be 10 digits.');
    108             $('.message').text('Please Enter correct Mobile Number Or Number with STD Code');
    109             $('.message').css('color','red');
    110             $('.mobile').val('');
    111             $('.mobile').focus();
    112             //alert();
    113             e.preventDefault();
    114 
    115                 return false;
    116 
    117         }
    118      
    119                 // Bailout.
    120                 if (camptix_inr_vars.gateway_id !== $('select[name="tix_payment_method"]', $form).val()) {
    121                         return true;
    122                 }
    123 
    124                 e.preventDefault();
    125 
    126                 return false;
    127         });
    128 
    129         /**
    130          * When the submit button is clicked.
    131          */
    132         $form.on('click touchend', 'input[type="submit"]', function (e) {
    133                 // Bailout.
    134                 if (camptix_inr_vars.gateway_id !== $('select[name="tix_payment_method"]', $form).val()) {
    135                         return true;
    136                 }
    137 
    138                 e.preventDefault();
    139 
    140                 // Validate custom attendee information fields.
    141                 if (!validate_fields()) {
    142                         show_errors('<div class="tix-error">' + camptix_inr_vars.errors.phone + '</div>');
    143 
    144                         return false;
    145                 }
    146 
    147                 var $submit_button = $(this),
    148                         $response;
    149 
    150                 $.post($form.attr('action'), $form.serialize())
    151                         .done(function (response) {
    152                                 // Bailout.
    153                                 if (!response.success) {
    154                                         var $el = $('<div></div>').html(response);
    155 
    156                                         show_errors($('#tix-errors', $el).html());
    157 
    158                                         return false;
    159                                 }
    160 
    161                                 // Cache response for internal use in Razorpay.
    162                                 $response = response;
    163 
    164                                 razorpay_handler = new Razorpay({
    165                                         'key'     : camptix_inr_vars.merchant_key_id,
    166                                         'order_id': order_id,
    167                                         'name'    : $response.data.popup_title,
    168                                         'image'   : camptix_inr_vars.popup.image,
    169                                         // 'description' : '',
    170                                         'handler' : function (response) {
    171                                                 // Remove loading animations.
    172                                                 // $form.find('.give-loading-animation').hide();
    173                                                 // Disable form submit button.
    174                                                 $submit_button.prop('disabled', true);
    175 
    176                                                 // Submit form after charge token brought back from Razorpay.
    177                                                 // Redirect to success page.
    178                                                 window.location.assign($response.data.return_url + '&transaction_id=' + order_id + '&receipt_id=' + receipt_id);
    179                                         },
    180 
    181                                         // You can add custom data here and fields limited to 15.
    182                                         // 'notes': {
    183                                         // 'extra_information' : $response.data
    184                                         // },
    185                                         'prefill': {
    186                                                 'name'   : $response.data.fullname,
    187                                                 'email'  : $response.data.email,
    188                                                 'contact': $response.data.phone
    189                                         },
    190 
    191                                         'modal': {
    192                                                 'ondismiss': function () {
    193                                                         // Remove loading animations.
    194                                                         $form.find('.give-loading-animation').hide();
    195 
    196                                                         // Re-enable submit button and add back text.
    197                                                         $submit_button.prop('disabled', false);
    198                                                 }
    199                                         },
    200 
    201                                         'theme': {
    202                                                 'color'        : camptix_inr_vars.popup.color,
    203                                                 'image_padding': false
    204                                         }
    205                                 });
    206 
    207                                 razorpay_handler.open();
    208                         })
    209                         .fail(function () {
    210                         })
    211                         .always(function () {
    212                                 // Enable form submit button.
    213                                 $submit_button.prop('disabled', false);
    214                         });
    215 
    216                 return false;
    217         });
    218 });
     1/**
     2 * Give - Razorpay Popup Checkout JS
     3 */
     4var camptix_l10n, camptix_inr_vars;
     5
     6/**
     7 * On document ready setup Razorpay events.
     8 */
     9jQuery(document).ready(function ($) {
     10        // Cache donation button title early to reset it if razorpay checkout popup close.
     11        var razorpay_handler = [],
     12                $container       = $('#tix'),
     13                $form            = $('form', $container),
     14                ticket_quantity  = $('.tix_tickets_table td.tix-column-quantity', $container).text(),
     15                order_id         = $('input[name="razorpay_order_id"]', $form).val(),
     16                receipt_id       = $('input[name="razorpay_receipt_id"]', $form).val();
     17
     18        /**
     19         * Validate extra attendee information fields.
     20         *
     21         * @returns {boolean}
     22         */
     23        var validate_fields = function () {
     24                for (var i = 1; i <= ticket_quantity; i++) {
     25                        if (!$('input[name="tix_attendee_info[' + i + '][phone]"]', $form).val()) {
     26                                return false;
     27                        }
     28                }
     29                return true;
     30        };
     31
     32        /**
     33         * Show errors.
     34         *
     35         * @param error_html
     36         */
     37        var show_errors = function (error_html) {
     38                var $errors = '';
     39
     40                // Remove old errors html.
     41                $('#tix-errors', $container).remove();
     42
     43                // Set new error html.
     44                $errors = $('<div id="tix-errors"></div>').html(error_html);
     45                $container.prepend($errors);
     46
     47                // Scroll to error div.
     48                $('html,body').animate({
     49                                scrollTop: $container.offset().top
     50                        },
     51                        'slow'
     52                );
     53        };
     54
     55        /**
     56         * Show/ Hide extra attendee fields.
     57         *
     58         * @param show
     59         */
     60        var show_custom_attendee_fields = function (show) {
     61                var $field_container;
     62
     63                for (var i = 1; i <= 2; i++) {
     64                        $field_container = $('input[name="tix_attendee_info[' + i + '][phone]"]', $form).closest('tr');
     65
     66                        if (show) {
     67                                $field_container.show();
     68                        } else {
     69                                $field_container.hide();
     70                        }
     71                }
     72        };
     73
     74        /**
     75         * Show extra attendee fields only if razorpay selected
     76         */
     77        $('select[name="tix_payment_method"]', $form).on('change', function () {
     78               
     79        }).change();
     80
     81        /**
     82         * Increase razorpay's z-index to appear above of all content.
     83         */
     84        $('.razorpay-container').css('z-index', '2147483543');
     85
     86        /**
     87         * On form submit prevent submission for Razorpay only.
     88         */
     89        $form.on('submit', function (e) {
     90           
     91            var phone = $('.mobile').val();
     92        phone = phone.replace(/[^0-9]/g,'');
     93
     94        if(!($.isNumeric(phone))){
     95            $('.message').text('Please Enter Only Numbers');
     96            $('.message').css('color','red');
     97            $('.mobile').val('');
     98            $('.mobile').focus();
     99            e.preventDefault();
     100                return false;
     101        }else
     102        if (phone.length < 10 )
     103        {
     104            //alert('Phone number must be 10 digits.');
     105            $('.message').text('Please Enter correct Mobile Number Or Number with STD Code');
     106            $('.message').css('color','red');
     107            $('.mobile').val('');
     108            $('.mobile').focus();
     109            //alert();
     110            e.preventDefault();
     111
     112                return false;
     113
     114        }
     115        return true;
     116                // Bailout.
     117        });
     118});
  • inc/instamojo/class-camptix-payment-method-instamojo.php

     
    299299                        $json_decode = json_decode( $response['body']);
    300300                        $long_url = $json_decode->payment_request->longurl;
    301301                        header( 'Location:' . $long_url );
    302                 }else{
    303                 echo 'Invalid Insatmojo Access Key & Token';
    304                 return;
     302                } else {
     303                        echo __( 'Invalid Insatmojo Access Key & Token', 'campt-indian-payment-gateway' );
     304                        return;
    305305                }
    306        
    307         return;
    308306
     307                return;
     308
    309309        }
    310310
    311311        /**
     
    320320
    321321                $payment_token = ( isset( $_REQUEST['tix_payment_token'] ) ) ? trim( $_REQUEST['tix_payment_token'] ) : '';
    322322
    323                 if ( ! $payment_token ) {
    324                         die( 'empty token' );
     323                if ( !$payment_token ) {
     324                        die( __( 'Empty Token', 'campt-indian-payment-gateway' ) );
    325325                }
    326326                // Set the associated attendees to cancelled.
    327327                return $this->payment_result( $payment_token, CampTix_Plugin::PAYMENT_STATUS_CANCELLED );
  • campt-indian-payment-gateway.php

     
    55 * Description: Simple and Flexible payment ticketing for Camptix using Indian Payment Platforms
    66 * Author: India WordPress Community
    77 * Author URI: https://github.com/wpindiaorg/
    8  * Version: 1.4
     8 * Version: 1.6
    99 * License: GPLv2 or later
    1010 * Text Domain: campt-indian-payment-gateway
    1111 * Domain Path: /languages
     
    9292         */
    9393        private function setup_contants() {
    9494                // Definitions
    95                 define( 'CAMPTIX_INDIAN_PAYMENTS_VERSION', '1.0' );
     95                define( 'CAMPTIX_INDIAN_PAYMENTS_VERSION', '1.5' );
    9696                define( 'CAMPTIX_MULTI_DIR', plugin_dir_path( __FILE__ ) );
    9797                define( 'CAMPTIX_MULTI_URL', plugin_dir_url( __FILE__ ) );
    9898        }