Plugin Directory

Changeset 3700542


Ignore:
Timestamp:
09/17/2026 03:40:17 PM (6 weeks ago)
Author:
oxygensuite
Message:

release 3.0.4

Location:
oxygen-mydata/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • oxygen-mydata/trunk/inc/class-oxygen.php

    r3683155 r3700542  
    66 * Oxygen MyData Class File
    77 *
    8  * @version 3.0.2
     8 * @version 3.0.4
    99 * @since  1.0.0
    1010 */
    … …  
    122122
    123123                /* Texts (translations) that changes with jquery */
    124                 wp_localize_script(
    125                         'create_document_meta_box_js',
    126                         'MyLocalizedText',
    127                         array(
    128                                 'createInvoiceText'   => __( 'Create Invoice', 'oxygen' ),
    129                                 'createReceiptText'   => __( 'Create Receipt', 'oxygen' ),
    130                                 'error_option'        => __( 'An error occurred while changing option.', 'oxygen' ),
    131                                 'gateway_disabled'    => __( 'The gateway has been disabled successfully.', 'oxygen' ),
    132                                 'success_send'        => __( 'Document sent successfully to customer\'s email address.', 'oxygen' ),
    133                                 'error_send'          => __( 'An error occurred while sending document via email.', 'oxygen' ),
    134                                 'success_download'    => __( 'PDF document downloaded successfully.', 'oxygen' ),
    135                                 'error_downloading'   => __( 'An error occurred while downloading the file.', 'oxygen' ),
    136                                 'empty_document_name' => __( 'Document has no name', 'oxygen' ),
    137                 'do_not_refresh_page' => __( 'Your transaction is in progress, please wait.', 'oxygen' ),
    138                 'failed_oxygen_payment' => __( 'Your transaction failed.', 'oxygen' ),
    139                         )
     124                wp_localize_script( 'create_document_meta_box_js', 'MyLocalizedText', self::get_localized_texts() );
     125        }
     126
     127        /**
     128         * Texts (translations) exposed to JS as the `MyLocalizedText` global.
     129         *
     130         * Shared by the admin scripts and the front end scripts (checkout payment
     131         * modal, PDF download), so every handle that uses `MyLocalizedText` can
     132         * localize the same set.
     133         *
     134         * @return array
     135         */
     136        public static function get_localized_texts() {
     137
     138                return array(
     139                        'createInvoiceText'     => __( 'Create Invoice', 'oxygen' ),
     140                        'createReceiptText'     => __( 'Create Receipt', 'oxygen' ),
     141                        'error_option'          => __( 'An error occurred while changing option.', 'oxygen' ),
     142                        'gateway_disabled'      => __( 'The gateway has been disabled successfully.', 'oxygen' ),
     143                        'success_send'          => __( 'Document sent successfully to customer\'s email address.', 'oxygen' ),
     144                        'error_send'            => __( 'An error occurred while sending document via email.', 'oxygen' ),
     145                        'success_download'      => __( 'PDF document downloaded successfully.', 'oxygen' ),
     146                        'error_downloading'     => __( 'An error occurred while downloading the file.', 'oxygen' ),
     147                        'empty_document_name'   => __( 'Document has no name', 'oxygen' ),
     148                        'do_not_refresh_page'   => __( 'Your transaction is in progress, please wait.', 'oxygen' ),
     149                        'failed_oxygen_payment' => __( 'Your transaction failed.', 'oxygen' ),
    140150                );
    141151        }
  • oxygen-mydata/trunk/inc/class-oxygenapi.php

    r3683155 r3700542  
    66 * OxygenApi Class File
    77 *
    8  * @version 3.0.2
     8 * @version 3.0.4
    99 * @since  1.0.0
    1010 */
    … …  
    8282                } else {
    8383
    84             self::$api_url = 'https://sandbox-api.oxygen.gr/v1';
     84//            self::$api_url = 'https://sandbox-api.oxygen.gr/v1';
     85            self::$api_url = 'https://api-dev.oxygen.gr/v1';
     86
    8587        }
    8688
  • oxygen-mydata/trunk/inc/class-oxygenhelperfunctions.php

    r3683155 r3700542  
    55 * @package Oxygen
    66 * @summary Class to add WooCommerce settings tab and fields, WooCommerce Helper Funtions
    7  * @version 3.0.2
     7 * @version 3.0.4
    88 * @since  1.0.0
    99 */
  • oxygen-mydata/trunk/inc/class-oxygenorder.php

    r3683155 r3700542  
    55 * @package Oxygen
    66 * @summary Class to add WooCommerce order hooks
    7  * @version 3.0.2
     7 * @version 3.0.4
    88 * @since  1.0.0
    99 */
    … …  
    384384        $iris_payment_status = get_post_meta( $order_id, 'everypay_iris_payment_status', true );
    385385        $transfer_status     = get_post_meta( $order_id, 'everypay_transfer_status', true );
    386         $card_payment_status  = get_post_meta( $order_id, 'everypay_card_payment_status', true );
     386        $card_payment_status = get_post_meta( $order_id, 'everypay_card_payment_status', true );
    387387
    388388        $messages = [];
    389389
    390         if ( $iris_payment_status === '1' || $iris_payment_status === 1 || $iris_payment_status === true ) {
     390        $iris_result = self::payment_status_result( $iris_payment_status );
     391
     392        if ( true === $iris_result ) {
    391393            $messages[] = '<span style="color:#28a745;">✓ ' . __( 'IRIS payment: Success', 'oxygen' ) . '</span>';
    392         } elseif ( $iris_payment_status === '0' || $iris_payment_status === 0 || $iris_payment_status === false ) {
     394        } elseif ( false === $iris_result ) {
    393395            $messages[] = '<span style="color:#dc3232;">✗ ' . __( 'IRIS payment: Failed', 'oxygen' ) . '</span>';
    394         }else if($card_payment_status === '1' || $card_payment_status === 1 || $card_payment_status === true){
     396        }
     397
     398        /* Own chain, not an elseif on IRIS: an order can fail IRIS and then be paid by card. */
     399        $card_result = self::payment_status_result( $card_payment_status );
     400
     401        if ( true === $card_result ) {
    395402            $messages[] = '<span style="color:#28a745;">✓ ' . __( 'Payment by card: Success', 'oxygen' ) . '</span>';
    396         } elseif ( $card_payment_status === '0' || $card_payment_status === 0 || $card_payment_status === false ) {
     403        } elseif ( false === $card_result ) {
    397404            $messages[] = '<span style="color:#dc3232;">✗ ' . __( 'Payment by card: Failed', 'oxygen' ) . '</span>';
    398         }else{
    399             $messages[] = '<span style="color:#dc3232;">-</span>';
    400         }
    401 
    402         if ( $transfer_status === '1' || $transfer_status === 1 || $transfer_status === true ) {
     405        }
     406
     407        $transfer_result = self::payment_status_result( $transfer_status );
     408
     409        if ( true === $transfer_result ) {
    403410            $messages[] = '<span style="color:#28a745;">✓ ' . __( 'IRIS Transfer: Completed', 'oxygen' ) . '</span>';
    404         } elseif ( $transfer_status === '0' || $transfer_status === 0 || $transfer_status === false ) {
     411        } elseif ( false === $transfer_result ) {
    405412            $messages[] = '<span style="color:#dc3232;">✗ ' . __( 'IRIS Transfer: Failed', 'oxygen' ) . '</span>';
    406413        }
    407414
    408415        echo $messages ? implode('<br>', $messages) : '—';
     416    }
     417
     418    /**
     419     *  Resolves a payment status meta value into a tri-state result.
     420     *
     421     *  WordPress stores a boolean false as an empty string, so an empty value can never
     422     *  be read as "failed" - it is indistinguishable from a meta key that was never
     423     *  written. Failures must therefore be recorded as 0 / '0'.
     424     *
     425     *  @param mixed $value raw meta value.
     426     *  @return bool|null true on success, false on failure, null when nothing was recorded.
     427     */
     428    private static function payment_status_result( $value ) {
     429
     430        if ( '' === $value || null === $value ) {
     431            return null;
     432        }
     433
     434        return (bool) $value;
    409435    }
    410436
    … …  
    28152841            )
    28162842    );
     2843
     2844    /* download_pdf.js also runs on the front end, where the admin-only localization is absent. */
     2845    wp_localize_script( 'download_pdf', 'MyLocalizedText', Oxygen::get_localized_texts() );
    28172846}
    28182847
  • oxygen-mydata/trunk/inc/class-oxygenwoosettings.php

    r3683155 r3700542  
    55 * @package Oxygen
    66 * @summary Class to add WooCommerce settings tab and fields, WooCommerce categories fields
    7  * @version 3.0.2
     7 * @version 3.0.4
    88 * @since  1.0.0
    99 */
  • oxygen-mydata/trunk/inc/class-wc-oxygenpayment-gateway.php

    r3683155 r3700542  
    44 *
    55 * @package Oxygen Payments
    6  * @version 3.0.2
     6 * @version 3.0.4
    77 * @author Oxygen
    88 * @since 1.0.0
    … …  
    512512                $api_url = 'https://api.oxygen.gr/v1';
    513513        } else {
    514         $api_url = 'https://sandbox-api.oxygen.gr/v1';
     514//        $api_url = 'https://sandbox-api.oxygen.gr/v1';
     515        $api_url = 'https://api-dev.oxygen.gr/v1';
     516
    515517    }
    516518
    … …  
    705707}
    706708
    707 add_filter( 'query_vars', 'my_add_query_vars' );
     709//add_filter( 'query_vars', 'my_add_query_vars' );
    708710
    709711/**
    … …  
    729731                wp_enqueue_script( 'custom_payment_js', OXYGEN_PLUGIN_URL . 'js/custom_payment.js', array( 'jquery' ), null, true );
    730732                wp_enqueue_script( 'iris_payment_js', OXYGEN_PLUGIN_URL . 'js/iris_payment.js', array( 'jquery' ), null, true );
     733
     734                /* Texts used by custom_payment.js while the transaction is running. */
     735                wp_localize_script( 'custom_payment_js', 'MyLocalizedText', Oxygen::get_localized_texts() );
     736
     737                wp_localize_script(
     738                        'custom_payment_js',
     739                        'oxygen_payment_request',
     740                        array(
     741                                'url' => OXYGEN_PLUGIN_URL . 'inc/request-handle-message.php',
     742                        )
     743                );
    731744        }
    732745}
    … …  
    13011314        'methods'  => 'POST',
    13021315        'callback' => 'oxygen_everypay_status_callback',
    1303 //        'permission_callback' => '__return_true',
     1316        'permission_callback' => '__return_true',
    13041317    ]);
    13051318});
  • oxygen-mydata/trunk/inc/request-handle-message.php

    r3683155 r3700542  
    44 *
    55 * @package Oxygen Payments
    6  * @version 3.0.2
     6 * @version 3.0.4
    77 * @author Oxygen
    88 * @since 1.0.0
    … …  
    1818$nonce = wp_create_nonce( 'payment_id' );
    1919
     20OxygenHelperFunctions::debug( array( '[card-payment] ===== request-handle-message.php entered =====' ), 'info' );
    2021
    2122if ( isset( $_POST['payment_id'] ) && wp_verify_nonce( $nonce, 'payment_id' ) ) {
    2223        $payment_id = sanitize_key( $_POST['payment_id'] );
     24
     25        OxygenHelperFunctions::debug( array( '[card-payment] payment_id from POST: ' . $payment_id ), 'info' );
    2326} else {
     27        OxygenHelperFunctions::debug( array( '[card-payment] no payment_id in POST - aborting' ), 'warning' );
     28
    2429        $response = array( 'status' => 'given payment id is null' );
    2530        echo wp_json_encode( $response );
    … …  
    4550        );
    4651
     52        OxygenHelperFunctions::debug( array( '[card-payment] GET ' . $endpoint ), 'info' );
     53
    4754        $response_from_api = wp_remote_get( $endpoint, $options );
     55
     56        OxygenHelperFunctions::debug(
     57                array( '[card-payment] API HTTP code: ' . wp_remote_retrieve_response_code( $response_from_api ) ),
     58                'info'
     59        );
    4860
    4961        if ( ! is_wp_error( $response_from_api ) ) {
    … …  
    5769
    5870
     71                        $order_id = WC()->session->get( 'order_id' );
     72
     73                        OxygenHelperFunctions::debug(
     74                                array(
     75                                        '[card-payment] decoded API payload',
     76                                        $array_data,
     77                                        '[card-payment] is_paid: ' . var_export( $is_paid, true ),
     78                                        '[card-payment] receipt id: ' . var_export( $has_receipt_id, true ),
     79                                        '[card-payment] order_id from WC session: ' . var_export( $order_id, true ),
     80                                ),
     81                                'info'
     82                        );
     83
    5984                        if ( $is_paid ) {
    6085
    61                                 $order_id = WC()->session->get( 'order_id' );
    6286                                $my_order = wc_get_order( $order_id );
     87
     88                                if ( ! $my_order ) {
     89                                        OxygenHelperFunctions::debug(
     90                                                array( '[card-payment] wc_get_order() returned false - session order_id is stale or missing' ),
     91                                                'error'
     92                                        );
     93                                } else {
     94                                        OxygenHelperFunctions::debug(
     95                                                array( '[card-payment] order status before payment_complete: ' . $my_order->get_status() ),
     96                                                'info'
     97                                        );
     98                                }
     99
    63100                                $my_order->payment_complete();
    64101                                $my_order->update_status( 'wc-processing' );
    65                 update_post_meta( $order_id, 'everypay_card_payment_status', true );
     102                update_post_meta( $order_id, 'everypay_card_payment_status', 1 );
    66103
    67104                                if ( !empty($has_receipt_id) ) {
    … …  
    73110                                }
    74111
    75                 $thankyou = WC()->session->get( 'thankyou_link' );
     112//                $thankyou = WC()->session->get( 'thankyou_link' );
     113                $thankyou = $my_order->get_checkout_order_received_url();
     114
     115                                OxygenHelperFunctions::debug(
     116                                        array(
     117                                                '[card-payment] order status after status updates: ' . $my_order->get_status(),
     118                                                '[card-payment] redirect returned to JS: ' . $thankyou,
     119                                                /* If this still carries order-pay, WooCommerce routes to the pay page and
     120                                                   refuses it because the order no longer needs payment. */
     121                                                '[card-payment] redirect contains order-pay: ' . ( false !== strpos( $thankyou, 'order-pay' ) ? 'YES - BUG' : 'no' ),
     122                                                '[card-payment] old session thankyou_link (unused): ' . var_export( WC()->session->get( 'thankyou_link' ), true ),
     123                                        ),
     124                                        'info'
     125                                );
    76126
    77127                                $response = array(
    … …  
    82132
    83133                        } else {
     134
     135                                /*
     136                                 * Record the failure as 0, never as false: WordPress stores a boolean
     137                                 * false as an empty string, which oxygen_payments_details_global cannot
     138                                 * tell apart from "no card payment was ever attempted".
     139                                 */
     140                                if ( ! empty( $order_id ) ) {
     141                                        update_post_meta( $order_id, 'everypay_card_payment_status', 0 );
     142                                }
     143
     144                                OxygenHelperFunctions::debug(
     145                                        array( '[card-payment] NOT PAID - everypay_card_payment_status set to 0 for order ' . var_export( $order_id, true ) ),
     146                                        'warning'
     147                                );
     148
    84149                                $response = array( 'status' => 'not_paid' );
    85150                                echo wp_json_encode( $response );
    86151                        }
    87152                } else {
     153                        OxygenHelperFunctions::debug( array( '[card-payment] API returned an empty body' ), 'error' );
     154
    88155                        $response = array( 'status' => 'null_data' );
    89156                        echo wp_json_encode( $response );
    … …  
    92159        } else {
    93160                $error_message = $response_from_api->get_error_message();
     161
     162                OxygenHelperFunctions::debug( array( '[card-payment] wp_remote_get failed: ' . $error_message ), 'error' );
     163
    94164                $response      = array(
    95165                        'status'        => 'error',
    … …  
    99169        }
    100170} else {
     171        OxygenHelperFunctions::debug( array( '[card-payment] payment_id empty - nothing to do' ), 'warning' );
     172
    101173        echo 'empty payment id';
    102174}
     175
     176OxygenHelperFunctions::debug( array( '[card-payment] ===== request-handle-message.php finished =====' ), 'info' );
  • oxygen-mydata/trunk/inc/templates/plain-invoice-email-template.php

    r3683155 r3700542  
    77 *
    88 * @package Oxygen
    9  * @version 3.0.2
     9 * @version 3.0.4
    1010 *
    1111 * @param string   $email_heading Heading for the email.
  • oxygen-mydata/trunk/oxygen-mydata.php

    r3697066 r3700542  
    44 * Plugin URI: https://wordpress.org/plugins/oxygen-mydata/
    55 * Description: WooCommerce integration with MyData invoices for Greece.
    6  * Version: 3.03
     6 * Version: 3.0.4
    77 * Author: oxygensuite
    88 * Author URI: https://www.pelatologio.gr/
    … …  
    2222 *
    2323 * @package Oxygen
    24  * @version 3.03
     24 * @version 3.0.4
    2525 * @since   1.0.0
    2626 */
    … …  
    2929
    3030// Define constants.
    31 define( 'OXYGEN_PLUGIN_VERSION', '3.03' );
     31define( 'OXYGEN_PLUGIN_VERSION', '3.0.4' );
    3232define( 'OXYGEN_PLUGIN_FILE', __FILE__ );
    3333define( 'OXYGEN_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • oxygen-mydata/trunk/readme.txt

    r3697066 r3700542  
    1010WC requires at least: 4.7
    1111WC tested up to: 11.0.1
    12 Version: 3.03
    13 Stable tag: 3.03
     12Version: 3.0.4
     13Stable tag: 3.0.4
    1414License: GPLv2
    1515License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    117117== Changelog ==
    118118
     119= 3.0.4 =
     120* Fixed bug with oxygen payments - payment with card
     121* Fixed register_rest_route error for permission callback at payment gateway
     122* Fixed MyLocalizedText variable not defined
     123
    119124= 3.0.3 =
    120125* Fixed on skroutz invoice uploader - reduce resources usage
Note: See TracChangeset for help on using the changeset viewer.