Plugin Directory

Changeset 2421686


Ignore:
Timestamp:
11/19/2020 05:01:47 PM (5 years ago)
Author:
nor1m
Message:

Fix bugs

Location:
qr-payments-via-paypal/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • qr-payments-via-paypal/trunk/includes/class-npqp-form-invoice-data.php

    r2140460 r2421686  
    11<?php
    2 
    3 //debug($order, 1);
    42
    53if ( !$order ){
     
    1311$billing           = $order->data['billing'];
    1412$country_code_res  = $NPQP_Country_Code->getCountryCode( $billing['phone'] );
     13
    1514$b_country_code    = $country_code_res['country_code'];
    1615$b_national_number = $country_code_res['number'];
    1716
    1817$shipping          = $order->data['shipping'];
     18
     19// Если нет шипинга, то данные берем из биллинга
     20if ( empty($shipping['postcode']) && empty($shipping['country']) ) {
     21    $shipping = $billing;
     22}
    1923
    2024$invoice_number    = $order->id;
     
    117121    }
    118122}
    119 
    120 //debug($items, 1);
    121123
    122124$primary_recipients = [
  • qr-payments-via-paypal/trunk/nor1m-paypal-qr-payment.php

    r2192999 r2421686  
    55 * Author: Vitaly Mironov
    66 * Author URI: http://nor1m.ru
    7  * Version: 0.4
     7 * Version: 0.5
    88 */
    99
    10 if ( ! @npqp_is_woocommerce_active() ) {
     10if (!@npqp_is_woocommerce_active()) {
    1111    return false;
    1212}
    1313
    14 function npqp_is_woocommerce_active(){
     14function npqp_is_woocommerce_active()
     15{
    1516    static $active_plugins;
    16     if ( ! isset( $active_plugins ) ) {
    17         $active_plugins = (array) get_option( 'active_plugins', array() );
    18         if ( is_multisite() ) {
    19             $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
     17    if (!isset($active_plugins)) {
     18        $active_plugins = (array)get_option('active_plugins', array());
     19        if (is_multisite()) {
     20            $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
    2021        }
    2122    }
     
    2829 * Translates
    2930 */
    30 add_action( 'plugins_loaded', 'npqp_init' );
    31 function npqp_init(){
    32     load_plugin_textdomain( 'npqp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
     31add_action('plugins_loaded', 'npqp_init');
     32function npqp_init()
     33{
     34    load_plugin_textdomain('npqp', false, dirname(plugin_basename(__FILE__)) . '/languages/');
    3335}
    3436
     
    3638 * Creating a page with a qr code when activating the plugin
    3739 */
    38 register_activation_hook( __FILE__, 'npqp_plugin_activate' );
    39 function npqp_plugin_activate(){
     40register_activation_hook(__FILE__, 'npqp_plugin_activate');
     41function npqp_plugin_activate()
     42{
    4043
    4144    $title = "QR Payment";
    42     $content  = '<div id="qr_code_img" style="text-align: center;">[NPQP-QR-CODE-PAGE]</div>';
     45    $content = '<div id="qr_code_img" style="text-align: center;">[NPQP-QR-CODE-PAGE]</div>';
    4346    $content .= '<div style="text-align: center; display: inline-block; position: relative; margin-top: -10px; width: 100%;">';
    44     $content .=     '<img style="display: inline-block;" src="'. plugins_url('assets/img/processing.gif', __FILE__) .'" />';
     47    $content .= '<img style="display: inline-block;" src="' . plugins_url('assets/img/processing.gif', __FILE__) . '" />';
    4548    $content .= '</div>';
    4649    $content .= '<b style="text-align: center; display: inline-block; position: relative; top: -30px; width: 100%; font-size: 16px; color: #565656;">' . __('Payment is pending', 'npqp') . '</b>';
    4750    $content .= '<a href="javascript:history.back()" style="background: #0f7fc3;padding: 10px 15px;display: inline-block;margin-top: 21px;border-radius: 3px;color: #fff;width: 250px;max-width: 100%;font-size: 16px;text-decoration: none;cursor: pointer;top: -30px;position: relative;">' . __('Back to checkout', 'npqp') . '</a>';
    4851
    49     if ( ! post_exists( $title ) ) {
     52    if (!post_exists($title)) {
    5053        $post_id = wp_insert_post(array(
    51             'post_type'         => 'page',
    52             'post_title'        => $title,
    53             'post_content'      => $content,
    54             'post_status'       => 'publish',
    55             'post_author'       => 1,
    56             'post_name'         => 'qr-payments',
     54            'post_type' => 'page',
     55            'post_title' => $title,
     56            'post_content' => $content,
     57            'post_status' => 'publish',
     58            'post_author' => 1,
     59            'post_name' => 'qr-payments',
    5760        ));
    5861    }
    5962}
    6063
    61 require_once dirname( __FILE__ ) . '/includes/class-npqp-paypal-api.php';
     64require_once dirname(__FILE__) . '/includes/class-npqp-paypal-api.php';
    6265
    6366/*
    6467* This action hook registers our PHP class as a WooCommerce payment gateway
    6568*/
    66 add_filter( 'woocommerce_payment_gateways', 'NPQP_add_gateway_class' );
    67 function NPQP_add_gateway_class( $gateways ) {
     69add_filter('woocommerce_payment_gateways', 'NPQP_add_gateway_class');
     70function NPQP_add_gateway_class($gateways)
     71{
    6872    $gateways[] = 'WC_NPQP_Gateway';
    6973    return $gateways;
    7074}
    7175
    72 // admin styles
    73 wp_enqueue_style( 'npqp_admin_css', plugins_url('assets/css/admin.css', __FILE__) );
    74 
    75 // qr code generator
    76 wp_enqueue_script( 'qrcode', plugins_url('assets/js/qrcode.min.js', __FILE__) );
    77 
    78 // frontend styles
    79 wp_enqueue_style( 'npqp_frontend_css', plugins_url('assets/css/frontend.css', __FILE__) );
     76// правильный способ подключить стили и скрипты
     77add_action('wp_enqueue_scripts', function () {
     78    // admin styles
     79    wp_enqueue_style('npqp_admin_css', plugins_url('assets/css/admin.css', __FILE__));
     80    // qr code generator
     81    wp_enqueue_script('qrcode', plugins_url('assets/js/qrcode.min.js', __FILE__));
     82    // frontend styles
     83    wp_enqueue_style('npqp_frontend_css', plugins_url('assets/css/frontend.css', __FILE__));
     84    // frontend scripts
     85    wp_enqueue_script('npqp_main_js', plugins_url('assets/js/main.js', __FILE__), array('jquery'));
     86});
    8087
    8188/*
    8289* The class itself, please note that it is inside plugins_loaded action hook
    8390*/
    84 add_action( 'plugins_loaded', 'NPQP_init_gateway_class' );
    85 function NPQP_init_gateway_class() {
     91add_action('plugins_loaded', 'NPQP_init_gateway_class');
     92function NPQP_init_gateway_class()
     93{
    8694
    8795    // check ajax status
    88     if ( isset($_GET['npqp_ajax_url']) ) {
     96    if (isset($_GET['npqp_ajax_url'])) {
    8997        echo npqp_ajax();
    9098        die(200);
    9199    }
    92100
    93     class WC_NPQP_Gateway extends WC_Payment_Gateway {
    94 
    95         public function __construct() {
    96 
    97             $this->id                 = 'npqp'; // payment gateway plugin ID
    98             $icon                     = ''; // URL of the icon that will be displayed on checkout page near your gateway name
    99             $icon                     = apply_filters( 'npqp_icon', $icon ); // filter
    100             $this->icon               = $icon;
    101             $this->has_fields         = true; // in case you need a custom credit card form
    102             $this->method_title       = __('QR payments via PayPal', 'npqp');
     101    class WC_NPQP_Gateway extends WC_Payment_Gateway
     102    {
     103
     104        public $id;
     105        public $title;
     106        public $icon;
     107        public $has_fields;
     108        public $method_title;
     109        public $method_description;
     110        public $form_fields;
     111        public $description;
     112        public $enabled;
     113        public $testmode;
     114        public $api_client_id;
     115        public $api_secret_id;
     116        public $paypal_webhook_id;
     117        public $qr_code_page_url;
     118        public $qr_code_width;
     119        public $qr_code_height;
     120        public $qr_code_stroke_color;
     121        public $qr_code_background_color;
     122
     123        public function __construct()
     124        {
     125
     126            $this->id = 'npqp'; // payment gateway plugin ID
     127            $icon = ''; // URL of the icon that will be displayed on checkout page near your gateway name
     128            $icon = apply_filters('npqp_icon', $icon); // filter
     129            $this->icon = $icon;
     130            $this->has_fields = true; // in case you need a custom credit card form
     131            $this->method_title = __('QR payments via PayPal', 'npqp');
    103132            $this->method_description = __('Payment with qr code', 'npqp'); // will be displayed on the options page
    104             $this->form_fields        = require dirname( __FILE__ ) . '/includes/class-npqp-form-fields.php';
    105 
    106             include_once dirname( __FILE__ ) . '/includes/class-npqp-country-code.php';
     133            $this->form_fields = require dirname(__FILE__) . '/includes/class-npqp-form-fields.php';
     134
     135            include_once dirname(__FILE__) . '/includes/class-npqp-country-code.php';
    107136
    108137            // gateways can support subscriptions, refunds, saved payment methods,
     
    114143            // Load the settings.
    115144            $this->init_settings();
    116             $this->title                    = $this->get_option( 'title' );
    117             $this->description              = $this->get_option( 'description' );
    118             $this->enabled                  = $this->get_option( 'enabled' );
    119             $this->testmode                 = 'yes' === $this->get_option( 'testmode' );
    120             $this->api_client_id            = $this->testmode ? $this->get_option( 'sandbox_api_client_id' ) : $this->get_option( 'live_api_client_id' );
    121             $this->api_secret_id            = $this->testmode ? $this->get_option( 'sandbox_api_secret_id' ) : $this->get_option( 'live_api_secret_id' );
    122             $this->paypal_webhook_id        = $this->testmode ? $this->get_option( 'sandbox_paypal_webhook_id' ) : $this->get_option( 'live_paypal_webhook_id' );
    123 
    124             $this->qr_code_page_url         = $this->get_option( 'qr_code_page_url' ) ? $this->get_option( 'qr_code_page_url' ) : "qr-code-page";
    125             $this->qr_code_width            = $this->get_option( 'qr_code_width' ) ? $this->get_option( 'qr_code_width' ) : "200";
    126             $this->qr_code_height           = $this->get_option( 'qr_code_height' ) ? $this->get_option( 'qr_code_height' ) : "200";
    127             $this->qr_code_stroke_color     = $this->get_option( 'qr_code_stroke_color' ) ? $this->get_option( 'qr_code_stroke_color' ) : "#00000";
    128 
    129             // and this is our custom JS in your plugin directory that works with token.js
    130             wp_enqueue_script( 'npqp_main_js', plugins_url( 'assets/js/main.js', __FILE__ ), array('jquery') );
    131 
    132             /*            if ( is_admin() && isset($_GET['section']) && $_GET['section'] == 'npqp' ) {
    133                             wp_localize_script('jquery', 'nqpp_l18n', array(
    134                                 'Visit site' => __('Visit site', 'npqp'),
    135                                 'Donate'     => __('Donate', 'npqp')
    136                             ));
    137                             wp_enqueue_script( 'npqp_admin_js', plugins_url( 'assets/js/admin.js', __FILE__ ), array('jquery') );
    138                         }*/
    139 
    140             // in most payment processors you have to use PUBLIC KEY to obtain a token
    141             wp_localize_script( 'npqp_main_js', 'npqp_params', array(
    142                 'qr_code_page_url'         => $this->qr_code_page_url,
    143                 'qr_code_width'            => $this->qr_code_width,
    144                 'qr_code_height'           => $this->qr_code_height,
    145                 'qr_code_stroke_color'     => $this->qr_code_stroke_color,
    146                 'qr_code_background_color' => $this->qr_code_background_color,
    147                 'npqp_ajax_url'            => home_url('/?npqp_ajax_url'),
    148                 'is_qrcodepage'            => is_qrcodepage()
    149             ));
     145            $this->title = $this->get_option('title');
     146            $this->description = $this->get_option('description');
     147            $this->enabled = $this->get_option('enabled');
     148            $this->testmode = 'yes' === $this->get_option('testmode');
     149            $this->api_client_id = $this->testmode ? $this->get_option('sandbox_api_client_id') : $this->get_option('live_api_client_id');
     150            $this->api_secret_id = $this->testmode ? $this->get_option('sandbox_api_secret_id') : $this->get_option('live_api_secret_id');
     151            $this->paypal_webhook_id = $this->testmode ? $this->get_option('sandbox_paypal_webhook_id') : $this->get_option('live_paypal_webhook_id');
     152
     153            $this->qr_code_page_url = $this->get_option('qr_code_page_url') ? $this->get_option('qr_code_page_url') : "qr-code-page";
     154            $this->qr_code_width = $this->get_option('qr_code_width') ? $this->get_option('qr_code_width') : "200";
     155            $this->qr_code_height = $this->get_option('qr_code_height') ? $this->get_option('qr_code_height') : "200";
     156            $this->qr_code_stroke_color = $this->get_option('qr_code_stroke_color') ? $this->get_option('qr_code_stroke_color') : "#00000";
     157            $this->qr_code_background_color = "#fff";
     158
     159            add_action( 'wp_enqueue_scripts', function(){
     160                wp_localize_script('npqp_main_js', 'npqp_params', array(
     161                    'qr_code_page_url' => $this->qr_code_page_url,
     162                    'qr_code_width' => $this->qr_code_width,
     163                    'qr_code_height' => $this->qr_code_height,
     164                    'qr_code_stroke_color' => $this->qr_code_stroke_color,
     165                    'qr_code_background_color' => $this->qr_code_background_color,
     166                    'npqp_ajax_url' => home_url('/?npqp_ajax_url'),
     167                    'is_qrcodepage' => is_qrcodepage()
     168                ));
     169            });
    150170
    151171            // This action hook saves the settings
    152             add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, [
     172            add_action('woocommerce_update_options_payment_gateways_' . $this->id, [
    153173                $this, 'process_admin_options'
    154174            ]);
    155175
    156176            // You can also register a webhook here
    157             add_action( 'woocommerce_api_npqp', [ $this, 'webhook' ] );
    158 
    159             if ( isset($_GET['npqrdbg']) ) {
     177            add_action('woocommerce_api_npqp', [$this, 'webhook']);
     178
     179            if (isset($_GET['npqrdbg'])) {
    160180                //...
    161181            }
     
    166186         * Payment fields in checkout
    167187         */
    168         public function payment_fields() {
    169             if ( $this->description ) {
    170                 echo wpautop( wp_kses_post( trim( $this->description ) ) );
     188        public function payment_fields()
     189        {
     190            if ($this->description) {
     191                echo wpautop(wp_kses_post(trim($this->description)));
    171192            }
    172193        }
     
    175196        * Get PayPal payment link
    176197        */
    177         public function get_payment_link($order){
     198        public function get_payment_link($order)
     199        {
    178200
    179201            $PayPalApi = new NPQP_PayPal_API([
    180                 'testmode'          => $this->testmode,
    181                 'api_client_id'     => $this->api_client_id,
    182                 'api_secret_id'     => $this->api_secret_id,
     202                'testmode' => $this->testmode,
     203                'api_client_id' => $this->api_client_id,
     204                'api_secret_id' => $this->api_secret_id,
    183205                'paypal_webhook_id' => $this->paypal_webhook_id,
    184                 'order'             => $order,
    185                 'fields'            => $this->settings
     206                'order' => $order,
     207                'fields' => $this->settings
    186208            ]);
    187209
     
    192214        * Fields validation
    193215        */
    194         public function validate_fields() {
     216        public function validate_fields()
     217        {
    195218
    196219            $validate = true;
    197220
    198             $billing_first_name = sanitize_text_field( $_POST['billing_first_name'] );
    199 
    200             if( empty( $billing_first_name ) ) {
    201                 wc_add_notice( __('First name is required!', 'npqp'), 'error' );
     221            $billing_first_name = sanitize_text_field($_POST['billing_first_name']);
     222
     223            if (empty($billing_first_name)) {
     224                wc_add_notice(__('First name is required!', 'npqp'), 'error');
    202225                $validate = false;
    203226            }
    204227
    205             $validate = apply_filters( 'npqp_validate_fields_flag', $validate ); // filter
     228            $validate = apply_filters('npqp_validate_fields_flag', $validate); // filter
    206229            return $validate;
    207230        }
     
    210233        * We're processing the payments here
    211234        */
    212         public function process_payment( $order_id ) {
     235        public function process_payment($order_id)
     236        {
    213237
    214238            global $woocommerce;
    215239
    216240            // we need it to get any order detailes
    217             $order = wc_get_order( $order_id );
     241            $order = wc_get_order($order_id);
    218242
    219243            $payment_link = $this->get_payment_link($order);
    220244
    221             if ( isset($payment_link['status']) && $payment_link['status'] == 'error' ) {
     245            if (isset($payment_link['status']) && $payment_link['status'] == 'error') {
    222246                $error = $payment_link['error'];
    223                 $error = apply_filters( 'npqp_error_text', $error ); // filter
    224                 wc_add_notice( $error , 'error' );
     247                $error = apply_filters('npqp_error_text', $error); // filter
     248                wc_add_notice($error, 'error');
    225249                return;
    226250            }
    227251
    228             if ( !$payment_link ) {
     252            if (!$payment_link) {
    229253                npqpLog('process_payment No valid payment link', [
    230254                    'order_id' => $order_id,
    231255                    'payment_link' => $payment_link,
    232256                ]);
    233                 wc_add_notice( __('No valid payment link', 'npqp'), 'error' );
     257                wc_add_notice(__('No valid payment link', 'npqp'), 'error');
    234258                return;
    235259            }
     
    238262            $redirect_link = $this->qr_code_page_url ? $this->qr_code_page_url : 'qr-payments';
    239263            $redirect_link = '/' . $redirect_link . '/?payment_link=' . htmlentities(urlencode(esc_url($payment_link))) . '&order_id=' . (int)$order_id;
    240             $redirect_link = home_url( $redirect_link );
    241             $redirect_link = apply_filters( 'npqp_redirect_link', $redirect_link ); // filter
     264            $redirect_link = home_url($redirect_link);
     265            $redirect_link = apply_filters('npqp_redirect_link', $redirect_link); // filter
    242266
    243267            npqpLog('process_payment', [
    244                 'order_id'      => $order_id,
    245                 'payment_link'  => $payment_link,
     268                'order_id' => $order_id,
     269                'payment_link' => $payment_link,
    246270                'redirect_link' => $redirect_link,
    247271            ]);
     
    249273            // redirect to qr page
    250274            return array(
    251                 'result'   => 'success',
     275                'result' => 'success',
    252276                'redirect' => $redirect_link
    253277            );
     
    257281        * In case you need a webhook, like PayPal IPN etc
    258282        */
    259         public function webhook() {
    260 
    261             $post = json_decode( file_get_contents('php://input'), 1 );
    262 
    263             if ( isset($post['event_type']) && $post['event_type'] == 'INVOICING.INVOICE.PAID' ) {
     283        public function webhook()
     284        {
     285
     286            $post = json_decode(file_get_contents('php://input'), 1);
     287
     288            if (isset($post['event_type']) && $post['event_type'] == 'INVOICING.INVOICE.PAID') {
    264289
    265290                $PayPalApi = new NPQP_PayPal_API([
    266                     'testmode'          => $this->testmode,
    267                     'api_client_id'     => $this->api_client_id,
    268                     'api_secret_id'     => $this->api_secret_id,
     291                    'testmode' => $this->testmode,
     292                    'api_client_id' => $this->api_client_id,
     293                    'api_secret_id' => $this->api_secret_id,
    269294                    'paypal_webhook_id' => $this->paypal_webhook_id
    270295                ]);
     
    276301                ]);
    277302
    278                 if ( $verify == 'SUCCESS' ) {
    279 
    280                     $webhook_event_arr = json_decode( file_get_contents('php://input'), true );
     303                if ($verify == 'SUCCESS') {
     304
     305                    $webhook_event_arr = json_decode(file_get_contents('php://input'), true);
    281306                    $status_success = 'PAID';
    282                     $status_success = apply_filters( 'npqp_status_success', $status_success ); // filter
    283 
    284                     if ( $webhook_event_arr['resource']['invoice']['status'] != $status_success ) {
     307                    $status_success = apply_filters('npqp_status_success', $status_success); // filter
     308
     309                    if ($webhook_event_arr['resource']['invoice']['status'] != $status_success) {
    285310                        return;
    286311                    }
     
    290315                    ]);
    291316
    292                     if ( isset($webhook_event_arr['resource']['invoice']['detail']['invoice_number']) ){
     317                    if (isset($webhook_event_arr['resource']['invoice']['detail']['invoice_number'])) {
    293318
    294319                        $invoice_number = $webhook_event_arr['resource']['invoice']['detail']['invoice_number'];
    295320
    296321                        // get clear invoice id
    297                         if ( strpos($invoice_number, '-') !== false ) {
     322                        if (strpos($invoice_number, '-') !== false) {
    298323                            $invoice_number = explode('-', $invoice_number)[0];
    299324                        }
    300325
    301                         $order = wc_get_order( $invoice_number );
    302 
    303                         $order = apply_filters( 'npqp_order', $order ); // filter
    304 
    305                         if ( $order ) {
    306 
    307                             if ( ! $order->is_paid() ) {
     326                        $order = wc_get_order($invoice_number);
     327
     328                        $order = apply_filters('npqp_order', $order); // filter
     329
     330                        if ($order) {
     331
     332                            if (!$order->is_paid()) {
    308333                                global $woocommerce;
    309334                                $order->payment_complete();
     
    312337
    313338                                $add_order_note = __('Hey, your order is paid! Thank you!', 'npqp');
    314                                 $add_order_note = apply_filters( 'npqp_add_order_note', $add_order_note ); // filter
    315                                 $order->add_order_note( $add_order_note );
     339                                $add_order_note = apply_filters('npqp_add_order_note', $add_order_note); // filter
     340                                $order->add_order_note($add_order_note);
    316341
    317342                                npqpLog('verifyWebhook', [
     
    334359
    335360    }
     361
     362
     363    new WC_NPQP_Gateway();
    336364}
    337365
    338366// шорткод страницы с qr кодом
    339 add_shortcode( 'NPQP-QR-CODE-PAGE', 'NPQP_QR_code_page' );
    340 function NPQP_QR_code_page() {
    341 
    342     if ( isset($_GET['order_id']) ){
    343         $order = wc_get_order( $_GET['order_id'] );
    344         if ( $order ) {
     367add_shortcode('NPQP-QR-CODE-PAGE', 'NPQP_QR_code_page');
     368function NPQP_QR_code_page()
     369{
     370
     371    if (isset($_GET['order_id'])) {
     372        $order = wc_get_order($_GET['order_id']);
     373        if ($order) {
    345374            $return_url = $order->get_checkout_order_received_url();
    346375        } else {
     
    353382    echo '<div id="wc-npqp-qr-form" class="wc-npqp-qr-form">';
    354383
    355     do_action( 'npqp_qr_form_before', 'npqp' ); // action
    356 
    357     echo  '<div class="npqp-qr-form-wrapper">
    358             <input type="hidden" id="npqp-order-id" value="'. esc_attr( urldecode( $_GET['order_id'] ) ) .'">
    359             <input type="hidden" id="npqp-return-url" value="'. esc_attr( urldecode( $return_url ) ) .'">
    360             <input type="hidden" id="npqp-qrcode-text" value="'. esc_attr( urldecode( $_GET['payment_link'] ) ) .'">
    361             <a target="_blank" href="'. esc_attr( urldecode( $_GET['payment_link'] ) ) .'"><div id="npqp-qrcode"></div></a>
    362             <a class="npqp-paynow-btn onlymob" target="_blank" href="'. esc_attr( urldecode( $_GET['payment_link'] ) ) .'">' . __('Pay Now', 'npqp') . '</a>
     384    do_action('npqp_qr_form_before', 'npqp'); // action
     385
     386    echo '<div class="npqp-qr-form-wrapper">
     387            <input type="hidden" id="npqp-order-id" value="' . esc_attr(urldecode($_GET['order_id'])) . '">
     388            <input type="hidden" id="npqp-return-url" value="' . esc_attr(urldecode($return_url)) . '">
     389            <input type="hidden" id="npqp-qrcode-text" value="' . esc_attr(urldecode($_GET['payment_link'])) . '">
     390            <a target="_blank" href="' . esc_attr(urldecode($_GET['payment_link'])) . '"><div id="npqp-qrcode"></div></a>
     391            <a class="npqp-paynow-btn onlymob" target="_blank" href="' . esc_attr(urldecode($_GET['payment_link'])) . '">' . __('Pay Now', 'npqp') . '</a>
    363392          </div>';
    364393
    365     do_action( 'npqp_qr_form_after', 'npqp' ); // action
     394    do_action('npqp_qr_form_after', 'npqp'); // action
    366395
    367396    echo '<div class="clear"></div>';
     
    369398
    370399// npqp ajax       
    371 function npqp_ajax() {
    372     if( empty( $_GET['action'] ) ) {
     400function npqp_ajax()
     401{
     402    if (empty($_GET['action'])) {
    373403        return __('Action is missed', 'npqp');
    374404    }
    375     if ( $_GET['action'] == 'getorderpaidstatus' ) {
     405    if ($_GET['action'] == 'getorderpaidstatus') {
    376406        return npqp_order_is_paid($_GET['order_id']);
    377407    }
     
    379409
    380410// order is paid
    381 function npqp_order_is_paid($id){
     411function npqp_order_is_paid($id)
     412{
    382413    $post = get_post($id);
    383     if ( isset($post->post_status) ){
     414    if (isset($post->post_status)) {
    384415        return ($post->post_status == 'wc-processing' || $post->post_status == 'wc-completed') ? 1 : 0;
    385416    } else {
     
    389420
    390421// debug
    391 function npqpDebug($data, $die = false) {
    392     echo "<pre>"; var_dump($data); echo "</pre>";
     422function npqpDebug($data, $die = false)
     423{
     424    echo "<pre>";
     425    var_dump($data);
     426    echo "</pre>";
    393427    if ($die) exit(200);
    394428}
    395429
    396 function is_qrcodepage(){
    397     return wc_post_content_has_shortcode( 'NPQP-QR-CODE-PAGE' );
     430function is_qrcodepage()
     431{
     432    return wc_post_content_has_shortcode('NPQP-QR-CODE-PAGE');
    398433}
    399434
    400435// log
    401 function npqpLog($title, $data = false){
    402     $filename = dirname( __FILE__ ) . '/log.txt';
    403     if ( !$data ) {
    404         file_put_contents( $filename, date('d.m.Y/H:i:s') . ': ' . $_SERVER['REMOTE_ADDR'] . ': ' . $title . PHP_EOL, FILE_APPEND );
     436function npqpLog($title, $data = false)
     437{
     438    $filename = dirname(__FILE__) . '/log.txt';
     439    if (!$data) {
     440        file_put_contents($filename, date('d.m.Y/H:i:s') . ': ' . $_SERVER['REMOTE_ADDR'] . ': ' . $title . PHP_EOL, FILE_APPEND);
    405441    } else {
    406         file_put_contents( $filename, date('d.m.Y/H:i:s') . ': ' . $_SERVER['REMOTE_ADDR'] . ': ' . $title . PHP_EOL . var_export($data, true) . PHP_EOL, FILE_APPEND );
    407     }
    408 }
     442        file_put_contents($filename, date('d.m.Y/H:i:s') . ': ' . $_SERVER['REMOTE_ADDR'] . ': ' . $title . PHP_EOL . var_export($data, true) . PHP_EOL, FILE_APPEND);
     443    }
     444}
  • qr-payments-via-paypal/trunk/readme.txt

    r2367945 r2421686  
    1 === Qr payments via PayPal ===
     1=== WooCommerce Qr payments via PayPal ===
    22Contributors: nor1m
    33Donate link: https://paypal.me/nor1m
Note: See TracChangeset for help on using the changeset viewer.