Plugin Directory

Changeset 2201328


Ignore:
Timestamp:
11/26/2019 01:31:14 PM (6 years ago)
Author:
udjin
Message:

1.8 = * Added test mode

Location:
platon-pay
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • platon-pay/tags/1.7/inc/order-processing.php

    r2171611 r2201328  
    4646                $resultInfo['id_shortcode'] = $result->id_shortcode;
    4747            }
    48             $newPriceFormat = number_format($resultInfo["price"], 2);
     48            $newPriceFormat = number_format($resultInfo["price"], 2, '.', '');
    4949
    5050           
  • platon-pay/trunk/css/style.css

    r2171607 r2201328  
    114114    border-bottom: 1px solid #dddddd;
    115115}
    116 .tab-block li {
     116.tab-block .tab-default {
    117117    background: #ddd;
    118118    color: #1c2345;
     
    124124    border-radius: 15px 15px 0 0;
    125125    margin: 0 10px 0 0;
     126}
     127.tab-block .additional-tab-block {
     128    float: left;
    126129}
    127130.tab-block .active-tab {
     
    229232    border: 1px solid #ddd;
    230233    box-shadow: inset 0 1px 2px rgba(0,0,0,.07);
     234}
     235.full-width-block {
     236    width: 100% !important;
     237    display: inline-block;
     238}
     239#test-mode-info{
     240    display: none;
     241    font-weight: 500;
     242}
     243#test-mode-info p {
     244    margin-top: 0;
     245}
     246.test-info-card {
     247    font-weight: 700;
    231248}
    232249.desc-field {
     
    574591}
    575592
     593/*Форма отправки запроса на подключение модуля*************************************************************************/
     594.left-test-mode-info {
     595    width: 19%;
     596    float: left;
     597}
     598.right-test-mode-info {
     599    width: 81%;
     600    float: right;
     601}
     602.wrapper-psp-hook-up {
     603    position: absolute;
     604    top: 50%;
     605    left: 50%;
     606    transform: translate(-50%,-50%);
     607    background: #fff;
     608    z-index: 9;
     609    margin-left: -20px;
     610    width: 100%;
     611    max-width: 300px;
     612    padding: 20px;
     613    display: none;
     614}
     615.title-modal-hook-up {
     616    display: block;
     617    text-align: center;
     618    font-size: 20px;
     619    color: #000;
     620    margin-bottom: 20px;
     621}
     622.button-default-platon {
     623    background: #ee8527;
     624    color: #fff;
     625    cursor: pointer;
     626    font-size: 16px;
     627    border-radius: 5px;
     628    padding: 9px 25px;
     629    display: inline-block;
     630    border: none;
     631}
     632#platon-psp-hook-up {
     633    margin-bottom: 20px;
     634}
     635.button-default-platon:focus,
     636.button-default-platon:active {
     637    outline: none;
     638}
     639.close-modal-hook-up {
     640    position: absolute;
     641    top: 10px;
     642    right: 10px;
     643    line-height: 0.7;
     644    width: 15px;
     645    height: 15px;
     646    font-size: 16px;
     647    cursor: pointer;
     648    display: inline-block;
     649    text-align: center;
     650}
     651.line-field-hook-up {
     652    margin-bottom: 15px;
     653}
     654.line-field-hook-up input {
     655    width: 100%;
     656    outline: none;
     657    height: 35px;
     658    border: 1px solid #848484;
     659}
     660.line-field-hook-up input:focus,
     661.line-field-hook-up input:active {
     662    outline: none;
     663    border-color: #848484 !important;
     664    box-shadow: none !important;
     665}
     666.message-result {
     667    text-align: center;
     668    font-weight: 500;
     669    margin-bottom: 10px;
     670    font-size: 14px;
     671    display: none;
     672}
     673.status-success {
     674    color: #1bcf1c;
     675}
     676.status-error {
     677    color: #cc0000;
     678}
     679.overlay-psp-hook-up {
     680    position: absolute;
     681    top: 0;
     682    right: 0;
     683    bottom: 0;
     684    left: 0;
     685    z-index: 8;
     686    background: rgba(0, 0, 0, 0.7);
     687    margin-left: -20px;
     688    display: none;
     689}
     690
    576691
    577692/*Нижняя панель(footer) плагина****************************************************************************************/
     
    603718    }
    604719}
     720@media(max-width: 1450px){
     721    .copy-shortcode {
     722        padding: 11px 5px;
     723        font-size: 12px;
     724    }
     725}
  • platon-pay/trunk/inc/form.php

    r2171607 r2201328  
    5252                $html .= '<input name="phone" class="phone-field-form" type="tel" placeholder="'.$phonePlaceholder.'" '. $phoneRequire .'>';
    5353            }
    54             $html .=    '<input type="hidden" name="shortcode_id" value="'.$info['id_shortcode'].'">';
    55             $html .=    '<input type="hidden" name="link_to_handler" value="'.$linkToHandler.'">';
    56             $html .=     wp_nonce_field( 'platon_pay_nonce_action','platon_pay_nonce_field',true, false );
    57             $html .=     '<button type="submit" data-active="0" class="button-order-processing" style="background-color: #'.$colorButtonForm.'">'.$nameButtonForm.'</button>';
     54            $html .=    '<div class="do-not-transmit-field">';
     55            $html .=        '<input type="hidden" name="shortcode_id" value="'.$info['id_shortcode'].'">';
     56            $html .=        '<input type="hidden" name="link_to_handler" value="'.$linkToHandler.'">';
     57            $html .=        wp_nonce_field( 'platon_pay_nonce_action','platon_pay_nonce_field',true, false );
     58            $html .=    '</div>';
     59            $html .=    '<button type="submit" data-active="0" class="button-order-processing" style="background-color: #'.$colorButtonForm.'">'.$nameButtonForm.'</button>';
    5860        $html .= '</form>';
    5961    $html .= '</div>';
  • platon-pay/trunk/inc/list-orders.php

    r2171607 r2201328  
    106106                        <td class="id-invoice"><?php echo $info['id_invoice'] ? $info['id_invoice'] : '&nbsp;'; ?></td>
    107107                        <td class="order-platon"><?php echo $info['order_platon'] ? $info['order_platon'] : '&nbsp;'; ?></td>
    108                         <td class="fio"><?php echo (($info['first_name'] ? $info['first_name'] : '') . ' ' . ($info['last_name'] ? $info['last_name'] : '')); ?></td>
     108                        <td class="fio"><?php echo (($info['first_name'] ? $info['first_name'] : '') . ' ' . ($info['last_name'] ? $info['last_name'] : '&nbsp;')); ?></td>
    109109                        <td class="email"><?php echo $info['email'] ? $info['email'] : '&nbsp;'; ?></td>
    110110                        <td class="phone"><?php echo $info['phone'] ? $info['phone'] : '&nbsp;'; ?></td>
  • platon-pay/trunk/inc/order-processing.php

    r2174685 r2201328  
    3636        /*Настройки для подключения к Platon***************************************************************************/
    3737        $infoUrl = ( get_option('platon_url_field') ) ? get_option('platon_url_field') : '';
    38         $infoSecret = ( get_option('platon_secret_key') ) ? get_option('platon_secret_key') : '';
    39         $infoPassword = ( get_option('platon_password_key') ) ? get_option('platon_password_key') : '';
     38        if(get_option('platon_test_mode') !== '0'){
     39            $infoSecret = 'F5QQ6NQS64';
     40            $infoPassword = 'TaHycyY5z7PeZsX4fpuQcXusX5JHjmLy';
     41        }else{
     42            $infoSecret = ( get_option('platon_secret_key') ) ? get_option('platon_secret_key') : '';
     43            $infoPassword = ( get_option('platon_password_key') ) ? get_option('platon_password_key') : '';
     44        }
    4045       
    4146        /*Сбор данных для совершения оплаты****************************************************************************/
     
    100105/*Изменение статуса заказа и запись внутренего id заказа от Platon*****************************************************/
    101106if(!isset($_GET["order"]) && isset($_POST['sign'])){
    102    
    103107    $order_id = sanitize_text_field($_POST['id']);
    104108    $sign = sanitize_text_field($_POST['sign']);
    105109    $status = sanitize_text_field($_POST['status']);
    106110   
     111    $invoice_table = $wpdb->prefix . 'platon_invoice';
     112    $internal_order_id = sanitize_text_field($_POST['order']);
     113   
    107114    if ($order_id && $sign && $status === 'SALE') {
    108         $internal_order_id = sanitize_text_field($_POST['order']);
    109        
    110         $invoice_table = $wpdb->prefix . 'platon_invoice';
    111115        $wpdb->update( $invoice_table,
    112116            array( 'status' => 'Оплачен', 'order_platon' =>  $order_id),
    113117            array( 'id' => $internal_order_id ));
    114118    }
    115    
    116119}
     120
     121
     122/*Изменение статуса заказа в тестовом режиме***************************************************************************/
     123if(isset($_GET['platon-result']) && isset($_GET['order']) && get_option('platon_test_mode')){
     124    $invoice_table = $wpdb->prefix . 'platon_invoice';
     125    $internal_order_id = sanitize_text_field($_GET['order']);
     126    $wpdb->update( $invoice_table, array( 'status' => 'Тестовый платеж'), array( 'id' => $internal_order_id ));
     127}
     128
    117129
    118130/*Показ оповещения после успешного совершения заказа*******************************************************************/
     
    137149}
    138150
    139    
     151
    140152/*Удаление заказа******************************************************************************************************/
    141153function platon_pay_remove_order(){
     
    163175}
    164176add_action('wp_ajax_remove_order', 'platon_pay_remove_order');
     177
     178
     179/*Функция для логирования полученых данных*******************************************************************************/
     180function platon_pay_log_info($info = array()){
     181    $fp = fopen(plugin_dir_path( __FILE__ ).'platon-logs.txt','w+');
     182    fwrite($fp, $info);
     183    fclose($fp);
     184}
  • platon-pay/trunk/inc/settings.php

    r2171607 r2201328  
    1111   
    1212    $callbackUrl = '/?platon-result=Result_Payment';
    13    
     13
     14    $testMode = ( get_option('platon_test_mode') ) ? get_option('platon_test_mode') : '';
    1415
    1516    $path = plugins_url( 'platon/index.php');
     
    6465       
    6566        <ul class="tab-block">
    66             <li data-tab="system-settings" class="active-tab">Системные настройки Platon</li>
    67             <li data-tab="form-settings">Настройки формы</li>
    68             <li data-tab="content-shortcode">Формирование шорткода</li>
    69             <li data-tab="design-form">Оповещения</li>
     67            <li data-tab="system-settings" class="active-tab tab-default">Системные настройки Platon</li>
     68            <li data-tab="form-settings" class="tab-default">Настройки формы</li>
     69            <li data-tab="content-shortcode" class="tab-default">Формирование шорткода</li>
     70            <li data-tab="design-form" class="tab-default">Оповещения</li>
    7071        </ul>
    7172       
    7273        <div class="all-content-tab">
    7374            <div class="content-tab simple-fields active-content" id="system-settings">
     75                <div class="full-width-block">
     76                    <div class="left-test-mode-info">
     77                        <div class="field-block full-width-block">
     78                            <input type="checkbox" class="checkbox"  id="platon-test-mode" name="platon_test_mode" <?php echo ($testMode) ? 'checked' : ''; ?>>
     79                            <label for="platon-test-mode">Рабочий режим</label><!--Тестовый режим-->
     80                        </div>
     81                        <span class="button-default-platon" id="platon-psp-hook-up">Подключить PSP Platon</span>
     82                    </div>
     83                    <div class="right-test-mode-info">
     84                        <div class="field-block full-width-block" id="test-mode-info">
     85                            <p>Вы можете протестировать процесс работы модуля без проведения оплат.</p>
     86                            <p>Для включения реальных платежей – вам необходимы выключить «Режим тестирования» - и связаться с нашими специалистами для получения необходимых данных.</p>
     87                            <div class="test-info-card">
     88                                <p>Для тестирования успешной оплаты картой, введите следующие реквизиты:</p>
     89                                <p>№ карты: 4111 1111 1111 1111</p>
     90                                <p>Срок: 01/20, CVV: 123</p>
     91                            </div>
     92                        </div>
     93                    </div>
     94                </div>
     95               
    7496                <div class="field-block">
    7597                    <label for="url-field">Url</label>
     
    291313    </div>
    292314   
     315    <div class="wrapper-psp-hook-up" id="psp-hook-up">
     316        <span class="close-modal-hook-up">x</span>
     317        <span class="title-modal-hook-up">Заявка на подключение</span>
     318        <p class="message-result">Заявка была успешно отправлена</p>
     319        <form class="form-hook-up">
     320            <div class="line-field-hook-up">
     321                <input type="text" name="your-name" placeholder="Ваше имя">
     322            </div>
     323            <div class="line-field-hook-up">
     324                <input type="email" name="your-email" placeholder="E-mail">
     325            </div>
     326            <div class="line-field-hook-up">
     327                <input type="tel" name="your-tel" class="phone-field-platon" placeholder="Телефон">
     328            </div>
     329            <input type="hidden" name="your-site" value="<?php echo home_url(); ?>">
     330            <input type="hidden" name="your-callback-url" value="<?php echo home_url() . $callbackUrl; ?>">
     331            <input type="hidden" name="your-topic" value="WP">
     332            <?php echo wp_nonce_field( 'platon_pay_nonce_hook_up','platon_pay_nonce_hook_up',true, false ); ?>
     333            <button id="send-info-hook-up" class="button-default-platon">Отправить заявку</button>
     334        </form>
     335    </div>
     336    <div class="overlay-psp-hook-up"></div>
     337   
    293338    <script type="text/javascript">
    294339        $(document).ready(function(){
  • platon-pay/trunk/index.php

    r2171611 r2201328  
    44* Description: “Platon Pay” is perfect for both single-page landing page and small sites where there is no large catalog of goods and store functions.
    55* Author: udjin
    6 * Version: 1.7
     6* Version: 1.8
    77* Requires at least: 4.7
    88* Requires PHP: 5.2
     
    2121        $table_invoice = $wpdb->prefix . 'platon_invoice';
    2222        $table_order = $wpdb->prefix . 'platon_orders';
     23       
     24        /*Включение тестового режима*/
     25        update_option( 'platon_test_mode', 1, true);
    2326       
    2427        $sql = "CREATE TABLE $table_name (
     
    159162       
    160163        if($allOptions){
     164                $platonTestMode = sanitize_text_field($allOptions['platon_test_mode']);
    161165            $platonUrlField = esc_url($allOptions['platon_url_field']);
    162166            $platonSecretKey = sanitize_text_field($allOptions['platon_secret_key']);
     
    185189                $messageSuccessOrder = sanitize_text_field(str_replace(array($pOpen,$pClose), ' ', $allOptions['message_success_order']));
    186190           
     191                update_option( 'platon_test_mode', $platonTestMode, true);
    187192            update_option( 'platon_url_field', $platonUrlField, true);
    188193            update_option( 'platon_secret_key', $platonSecretKey, true);
     
    225230}
    226231
     232/**********************************************************************************************************************/
     233/*Отправка информации на подключения оплаты****************************************************************************/
     234/**********************************************************************************************************************/
     235add_action('wp_ajax_send_info_hook_up', 'platon_pay_send_info_hook_up');
     236function platon_pay_send_info_hook_up() {
     237    $json = array();
     238   
     239    $nonceCode = check_ajax_referer( 'platon_pay_nonce_hook_up', 'security' );
     240    $sanitizeInfo = sanitize_text_field(json_encode($_POST['info']));
     241    $infoArray = json_decode($sanitizeInfo, true);
     242    if($nonceCode){
     243        $hookUpArray = array(
     244            'your-name'         => sanitize_text_field($infoArray['your-name']),
     245            'your-email'        => sanitize_text_field($infoArray['your-email']),
     246            'your-tel'          => sanitize_text_field($infoArray['your-tel']),
     247            'your-site'         => sanitize_text_field($infoArray['your-site']),
     248            'your-callback-url' => sanitize_text_field($infoArray['your-callback-url']),
     249            'your-topic'        => sanitize_text_field($infoArray['your-topic'])
     250        );
     251       
     252        $headers = array();
     253        $headers[] = "Content/Type: application/json";
     254        $headers[] = "Accept: application/json";
     255       
     256        $curl = curl_init();
     257        curl_setopt($curl, CURLOPT_URL, 'https://platon.ua/wp-content/themes/platon/ajax_platon_bitrix_lead.php');
     258        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     259        curl_setopt($curl, CURLOPT_POST, 1);
     260        curl_setopt($curl, CURLOPT_POSTFIELDS, $hookUpArray);
     261        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     262        $res = json_decode(curl_exec($curl), true);
     263        if($res['status'] == 'success') {
     264            $json['message'] = 'Спасибо! Ваша заявка получена. В скором времени с Вами свяжется наш менеджер.';
     265            $json['status'] = 'success';
     266        }else{
     267            $errorResult = curl_error($curl);
     268            $json['message'] = 'Ошибка';
     269            $json['status'] = 'error';
     270        }
     271        curl_close($curl);
     272       
     273        $json['info_result_status'] = $res;
     274    }
     275   
     276    echo json_encode($json);
     277    wp_die();
     278}
     279
     280
    227281
    228282require_once(plugin_dir_path( __FILE__ ).'/inc/form.php');
  • platon-pay/trunk/js/frontend.js

    r2171607 r2201328  
    7171                    parentForm.attr('action', result.url_to_send).append(result.args_inputs);
    7272                    self.attr('data-active', '1');
     73                    parentForm.find('.do-not-transmit-field').remove();
    7374                    parentForm.submit();
    7475                }
  • platon-pay/trunk/js/script.js

    r2171607 r2201328  
    1111            }else if(this.type === 'textarea'){
    1212                let idTextarea = $(this).attr('id');
    13                 dataOptions[this.name] = tinyMCE.get(idTextarea).getContent();
     13                let visibleTextarea = $('#'+idTextarea).is(":visible");
     14                if(visibleTextarea){
     15                    dataOptions[this.name] = '<p>'+$(this).val()+'</p>';
     16                }else{
     17                    dataOptions[this.name] = tinyMCE.get(idTextarea).getContent();
     18                }
    1419            }else{
    1520                let nameField = this.name.split('[');
     
    5358    }
    5459
     60
    5561    /*Запуск функции сохранения настроек------------------------*/
    5662    $('#save-settings, #save-settings-bottom').on('click', function(){
    5763        save_settings();
    5864    });
     65
    5966
    6067    /*Удаления строки шорткода----------------------------------*/
     
    8592        );
    8693    }
    87    
     94
     95
    8896    /*Удаление заказа с админки****************************************************************************************/
    8997    $(document).on('click', '.remove-order', function(){
     
    126134
    127135    /*Переключение табов***********************************************************************************************/
    128     $('.tab-block').on('click', 'li', function(){
     136    $('.tab-block').on('click', '.tab-default', function(){
    129137        let sel = $(this);
    130138        if(!sel.hasClass('active-tab')){
     
    188196    $("#color-button-form").wheelColorPicker();
    189197
     198
    190199    /*Изменение цвета input в зависимости от выбраного цвета в ColorPicker*********************************************/
    191200    $('.left-settings-form').on('blur','INPUT', function(){
     
    193202        $(this).css({'background-color': colorInput});
    194203    });
    195    
    196    
     204
     205
    197206    /*Всплывающие подсказки********************************************************************************************/
    198207    $('.help-icon').mouseover(function() {
     
    228237        });
    229238    }
    230    
     239
     240
     241    /*Блокирование полей при включеном тестовом режиме*****************************************************************/
     242    let testModeElement = $('#platon-test-mode');
     243    testModeElement.on('change', function(el) {
     244        if(testModeElement.attr("checked") == 'checked'){
     245            $('#url-field, #secret-key, #password-key, #return-url').attr('disabled', true);
     246            $('#test-mode-info').slideDown();
     247            testModeElement.next('label').text('Тестовый режим');
     248        }else{
     249            $('#url-field, #secret-key, #password-key, #return-url').removeAttr('disabled');
     250            $('#test-mode-info').slideUp();
     251            testModeElement.next('label').text('Рабочий режим');
     252        }
     253    });
     254    if(testModeElement.attr("checked") == 'checked'){
     255        $('#url-field, #secret-key, #password-key, #return-url').attr('disabled', true);
     256        $('#test-mode-info').slideDown();
     257        testModeElement.next('label').text('Тестовый режим');
     258    }
     259
     260
     261    /*Всплывающее окно отправки запроса на подключение модуля**********************************************************/
     262    $('#platon-psp-hook-up').on('click',function(event){
     263        $('.form-hook-up').show();
     264        $('.message-result').text('').hide();
     265        $('.overlay-psp-hook-up').fadeIn(400,
     266            function(){
     267                $('#psp-hook-up').css('display', 'block').animate({opacity: 1, top: '50%'}, 200);
     268            });
     269    });
     270    $('.close-modal-hook-up, .overlay-psp-hook-up').on('click', function(){
     271        $('#psp-hook-up')
     272            .animate({opacity: 0, top: '45%'}, 200,
     273                function(){
     274                    $('.overlay-psp-hook-up').fadeOut(400);
     275                }
     276            );
     277    });
     278
     279
     280    /*К полю телефона добавление плюса(+)******************************************************************************/
     281    $('.phone-field-platon').focus(function(){
     282        let sel = $(this);
     283        if(sel.val() === ''){
     284            sel.val('+');
     285        }
     286    }).blur(function(){
     287        let sel = $(this);
     288        if(sel.val() === '+'){
     289            sel.val('');
     290        }
     291    });
     292
     293
     294    /*Отправка информации с формы  на подключение модуля***************************************************************/
     295    $('#send-info-hook-up').click(function(event){
     296        event.preventDefault();
     297       
     298        let infoHookUpArray = new Object();
     299        let requireFields = new Array();
     300        $('.form-hook-up').find('input').each(function() {
     301            infoHookUpArray[this.name] = $(this).val();
     302            if($(this).val() === ''){
     303                requireFields.push(this.name);
     304            }
     305        });
     306
     307        if(requireFields.length === 0) {
     308            let dataInfo = {
     309                action: 'send_info_hook_up',
     310                dataType: 'json',
     311                info: infoHookUpArray,
     312                security: $('#platon_pay_nonce_hook_up').val()
     313            };
     314            jQuery.ajax({
     315                url: ajaxurl,
     316                data: dataInfo,
     317                type: 'POST',
     318                success: function (response) {
     319                    let result = JSON.parse(response);
     320                    // console.log(result);
     321                    $('.form-hook-up').slideUp();
     322                    $('.message-result').show().attr('class','message-result status-' + result.status).text(result.message);
     323                }
     324            });
     325        }else{
     326            $('.message-result').show().addClass('status-error').text('Все поля обязательны для заполнения!');
     327        }
     328    });
    231329
    232330});
  • platon-pay/trunk/readme.txt

    r2171611 r2201328  
    7676* This version fixes a security related bug.
    7777* Added ability to pay via Privat24.
     78= 1.8 =
     79* Added test mode
    7880
    7981== Upgrade Notice ==
     
    8385= 1.7 =
    8486* In this version has been fixed a bug with security and added ability to pay via Privat24.
     87= 1.8 =
     88* Added test mode
Note: See TracChangeset for help on using the changeset viewer.