Plugin Directory

Changeset 2803807


Ignore:
Timestamp:
10/25/2022 09:08:34 AM (3 years ago)
Author:
aircash
Message:

updated 1.0.2 version

Location:
aircash-for-woocommerce
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • aircash-for-woocommerce/tags/1.0.2/aircash-woocommerce.php

    r2802373 r2803807  
    1919
    2020add_action( 'init', 'aircash_load_textdomain' );
    21  
     21
    2222function aircash_load_textdomain() {
    23     load_plugin_textdomain( 'aircash-for-woocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
     23    load_plugin_textdomain( 'aircash-for-woocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    2424}
    2525if ( ! class_exists( 'WC_Aircash' ) ) {
     
    4242                add_action( 'admin_init', array( $this->get_aircash_payment_gateway(), 'admin_init' ) );
    4343                add_action( 'admin_init', array( $this->get_aircash_payment_gateway(), 'check_configuration' ) );
    44                 add_action('in_admin_footer', array($this->get_aircash_payment_gateway(), 'add_html_to_admin'));
     44                add_action('in_admin_footer', array($this->get_aircash_payment_gateway(), 'add_html_to_admin'));
    4545            }
    4646        }
     
    187187                                jQuery.post("<?php echo admin_url( 'admin-ajax.php' ); ?>", {
    188188                                    action: "aircash_dismiss_notice",
    189                                     dismiss_action: "<?php echo esc_js( $notice['dismiss_action'] ); ?>",
     189                                    dismiss_action: "<?php echo isset($notice['dismiss_action']) ? esc_js( $notice['dismiss_action']) : null; ?>",
    190190                                    nonce: "<?php echo esc_js( wp_create_nonce( 'aircash_dismiss_notice' ) ); ?>"
    191191                                });
  • aircash-for-woocommerce/tags/1.0.2/includes/class-aircash-payment-gateway.php

    r2802373 r2803807  
    545545                            echo base64_encode( $qr_code_image_data );
    546546                            ?>">
    547                             <?
     547                            <?php
    548548                        }
    549549                        ?>
  • aircash-for-woocommerce/trunk/aircash-woocommerce.php

    r2803780 r2803807  
    55 * Plugin URI:      https://aircash.eu/aircash-woocommerce/
    66 * Description:     Aircash - for quick and simple payments
    7  * Version:         1.0
     7 * Version:         1.0.2
    88 * Author:          Aircash
    99 * Requires PHP:    7.1
     
    1919
    2020add_action( 'init', 'aircash_load_textdomain' );
    21  
     21
    2222function aircash_load_textdomain() {
    23     load_plugin_textdomain( 'aircash-for-woocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
     23    load_plugin_textdomain( 'aircash-for-woocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    2424}
    2525if ( ! class_exists( 'WC_Aircash' ) ) {
     
    4242                add_action( 'admin_init', array( $this->get_aircash_payment_gateway(), 'admin_init' ) );
    4343                add_action( 'admin_init', array( $this->get_aircash_payment_gateway(), 'check_configuration' ) );
    44                 add_action('in_admin_footer', array($this->get_aircash_payment_gateway(), 'add_html_to_admin'));
     44                add_action('in_admin_footer', array($this->get_aircash_payment_gateway(), 'add_html_to_admin'));
    4545            }
    4646        }
     
    187187                                jQuery.post("<?php echo admin_url( 'admin-ajax.php' ); ?>", {
    188188                                    action: "aircash_dismiss_notice",
    189                                     dismiss_action: "<?php echo esc_js( $notice['dismiss_action'] ); ?>",
     189                                    dismiss_action: "<?php echo isset($notice['dismiss_action']) ? esc_js( $notice['dismiss_action']) : null; ?>",
    190190                                    nonce: "<?php echo esc_js( wp_create_nonce( 'aircash_dismiss_notice' ) ); ?>"
    191191                                });
  • aircash-for-woocommerce/trunk/includes/class-aircash-payment-gateway.php

    r2803780 r2803807  
    99use BaconQrCode\Renderer\ImageRenderer;
    1010use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
     11use BaconQrCode\Renderer\PlainTextRenderer;
    1112use BaconQrCode\Renderer\RendererStyle\RendererStyle;
    1213use BaconQrCode\Writer;
     
    6061        add_filter( 'wp_enqueue_scripts', array( $this, 'add_frontend_scripts' ) );
    6162        add_action( 'aircash_cron_hook', array( $this, 'update_aircash_account_status' ) );
     63        add_action( 'admin_head', array( $this, 'remove_manual_refund_button_for_aircash_orders' ) );
    6264    }
    6365
    6466    private function get_plugin_url(): string {
    6567        return untrailingslashit( plugins_url( '/', realpath( __DIR__ . '/../aircash-woocommerce.php' ) ) );
     68    }
     69
     70    /**
     71     * Hides the manual refund button
     72     *
     73     * @return void
     74     */
     75    public function remove_manual_refund_button_for_aircash_orders() {
     76        global $post;
     77        if ( ! $post ) {
     78            return;
     79        }
     80        if ( $post->post_type !== 'shop_order' ) {
     81            return;
     82        }
     83        $order = new WC_Order( $post->ID );
     84        if ( 'aircash-woocommerce' !== $order->get_payment_method() ) {
     85            return;
     86        }
     87        echo '<style>.do-manual-refund {display: none !important;}</style>';
    6688    }
    6789
     
    121143     */
    122144    public function add_html_to_admin() {
    123         echo '<div id="aircash-new-account-request-url" data-url="' . esc_attr($this->get_new_account_request_url()) . '"></div>';
     145        echo '<div id="aircash-new-account-request-url" data-url="' . esc_attr( $this->get_new_account_request_url() ) . '"></div>';
    124146    }
    125147
     
    427449            $order->save();
    428450        }
    429         $store_address   = get_option( 'woocommerce_store_address' );
    430         $store_address_2 = get_option( 'woocommerce_store_address_2' );
    431         $store_city      = get_option( 'woocommerce_store_city' );
    432         $store_postcode  = get_option( 'woocommerce_store_postcode' );
    433         $location        = null;
    434         if ( $store_address ) {
    435             $location .= $store_address . ', ';
    436         }
    437         if ( $store_address_2 ) {
    438             $location .= $store_address_2 . ', ';
    439         }
    440         if ( $store_city ) {
    441             $location .= trim( $store_postcode . ' ' . $store_city );
    442         }
    443         $store_raw_country = get_option( 'woocommerce_default_country' );
    444         if ( $store_raw_country ) {
    445             $location .= ', ' . $store_raw_country;
    446         }
     451        $location   = preg_replace( '/^https?:\/\//i', '', get_site_url() );
    447452        $parameters = array(
    448453            'Amount'               => (float) number_format( $order->get_total(), 2, '.', '' ),
     
    459464        // phpcs:ignore
    460465        ini_set( 'serialize_precision', - 1 );
    461         $body = wp_json_encode( $parameters, \JSON_UNESCAPED_SLASHES );
     466        $body = wp_json_encode( $parameters, JSON_UNESCAPED_SLASHES );
    462467        // phpcs:ignore
    463468        ini_set( 'serialize_precision', $serialize_precizion );
     
    472477            )
    473478        );
    474         $result   = $error_message = $qr_code_image_data = null;
     479        $result   = $error_message = $qr_code_image_data = $qr_code_textual = null;
    475480
    476481        $response_code = (int) wp_remote_retrieve_response_code( $response );
     
    485490            if ( isset( $result['codeLink'] ) && is_string( $result['codeLink'] ) ) {
    486491                // It's all good man, display the QR code
    487                 $renderer           = new ImageRenderer( new RendererStyle( 400 ), new ImagickImageBackEnd() );
    488                 $writer             = new Writer( $renderer );
    489                 $qr_code_image_data = $writer->writeString( $result['codeLink'] );
     492                if ( ! extension_loaded( 'imagick' ) ) {
     493                    $qr_code_textual    = true;
     494                    $renderer           = new PlainTextRenderer();
     495                    $writer             = new Writer( $renderer );
     496                    $qr_code_image_data = $writer->writeString( $result['codeLink'] );
     497                } else {
     498                    $qr_code_textual    = false;
     499                    $renderer           = new ImageRenderer( new RendererStyle( 400 ), new ImagickImageBackEnd() );
     500                    $writer             = new Writer( $renderer );
     501                    $qr_code_image_data = $writer->writeString( $result['codeLink'] );
     502                }
    490503            } else {
    491504                $error_message = 'Unable to generate QR code';
     
    520533
    521534                    <div class="aircash-qr-code-wrapper">
    522                         <img class="aircash-qr-code" src="data:image/png;base64,<?php
    523                         // phpcs:ignore
    524                         echo base64_encode( $qr_code_image_data );
    525                         ?>">
     535                        <?php
     536                        if ( $qr_code_textual ) {
     537                            ?>
     538                            <pre style="line-height:100%;color:black;font-family:monospace;font-size:11px;background:white;font-weight:100;letter-spacing:-1px;user-select:none;-webkit-user-select:none"><?php
     539                            echo $qr_code_image_data;
     540                            ?></pre><?php
     541                        } else {
     542                            ?>
     543                            <img class="aircash-qr-code" src="data:image/png;base64,<?php
     544                            // phpcs:ignore
     545                            echo base64_encode( $qr_code_image_data );
     546                            ?>">
     547                            <?php
     548                        }
     549                        ?>
    526550                        <ol>
    527551                            <li><?php echo esc_html__( 'Open Aircash application', 'aircash-for-woocommerce' ) ?></li>
     
    951975        $this->update_option( $aircash_callback_url_option, $callback_url );
    952976
    953         $body          = wp_json_encode( $parameters, \JSON_UNESCAPED_SLASHES ^ \JSON_UNESCAPED_LINE_TERMINATORS ^ \JSON_PRETTY_PRINT );
     977        $body          = wp_json_encode( $parameters, JSON_UNESCAPED_SLASHES ^ JSON_UNESCAPED_LINE_TERMINATORS ^ JSON_PRETTY_PRINT );
    954978        $response      = wp_remote_post(
    955979            'https://' . ( $test ? 'staging-m3.aircash.eu' : 'm3.aircash.eu' ) . '/api/AircashPay/ActivatePartner',
  • aircash-for-woocommerce/trunk/readme.txt

    r2803780 r2803807  
    44Requires at least: 4.7
    55Tested up to: 5.9.3
    6 Stable tag: 1.0
     6Stable tag: 1.0.2
    77Requires PHP: 7.1
    88License: GPLv2 or later
     
    101101== Changelog ==
    102102
     103= 1.0.2 =
     104
     105Updated refund option.
     106
    103107= 1.0.1 =
    104108
Note: See TracChangeset for help on using the changeset viewer.