Plugin Directory

Changeset 3105176


Ignore:
Timestamp:
06/20/2024 02:15:24 PM (22 months ago)
Author:
totalprocessing
Message:
  • Added compatibility support for the latest WooCommerce version.
  • Included detailed instructions for raising issues in the FAQs section.
  • Improved design compatibility with WooCommerce block features.
  • Implemented compatibility fixes for HPOS.
  • Enhanced the log system to save logs when an iframe loads.
  • Improved error handling during final transaction validation.
  • Fixed a query hook that was causing issues.
  • Updated the FAQs section to display sub-items without affecting the main items.
  • Added styling to display a loader in WooCommerce block features.
Location:
totalprocessing-card-payments
Files:
128 added
13 edited

Legend:

Unmodified
Added
Removed
  • totalprocessing-card-payments/trunk/admin/partials/admin-options.php

    r2908434 r3105176  
    204204                        <div id="collapse<?php echo $k;?>" class="accordion-collapse collapse" data-bs-parent="#faqAccordion">
    205205                            <div class="card-body">
     206                                <?php if( is_array( $faq['answer'] ) ):?>
     207                                <div class="accordion" id="subFaqAccordion">
     208                                    <?php $kk = 0;foreach( $faq['answer'] AS $kk => $subFaq ):?>
     209                                    <div class="accordion-item">
     210                                        <h2 class="accordion-header" id="heading<?php echo $kk;?>">
     211                                            <button type="button" class="accordion-button collapsed" data-bs-toggle="collapse" data-bs-target="#subcollapse<?php echo $kk;?>"><?php echo ($kk+1);?>. <?php echo $subFaq['question'];?></button>                                 
     212                                        </h2>
     213                                        <div id="subcollapse<?php echo $kk;?>" class="accordion-collapse collapse" data-bs-parent="#subFaqAccordion">
     214                                            <div class="card-body">
     215                                                <p><?php echo $subFaq['answer'];?></p>
     216                                            </div>
     217                                        </div>
     218                                    </div>
     219                                    <?php endforeach;?>
     220                                </div>
     221                                <?php else:?>
    206222                                <p><?php echo $faq['answer'];?></p>
     223                                <?php endif;?>
    207224                            </div>
    208225                        </div>
  • totalprocessing-card-payments/trunk/assets/css/cardsv2-style.css

    r2908434 r3105176  
    11#cnpFrame {width: 100%; border: none;}#cnpSwal {margin-bottom: 0.3rem; margin-top: 1rem;}#cnpNav {display: flex; align-items: center; justify-content: center;}#cnpNav button {font-size: small; margin: 5px; border-radius: 0.25em; font-weight: lighter;}
     2#tpcpv3_inline-loading{display:flex; align-items: center; justify-content: center;}
     3.dot-bricks {
     4  position: relative;
     5  top: 8px;
     6  left: -9999px;
     7  width: 12px;
     8  height: 12px;
     9  border-radius: 2px;
     10  background-color: #BDBDBD;
     11  color: #BDBDBD;
     12  box-shadow: 9991px -16px 0 0 #BDBDBD, 9991px 0 0 0 #BDBDBD, 10007px 0 0 0 #BDBDBD;
     13  animation: dot-bricks 2s infinite ease;
     14}
     15@keyframes dot-bricks {
     16  0% {
     17    box-shadow: 9991px -16px 0 0 #BDBDBD, 9991px 0 0 0 #BDBDBD, 10007px 0 0 0 #BDBDBD;
     18  }
     19  8.333% {
     20    box-shadow: 10007px -16px 0 0 #BDBDBD, 9991px 0 0 0 #BDBDBD, 10007px 0 0 0 #BDBDBD;
     21  }
     22  16.667% {
     23    box-shadow: 10007px -16px 0 0 #BDBDBD, 9991px -16px 0 0 #BDBDBD, 10007px 0 0 0 #BDBDBD;
     24  }
     25  25% {
     26    box-shadow: 10007px -16px 0 0 #BDBDBD, 9991px -16px 0 0 #BDBDBD, 9991px 0 0 0 #BDBDBD;
     27  }
     28  33.333% {
     29    box-shadow: 10007px 0 0 0 #BDBDBD, 9991px -16px 0 0 #BDBDBD, 9991px 0 0 0 #BDBDBD;
     30  }
     31  41.667% {
     32    box-shadow: 10007px 0 0 0 #BDBDBD, 10007px -16px 0 0 #BDBDBD, 9991px 0 0 0 #BDBDBD;
     33  }
     34  50% {
     35    box-shadow: 10007px 0 0 0 #BDBDBD, 10007px -16px 0 0 #BDBDBD, 9991px -16px 0 0 #BDBDBD;
     36  }
     37  58.333% {
     38    box-shadow: 9991px 0 0 0 #BDBDBD, 10007px -16px 0 0 #BDBDBD, 9991px -16px 0 0 #BDBDBD;
     39  }
     40  66.666% {
     41    box-shadow: 9991px 0 0 0 #BDBDBD, 10007px 0 0 0 #BDBDBD, 9991px -16px 0 0 #BDBDBD;
     42  }
     43  75% {
     44    box-shadow: 9991px 0 0 0 #BDBDBD, 10007px 0 0 0 #BDBDBD, 10007px -16px 0 0 #BDBDBD;
     45  }
     46  83.333% {
     47    box-shadow: 9991px -16px 0 0 #BDBDBD, 10007px 0 0 0 #BDBDBD, 10007px -16px 0 0 #BDBDBD;
     48  }
     49  91.667% {
     50    box-shadow: 9991px -16px 0 0 #BDBDBD, 9991px 0 0 0 #BDBDBD, 10007px -16px 0 0 #BDBDBD;
     51  }
     52  100% {
     53    box-shadow: 9991px -16px 0 0 #BDBDBD, 9991px 0 0 0 #BDBDBD, 10007px 0 0 0 #BDBDBD;
     54  }
     55}
  • totalprocessing-card-payments/trunk/assets/js/tpJs-cardsv2x.js

    r3031406 r3105176  
    162162            }
    163163        });
     164    }
     165
     166    tp.finalOrderPaymentProcess = function( response ){
     167        if(tpCardsInProgress === true){
     168            cardsv2Log('form in 3d progress!!');
     169            return;
     170        }
     171        tpCardsInProgress = false;
     172        cardsv2Log('final payment process for order:');
     173        cardsv2Log(response);
     174        pciFormSubmit(cardIframeID,"wpwl-container-card");
    164175    }
    165176
     
    290301            cardsv2Log(e);
    291302        });
    292         /*$.post(tp.tpCardVars.adminUrl, { action: globalPrefix + 'validate_tp_cardsv2_checkout', resourcePath: args[0]}, function(response) {
    293             cardsv2Log(response);
    294             if(response.hasOwnProperty("data")){
    295                 if(response.data.hasOwnProperty("url")){
    296                     window.location = (response.data.url);
    297                 } else {
    298                     $('body').trigger("update_checkout");
    299                     $('#tpCardsBtnReplace').remove();
    300                     $('#place_order').show();
    301                 }
    302             } else {
    303                 $('body').trigger("update_checkout");
    304                 $('#tpCardsBtnReplace').remove();
    305                 $('#place_order').show();
    306             }
    307         }).done(function(response){
    308             console.log('done');
    309             console.log(response);
    310         })
    311         .fail(function(response){
    312             console.log('failed');
    313             console.log(response);
    314         }).always(function(response){
    315             console.log('always');
    316             console.log(response);
    317         });*/
     303    }
     304
     305    function do_log_errors(args){
     306        Promise.resolve(
     307            $.ajax({
     308                type: 'POST',
     309                url: tp.tpCardVars.adminUrl,
     310                data: { action: globalPrefix + 'do_log_errors', errors: args[0], order_id: args[1]},
     311                success: function(response) {
     312                    cardsv2Log(args[0]);
     313                },
     314                error: function(jqXHR, textStatus, errorThrown){
     315                    alert( "Error(#3):" + "\n" + 'Message::' + textStatus + '->' + errorThrown + "\n" + 'resource:' + args[0] ); 
     316                    cardsv2Log(jqXHR);
     317                    cardsv2Log(textStatus);
     318                    cardsv2Log(errorThrown);
     319                },
     320            })
     321        ).then(function(){
     322            //do something
     323        }).catch(function(e) {
     324            alert( "Error(#3):" + "\n" + 'resource:' + args[0] );
     325            cardsv2Log(e);
     326        });
    318327    }
    319328
     
    344353        cardsv2Log('checkout endpoint docReady!');
    345354        cardsv2Log(tp.tpCardVars.pluginId + ' v.' + tp.tpCardVars.pluginVer);
    346         //cardsv2Log('wc_checkout_params =>');
    347         //cardsv2Log(wc_checkout_params);
    348         //cardsv2Log(tpCardVars);
    349355        window.document.addEventListener('parentLogV52', logToParentWindow, false);
    350         //var checkout_form = $( 'form.woocommerce-checkout' );
    351         //checkout_form.on( 'checkout_place_order', tp.tpCardsHandoff );
    352         //cardsv2Log('selected payment method onLoad =>');
    353         //cardsv2Log( $('form.woocommerce-checkout').find('input[name^="payment_method"]:checked').val() );
    354         /*$('body').on('updated_checkout', function() {
    355               cardsv2Log('checkout was updated!');
    356             if($('iframe#' + cardIframeID).length === 0){
    357         cardsv2Log('Checkout Iframe is initiated');
    358                 instantiateCheckoutIdOrder();
    359             }
    360         });*/
    361356    }
    362357} )( window.wc_gateway_tp = window.wc_gateway_tp || {}, jQuery );
  • totalprocessing-card-payments/trunk/assets/js/tpJs-cardsv2x_orderpay.js

    r3031406 r3105176  
    5353                    cardsv2Log( err );
    5454                }
    55                 /*if( typeof tp.{e.detail.funcs[ i ].name} === 'function' ){
    56                     tp.{e.detail.funcs[ i ].name}( e.detail.funcs[i].args );
    57                 } else {
    58                     cardsv2Log( e.detail.funcs[ i ].name );
    59                 }*/
    6055            }
    6156        }
     
    300295    }
    301296
     297    function do_log_errors(args){
     298        Promise.resolve(
     299            $.ajax({
     300                type: 'POST',
     301                url: tp.tpCardVars.adminUrl,
     302                data: { action: globalPrefix + 'do_log_errors', errors: args[0], order_id: args[1]},
     303                success: function(response) {
     304                    cardsv2Log(args[0]);
     305                },
     306                error: function(jqXHR, textStatus, errorThrown){
     307                    alert( "Error(#3):" + 'Message::' + textStatus + '->' + errorThrown + "\n" + 'resource:' + args[0] ); 
     308                    cardsv2Log(jqXHR);
     309                    cardsv2Log(textStatus);
     310                    cardsv2Log(errorThrown);
     311                },
     312            })
     313        ).then(function(){
     314            //do something
     315        }).catch(function(e) {
     316            alert( "Error(#3):" + "\n" + 'resource:' + args[0] );
     317            cardsv2Log(e);
     318        });
     319    }
     320
    302321    function progress_tp_cardsv2(args){
    303322        if(args.length === 1){
     
    332351        cardsv2Log('checkout endpoint docReady!');
    333352        cardsv2Log(tp.tpCardVars.pluginId + ' v.' + tp.tpCardVars.pluginVer);
    334         //cardsv2Log('wc_checkout_params =>');
    335         //cardsv2Log(wc_checkout_params);
    336         //cardsv2Log(tpCardVars);
    337353        window.document.addEventListener('parentLogV52', logToParentWindow, false);
    338         //var checkout_form = $( 'form.woocommerce-checkout' );
    339         //checkout_form.on( 'checkout_place_order', tp.tpCardsHandoff );
    340         //cardsv2Log('selected payment method onLoad =>');
    341         //cardsv2Log( $('form.woocommerce-checkout').find('input[name^="payment_method"]:checked').val() );
    342         /*$('body').on('updated_checkout', function() {
    343               cardsv2Log('checkout was updated!');
    344             if($('iframe#' + cardIframeID).length === 0){
    345         cardsv2Log('Checkout Iframe is initiated');
    346                 instantiateCheckoutIdOrder();
    347             }
    348         });*/
    349354    }
    350355} )( window.wc_gateway_tp = window.wc_gateway_tp || {}, jQuery );
  • totalprocessing-card-payments/trunk/gateways/open-banking-payment/openbanking.php

    r3022827 r3105176  
    153153            $tp_pluginVer       = TP_OPENBANKING_VERSION;
    154154            $prefix             = TP_OPENBANKING_PREFIX;
    155             wp_register_script( $prefix . 'tp_openbanking', plugin_dir_url( __FILE__ ).'assets/js/open-banking-widget-initiator.js', ['jquery','wp-util'], $tp_pluginVer );
    156 
    157             wp_register_script( $prefix . 'tp_fetch', 'https://cdn.jsdelivr.net/npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js' , ['jquery','wp-util'] , true );
    158             wp_register_script( $prefix . 'tp_swal', 'https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.all.min.js' , ['jquery','wp-util'] , true );
    159             wp_register_script( $prefix . 'tp_swal_poly1', 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.12.1/polyfill.min.js' , [] , true );
    160             wp_register_script( $prefix . 'tp_swal_poly2', 'https://cdn.jsdelivr.net/npm/promise-polyfill@8.1.3/dist/polyfill.js' , [] , true );
     155            wp_register_script( $prefix . 'tp_openbanking', plugin_dir_url( __FILE__ ).'assets/js/open-banking-widget-initiator.js', ['jquery','wp-util'], $tp_pluginVer, array("in_footer" => true) );
     156
     157            wp_register_script( $prefix . 'tp_fetch', 'https://cdn.jsdelivr.net/npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js' , ['jquery','wp-util'] , true, array("in_footer" => true) );
     158            wp_register_script( $prefix . 'tp_swal', 'https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.all.min.js' , ['jquery','wp-util'] , true, array("in_footer" => true) );
     159            wp_register_script( $prefix . 'tp_swal_poly1', 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.12.1/polyfill.min.js' , [] , true, array("in_footer" => true) );
     160            wp_register_script( $prefix . 'tp_swal_poly2', 'https://cdn.jsdelivr.net/npm/promise-polyfill@8.1.3/dist/polyfill.js' , [] , true, array("in_footer" => true) );
    161161
    162162            wp_localize_script( $prefix . 'tp_openbanking', $prefix . 'GlobalVars', [
  • totalprocessing-card-payments/trunk/includes/class-totalprocessing-constants.php

    r3031406 r3105176  
    1010
    1111class WC_TotalProcessing_Constants {
    12     const VERSION                          = "5.3.4";
    13     const DEBUG                            = false;
    14     const GLOBAL_PREFIX                    = "tpcpv3_";
    15     const GATEWAY_ID                       = "wc_tp_cardsv3";
    16     const GATEWAY_TITLE                    = "Total Processing Card Payments";
    17     const GATEWAY_DESCRIPTION              = "Card payment customisable in your payment flow. Checkout with Credit/Debit Card.";
    18     const PROXY_URL                        = "https://oppwa.totalprocessing.com/";
    19     const DEBUG_CONTACT_EMAIL              = "plugins@totalprocessing.com";
     12    const VERSION                                          = "5.4.2";
     13    const DEBUG                                            = false;
     14    const GLOBAL_PREFIX                                    = "tpcpv3_";
     15    const GATEWAY_ID                                       = "wc_tp_cardsv3";
     16    const GATEWAY_TITLE                                    = "Total Processing Card Payments";
     17    const GATEWAY_DESCRIPTION                              = "Card payment customisable in your payment flow. Checkout with Credit/Debit Card.";
     18    const PROXY_URL                                        = "https://oppwa.totalprocessing.com/";
     19    const DEBUG_CONTACT_EMAIL                              = "plugins@totalprocessing.com";
     20    const DISABLE_CHECKOUT_INIT_PAYMENT_CHECK              = true;
    2021
    2122    public static function getPluginBaseURL(){
  • totalprocessing-card-payments/trunk/includes/class-tp-payment-gateway.php

    r3036898 r3105176  
    310310        add_action( 'wp_ajax_' . TP_CONSTANTS::GLOBAL_PREFIX . 'download_debugdata_file', array( $this, 'ajax_download_debugdata_file' ) );
    311311
     312        add_action( 'woocommerce_blocks_enqueue_checkout_block_scripts_before', [$this, 'show_tp_errors'] );
     313
    312314        //check plugin
    313315        if($this->check_plugin()){
     
    578580            if($this->useModalPayFrames === true){
    579581                if(is_add_payment_method_page()){
    580                     wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_registration.js', ['jquery','wp-util'], $tp_pluginVer );
     582                    wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_registration.js', ['jquery','wp-util'], $tp_pluginVer, array("in_footer" => true) );
    581583                } else if(is_wc_endpoint_url( 'order-pay' )){
    582584                    //wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_orderpay.js', ['jquery','wp-util'], $tp_pluginVer );
    583585                    if($this->jsLogging === true){
    584                         wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_orderpay_logging.js', ['jquery','wp-util'], $tp_pluginVer );
     586                        wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_orderpay_logging.js', ['jquery','wp-util'], $tp_pluginVer, array("in_footer" => true) );
    585587                    } else {
    586                         wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_orderpay_logging_off.js', ['jquery','wp-util'], $tp_pluginVer );
     588                        wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_orderpay_logging_off.js', ['jquery','wp-util'], $tp_pluginVer, array("in_footer" => true) );
    587589                    }
    588590                } else {
    589591                    if($this->jsLogging === true){
    590                         wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_logging.js', ['jquery','wp-util'], $tp_pluginVer );
     592                        wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_logging.js', ['jquery','wp-util'], $tp_pluginVer, array("in_footer" => true) );
    591593                    } else {
    592                         wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_logging_off.js', ['jquery','wp-util'], $tp_pluginVer );
     594                        wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2_logging_off.js', ['jquery','wp-util'], $tp_pluginVer, array("in_footer" => true) );
    593595                    }
    594596                }
     
    596598                if( is_wc_endpoint_url( 'order-pay' ) ){
    597599                    $order_id = intval(get_query_var('order-pay'));
    598                     wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2x_orderpay.js' , ['jquery','wp-util'], $tp_pluginVer );
     600                    wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2x_orderpay.js' , ['jquery','wp-util'], $tp_pluginVer, array("in_footer" => true) );
    599601                }else{
    600                     wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2x.js' , ['jquery','wp-util'], $tp_pluginVer );
    601                 }
    602             }
    603             wp_register_script( $prefix . 'tp_fetch', 'https://cdn.jsdelivr.net/npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js' , ['jquery','wp-util'] , true );
    604             wp_register_script( $prefix . 'tp_swal', 'https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.all.min.js' , ['jquery','wp-util'] , true );
    605             wp_register_script( $prefix . 'tp_swal_poly1', 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.12.1/polyfill.min.js' , [] , true );
    606             wp_register_script( $prefix . 'tp_swal_poly2', 'https://cdn.jsdelivr.net/npm/promise-polyfill@8.1.3/dist/polyfill.js' , [] , true );
     602                    wp_register_script( $prefix . 'tp_cards', plugin_dir_url( dirname( __FILE__ ) ).'assets/js/tpJs-cardsv2x.js' , ['jquery','wp-util'], $tp_pluginVer, array("in_footer" => true) );
     603                }
     604            }
     605            wp_register_script( $prefix . 'tp_fetch', 'https://cdn.jsdelivr.net/npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js' , ['jquery','wp-util'] , true, array("in_footer" => true) );
     606            wp_register_script( $prefix . 'tp_swal', 'https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.all.min.js' , ['jquery','wp-util'] , true, array("in_footer" => true) );
     607            wp_register_script( $prefix . 'tp_swal_poly1', 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.12.1/polyfill.min.js' , [] , true, array("in_footer" => true) );
     608            wp_register_script( $prefix . 'tp_swal_poly2', 'https://cdn.jsdelivr.net/npm/promise-polyfill@8.1.3/dist/polyfill.js' , [] , true, array("in_footer" => true) );
    607609
    608610            wp_localize_script( $prefix . 'tp_cards', $prefix . 'CardVars', [
     
    688690            $amount = $forceAmount;
    689691        } else {
    690             $amount = WC()->cart->get_total(null);
     692            if(isset(WC()->cart)){
     693                $amount = WC()->cart->get_total(null);
     694            }else{
     695                $amount = 0;
     696            } 
    691697        }
    692698        if((float)$amount === 0){
     
    819825        $this->writeLog( '----- genCheckoutIdOrder [failed in Create Checkout ID] -----', null, 'debug' );
    820826        wp_send_json_error();
     827    }
     828   
     829    /*
     830     * This function is instantiated when checkout page loads or payment fragment refreshes
     831     */
     832    public function getCheckoutIdOrder(){
     833        $this->writeLog( '----- getCheckoutIdOrder [initiating Create Checkout ID] -----', null, 'debug' );
     834        $responseData = $this->createCheckoutArray();
     835        $checkoutid   = null;
     836        if($responseData){
     837            if(isset($responseData->id)){
     838                if(isset($responseData->result->code)){
     839                    if(in_array($responseData->result->code,['000.200.000','000.200.100','000.200.101'])){
     840                        $this->writeLog( '----- getCheckoutIdOrder [success in Create Checkout ID -> '.$responseData->id.'] -----', null, 'debug' );
     841                        $checkoutid = $responseData->id;
     842                       
     843                    }
     844                }
     845            }
     846        }
     847        $this->writeLog( '----- genCheckoutIdOrder [failed in Create Checkout ID] -----', null, 'debug' );
     848
     849        if(isset(WC()->session)){
     850            WC()->session->set( 'tp_payment_checkout_id', $checkoutid );
     851        }
     852        return $checkoutid;
    821853    }
    822854   
     
    10531085            return $validation;
    10541086        }
    1055         $parseUrl = parse_url($postArr['wp_http_referer']);
     1087        $parseUrl = wp_parse_url($postArr['wp_http_referer']);
    10561088        if(!isset($parseUrl['query'])){
    10571089            $validation['errors'][] = 'no query args';
     
    12201252                        $url = $responseResult['redirect'];
    12211253                    }
     1254                }elseif( isset( $responseResult['error'] ) ){
     1255                    $url = add_query_arg( 'tp_error', 'Payment not completed: ' . $responseResult['error'], $url );
    12221256                }
    12231257               
     
    16121646                        if( WC_SUBSCRIPTIONS_IS_ACTIVE && wcs_is_subscription( $order_id ) && isset($responseData->registrationId)){
    16131647                            $parent_id          = $order->get_parent_id();
    1614                             update_post_meta( $parent_id, '_registration_id', $responseData->registrationId );
     1648                            $parent_order       = wc_get_order( $parent_id );
     1649                            $parent_order->update_meta_data( '_registration_id', $responseData->registrationId );
     1650                            $parent_order->save();
     1651
    16151652                            $order->update_meta_data( '_registration_id', $responseData->registrationId );
    16161653                        }
     
    18021839    public function orderStatusHandler($status,$order){
    18031840        $array=[
    1804             'pending'    => ['result'=>'success', 'redirect' => false, 'refresh' => false, 'reload' => false, 'pending'=>true, 'process' => ["order"=>true]],
     1841            'pending'    => ['result'=>'success', 'redirect' => false, 'refresh' => false, 'reload' => false, 'pending'=>true, 'processpayment' => true, 'process' => ["order"=>true]],
    18051842            //'processing' => ['result'=>'success', 'redirect' => $this->get_return_url( $order ), 'refresh' => false, 'reload' => false],
    18061843            //'on-hold'    => ['result'=>'success', 'redirect' => $this->get_return_url( $order ), 'refresh' => false, 'reload' => false],
     
    18271864            $isFromOrderPayPage  = true;
    18281865        }
     1866
    18291867        if($order===false){
    18301868            $this->writeLog('-----------process_payment [Order does not exists]-----------', null, 'debug');
    1831             wc_add_notice('There was a problem creating your order, please try again.', 'error');
     1869            throw new \Exception('There was a problem creating your order, please try again.');
    18321870            return;
    18331871        }
     
    18471885        }
    18481886        $handler = $this->orderStatusHandler($order_data['status'],$order);
     1887        $handler['order_id'] = $order_id;
    18491888        //reject the failed, cancelled on-hold & success
    18501889        if( $isFromOrderPayPage && !isset($handler['pending'])){
     
    18811920            }
    18821921        }
    1883         $handler['fullPost'] = $_POST;
     1922
    18841923        $updateCheckout = false;
    18851924        $checkoutId = false;
     
    18921931            }
    18931932        }
     1933        $checkoutId            = $checkoutId !== false ? $checkoutId : WC()->session->get( 'tp_payment_checkout_id', false );
     1934        $handler['checkoutid'] = $checkoutId !== false ? $checkoutId : WC()->session->get( 'tp_payment_checkout_id', false );
    18941935        if($checkoutId === false){
    18951936            $this->writeLog('-----------process_payment [checkout id missing and create new checkout id] -----------', null,'debug');
    18961937            $checkoutId = $this->createCheckoutArray(false,false,$registrationId);
    18971938        }
     1939       
     1940        $handler['checkoutid2'] = $checkoutId;
    18981941        if($checkoutId !== false){
    18991942            $checkoutCode = '000.200.100';
     
    19241967       
    19251968        $this->writeLog('-----------process_payment [after payload is prepared]----------', $payload,'debug');
    1926        
    1927         if($this->jsLogging === true){
    1928             $handler['payload'] = $payload;
    1929         }
    1930        
     1969               
    19311970        $responseUpdate = $this->updateTransactionData($handler['platformbase'],$checkoutId,$payload);
    19321971       
    1933         if($this->jsLogging === true){
    1934             $handler['responseUpdate'] = $responseUpdate;
    1935         }
    19361972        $this->writeLog('----------process_payment [after transaction data updated]--------', $responseUpdate,'debug');
    19371973        if(isset($responseUpdate->result->code)){
     
    24342470            return;
    24352471        }
     2472        if( TP_CONSTANTS::DISABLE_CHECKOUT_INIT_PAYMENT_CHECK === true ){
     2473            return;
     2474        }
    24362475        $headers                 = ['Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8','Authorization' => 'Bearer '.$this->getAccessToken()];
    24372476        $arg                     = [
  • totalprocessing-card-payments/trunk/includes/payment-gateway-faqs-array.php

    r2693527 r3105176  
    22use TotalProcessing\WC_TotalProcessing_Constants AS TP_CONSTANTS;
    33return [
     4    [
     5        'question' => "Raising and Issue with our support team.",
     6        'answer'   => [
     7            [
     8                'question' => "What should I do if the plugin doesn't work properly with my WooCommerce site?",
     9                'answer'   => "<p>Our plugin is designed to be compatible with a wide variety of sites right upon installation. However, due to the complex nature of WooCommerce integrations, conflicts may arise due to other plugins or unique site configurations. If you encounter any issues, please contact our support team for assistance.</p>",
     10            ],
     11            [
     12                'question' => "How do you handle troubleshooting for these issues?",
     13                'answer'   => "<p>In most cases, we will request access to a staging site—an exact copy of your production site—to safely investigate and address the issue. This approach protects your live site from any potential disruptions that might affect your visitors during troubleshooting.</p>",
     14            ],
     15            [
     16                'question' => "What if I cannot provide access to a staging site?",
     17                'answer'   => "<p>If providing a staging site isn’t feasible, we will still assist you to the best of our abilities. However, please be aware that without access to a staging site, our ability to thoroughly investigate and resolve the issue may be significantly limited.</p>",
     18            ],
     19        ],
     20    ],
    421    [
    522        'question' => "Can caching affect the gateway processing?",
  • totalprocessing-card-payments/trunk/includes/tp-payment-gateway-helper-trait.php

    r2908434 r3105176  
    11<?php
    22use TotalProcessing\WC_TotalProcessing_Constants AS TP_CONSTANTS;
     3use Automattic\WooCommerce\Utilities\OrderUtil;
    34
    45trait TotalProcessingGatewayHelperTrait{
     
    112113    public function getClientOrdersCountForLast6Months( $userId ) {
    113114        global $wpdb;
    114         $sql        = "SELECT COUNT(1) FROM {$wpdb->prefix}posts p
    115                        INNER JOIN {$wpdb->prefix}postmeta pm
    116                            ON p.ID=pm.post_id
    117                        WHERE post_status IN ('wc-processing', 'wc-completed') 
    118                            AND p.post_date > date_sub(now(),Interval 6 month)
    119                            AND (meta_key = '_customer_user' AND meta_value=".(int)$userId.")";
     115
     116        //Check if HPOS usage is enabled.
     117        if ( OrderUtil::custom_orders_table_usage_is_enabled() ) {
     118            $sql        = "SELECT COUNT(1) FROM {$wpdb->prefix}wc_orders p
     119            INNER JOIN {$wpdb->prefix}wc_orders_meta pm
     120                ON p.id=pm.order_id
     121            WHERE status IN ('wc-processing', 'wc-completed') 
     122                AND p.date_created_gmt > date_sub(UTC_TIMESTAMP(),Interval 6 month)
     123                AND (meta_key = '_customer_user' AND meta_value=".(int)$userId.")";
     124        } else {
     125            $sql        = "SELECT COUNT(1) FROM {$wpdb->prefix}posts p
     126            INNER JOIN {$wpdb->prefix}postmeta pm
     127                ON p.ID=pm.post_id
     128            WHERE post_status IN ('wc-processing', 'wc-completed') 
     129                AND p.post_date > date_sub(now(),Interval 6 month)
     130                AND (meta_key = '_customer_user' AND meta_value=".(int)$userId.")";
     131        }
     132
    120133        $orderCount = $wpdb->get_var( $sql );
    121134        return $orderCount;
     
    346359        }
    347360
     361        $cartHash = "";
     362        if(!empty( $uuid )){
     363            $cartHash = $uuid;
     364        }else if(isset(WC()->cart)){
     365            $cartHash = WC()->cart->get_cart_hash();
     366        }
     367
     368        if(empty($cartHash)){
     369            $cartHash = time();
     370        }
     371
    348372        $logger                   = wc_get_logger();
    349373        $GLOBALS['logcounter']    = isset( $GLOBALS['logcounter'] ) ? $GLOBALS['logcounter'] + 1 : 1;
    350374
    351375        $context    = array( 'source' => TP_CONSTANTS::GATEWAY_ID );
    352         $cartHash   = !empty( $uuid ) ? $uuid : WC()->cart->get_cart_hash();
    353376        $logMessage = '['.$cartHash.'] Stack #' . $GLOBALS['logcounter'] . " : " . $label . ( $obj != null ? "\n" . wc_print_r( $obj, true ) : '' );
    354377
     
    697720                                <td colspan="7">
    698721                                    <div id="log-viewer">
    699                                         <pre>'.esc_html( file_get_contents( WC_LOG_DIR . $firstFileHandle ) ).'</pre>
     722                                        <pre>'.esc_html( @file_get_contents( WC_LOG_DIR . $firstFileHandle ) ).'</pre>
    700723                                    </div>
    701724                                </td>
     
    936959        }
    937960    }
     961
     962    public function is_checkout_block() {
     963        return WC_Blocks_Utils::has_block_in_page( wc_get_page_id('checkout'), 'woocommerce/checkout' );
     964    }
     965
     966    public function show_tp_errors(){
     967        if( isset( $_REQUEST['tp_error'] ) && !empty( $_REQUEST['tp_error'] ) ):
     968        ?>
     969        <ul class="woocommerce-error">
     970            <li><?php echo wp_kses_post( $_REQUEST['tp_error'] ); ?></li>
     971        </ul>
     972        <?php
     973        endif;
     974    }
    938975}
  • totalprocessing-card-payments/trunk/includes/tp-payment-gateway-subscriptions-trait.php

    r3022827 r3105176  
    77        $subsOrder                = wc_get_order( $subsOrderID );
    88        $subsParentOrderID        = $subsOrder->get_parent_id();
    9         $subsParentOrderRegID     = get_post_meta( $subsParentOrderID, '_registration_id', true );
     9        $subsParentOrder          = wc_get_order( $subsParentOrderID );
     10        $subsParentOrderRegID     = $subsParentOrder->get_meta('_registration_id');
    1011        if ( 0 == $amount ) {
    1112            $order->payment_complete();
     
    2930        $RegID                    = $subscription->get_registration_id();
    3031        $subsParentOrderID        = $subscription->get_parent_id();
    31         update_post_meta( $subsParentOrderID, '_registration_id', $RegID );
     32        $subsParentOrder          = wc_get_order($subsParentOrderID);
     33        $subsParentOrder->update_meta_data('_registration_id', $RegID );
     34        $subsParentOrder->save();
     35
    3236        $this->writeLog( '----- fn_change_subscription_payment_method [change payment method change process]-----', [$subsOrderID, $RegID, $subsParentOrderID], 'debug', 12344 );
    3337    }
  • totalprocessing-card-payments/trunk/readme.txt

    r3036898 r3105176  
    33Tags: ecommerce, Total processing, e-commerce, commerce, wordpress checkout, woocommerce gateway, payments, payment gateway, woocommerce, credit card, Total and Processing, Total, Processing
    44Requires at least: 5.2.0
    5 Tested up to: 6.3.1
    6 Stable tag: 6.0.3
     5Tested up to: 9
     6Stable tag: 7.0.0
    77Requires PHP: 7.4
    88License: GPLv3
     
    4747
    4848== Changelog ==
     49
     50= 7.0.0 - 20-06-2024 19:48 =
     51
     52* Added compatibility support for the latest WooCommerce version.
     53* Included detailed instructions for raising issues in the FAQs section.
     54* Improved design compatibility with WooCommerce block features.
     55* Implemented compatibility fixes for HPOS.
     56* Enhanced the log system to save logs when an iframe loads.
     57* Improved error handling during final transaction validation.
     58* Fixed a query hook that was causing issues.
     59* Updated the FAQs section to display sub-items without affecting the main items.
     60* Added styling to display a loader in WooCommerce block features.
    4961
    5062= 6.0.3 - 16-02-2024 19:48 =
  • totalprocessing-card-payments/trunk/templates/pci-frame-templatev3.php

    r3036898 r3105176  
    9090    var resourcePathVal    = "<?php echo $_GET['resourcePath']; ?>";
    9191    var order_id_val       = "<?php echo ($_GET['order_id'] ?? 0); ?>";
    92     var generalAlertMsg    = 'Uncertain Response. Please report this to the merchant before reattempting payment. They will need to verify if this transaction is successful.';
     92    var generalAlertMsg    = 'Error #if100: Uncertain Response. Please report this to the merchant before reattempting payment. They will need to verify if this transaction is successful.';
    9393    Promise.resolve(
    9494        $.ajax({
     
    104104                    } else {
    105105                        alert( "Error(#1):" + generalAlertMsg + "\n" + 'resource:' + resourcePathVal );
     106                        postMessageToParent({funcs:[{"name":"do_log_errors","args":[generalAlertMsg, order_id_val]}]});
    106107                        $('body').trigger("update_checkout");
    107108                        $('#tpCardsBtnReplace').remove();
     
    110111                } else {
    111112                    alert( "Error(#2):" + generalAlertMsg + "\n" + 'resource:' + resourcePathVal );
     113                    postMessageToParent({funcs:[{"name":"do_log_errors","args":[generalAlertMsg, order_id_val]}]});
    112114                    $('body').trigger("update_checkout");
    113115                    $('#tpCardsBtnReplace').remove();
     
    116118            },
    117119            error: function(jqXHR, textStatus, errorThrown){
    118                 alert( "Error(#3):" + generalAlertMsg + "\n" + 'Message::' + textStatus + '->' + errorThrown + "\n" + 'resource:' + resourcePathVal ); 
     120                alert( "Error(#3):" + generalAlertMsg + "\n" + 'Message::' + textStatus + '->' + errorThrown + "\n" + 'resource:' + resourcePathVal );
     121                postMessageToParent({funcs:[{"name":"do_log_errors","args":[generalAlertMsg, order_id_val]}]});
    119122                console.log(jqXHR);
    120123                console.log(textStatus);
     
    222225    }
    223226    </style>
    224     <style id="tprootcss" type="text/css">:root {--main-primary-color: #2372ce;--main-accent-color: #7f54b3; --wpwl-control-background: transparent!important;; --wpwl-control-border-radius: 0px!important;--wpwl-control-margin-right:4%;--wpwl-switch-buttons-background:#d8d8d8!important;--wpwl-switch-buttons-text-color:#000000!important;}</style>
     227    <style id="tprootcss" type="text/css">:root {--main-primary-color: #2372ce;--main-accent-color: #7f54b3; --wpwl-control-background: transparent!important; --wpwl-control-border-radius: 0px!important; --wpwl-control-margin-right:4%;--wpwl-switch-buttons-background:#d8d8d8!important;--wpwl-switch-buttons-text-color:#000000!important;}</style>
    225228    <style type="text/css">
    226229    html, body, fieldset {margin:0!important; padding:0!important; background: var(--main-primary-color); font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; color: var(--main-accent-color);}
     
    607610function executePayment(argArray){
    608611    console.log('exec now->');
    609     console.log(paymentContainer);
     612    console.log(jQuery('input[name="card.holder"].wpwl-control-cardHolder').val());
     613    jQuery('input[name="card.holder"].wpwl-control-cardHolder').val('');
     614    console.log(jQuery('input[name="card.holder"].wpwl-control-cardHolder').val());
    610615    wpwl.executePayment(paymentContainer);
    611616}
  • totalprocessing-card-payments/trunk/totalprocessing-card-payments-and-gateway-woocommerce.php

    r3036898 r3105176  
    1010 * Plugin URI:           https://www.totalprocessing.com/woocommerce/cards
    1111 * Description:          Accept all major credit and debit cards. Fast, seamless, and flexible.
    12  * Version:              6.0.3
     12 * Version:              7.0.0
    1313 * Author:               Total Processing Limited
    1414 * Copyright:            2022 Total Processing Limited.
     
    1818 * Text Domain:          totalprocessing-card-payments-and-gateway-woocommerce
    1919 * Domain Path:          /languages
    20  * WC tested up to:      6.1.1
     20 * WC tested up to:      9
    2121 * WC requires at least: 5.6
    2222 */
     
    2727}
    2828
     29define( 'TOTALPROCESSING_PAYMENTGATEWAY_PLUGIN_BASEPATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
    2930define( 'TOTALPROCESSING_PAYMENTGATEWAY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
    3031define( 'TOTALPROCESSING_PAYMENTGATEWAY_PLUGIN_BASEURL', plugin_dir_url( __FILE__ ) );
     
    9091}
    9192
     93// Registers WooCommerce Blocks integration.
     94add_action( 'woocommerce_blocks_loaded', 'totalprocessing_card_payments_and_gateway_woocommerce_block_support' );
     95function totalprocessing_card_payments_and_gateway_woocommerce_block_support() {
     96    if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
     97        require_once 'blocks/class-wc-tp-cards-payments-blocks.php';
     98        add_action(
     99            'woocommerce_blocks_payment_method_type_registration',
     100            function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) {
     101                $payment_method_registry->register( new Totalprocessing_Card_Payments_And_Gateway_Blocks_Support() );
     102            }
     103        );
     104    }
     105}
     106
     107/**
     108 * Declaring HPOS compatibility
     109 */
     110add_action( 'before_woocommerce_init', function() {
     111    if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
     112        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
     113    }
     114} );
     115
    92116/**
    93117 * Check if WooCommerce is activated
Note: See TracChangeset for help on using the changeset viewer.