Plugin Directory

Changeset 2217376


Ignore:
Timestamp:
12/24/2019 07:30:36 AM (6 years ago)
Author:
wp_estatic
Message:

Update segpay version

Location:
woo-sagepay-addon/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • woo-sagepay-addon/trunk/README.txt

    r2216770 r2217376  
    111111= 1.0.5 =
    112112* Fix - Made funcation changes.
     113= 2.0.0 =
     114* Fix - Update segapay kit.
     115
    113116== Upgrade Notice ==
  • woo-sagepay-addon/trunk/woo-sagepay-addon.php

    r2216770 r2217376  
    55 * Plugin URL:          Addon for sagepay and WooCommerce
    66 * Description:         Addon for sagepay and WooCommerce allows you to accept payments on your Woocommerce store. It accpets credit card payments and processes them securely with your merchant account.
    7  * Version:             1.0.5
     7 * Version:             2.0.0
    88 * WC requires at least:2.3
    99 * WC tested up to:     3.8.1
     
    2525    deactivate_plugins(plugin_basename(__FILE__));
    2626    add_action('load-plugins.php', function () {
    27         add_filter('gettext', 'wsap_change_text', 99, 3);
     27        add_filter('gettext', 'wsa_change_text', 99, 3);
    2828    });
    2929
    30     function wsap_change_text($translated_text, $untranslated_text, $domain)
     30    function wsa_change_text($translated_text, $untranslated_text, $domain)
    3131    {
     32        echo '111';
     33        echo '<pre>';
     34        print_r($_REQUEST);die;
    3235        $old = array(
    3336            "Plugin <strong>activated</strong>.",
     
    4144            remove_filter(current_filter(), __FUNCTION__, 99);
    4245        }
    43 
    4446        return $translated_text;
    4547    }
     
    4850}
    4951
    50 add_action('plugins_loaded', 'wsap_init_woocommerce_sagepay', 0);
    51 
    52 function wsap_init_woocommerce_sagepay()
     52add_action('plugins_loaded', 'wsa_init_woocommerce_sagepay_4', 0);
     53
     54function wsa_init_woocommerce_sagepay_4()
    5355{
    5456
     
    5961    load_plugin_textdomain('woocommerce', false, dirname(plugin_basename(__FILE__)) . '/lang');
    6062
    61     function wsap_add_sagepay_gateway($methods)
     63    function psdv2_add_sagepay_gateway($methods)
    6264    {
    63 
    64         $methods[] = 'woocommerce_sagepay';
     65        $methods[] = 'woocommerce_sagepay_psdv2';
     66
    6567        return $methods;
    6668    }
    6769
    68     add_filter('woocommerce_payment_gateways', 'wsap_add_sagepay_gateway');
    69 
    70     class woocommerce_sagepay extends WC_Payment_Gateway_CC
     70    add_filter('woocommerce_payment_gateways', 'psdv2_add_sagepay_gateway');
     71
     72    class woocommerce_sagepay_psdv2 extends WC_Payment_Gateway_CC
    7173    {
    7274
     
    7577            global $woocommerce;
    7678
    77             $this->id = 'sagepay';
    78             $this->method_title = __('Sagepay', 'woocommerce');
     79            $this->id = 'sagepay_psdv2';
     80            $this->method_title = __('Sagepay psdv2', 'woocommerce');
    7981            $this->icon = apply_filters('woocommerce_sagepay_icon', '');
    8082            $this->has_fields = true;
    81             $this->notify_url = add_query_arg('wc-api', 'woocommerce_sagepay', home_url('/'));
     83            $this->notify_url = add_query_arg('wc-api', 'woocommerce_sagepay_psdv2', home_url('/'));
    8284
    8385            $this->init_form_fields();
     
    9193            $this->mode = $this->get_option('mode');
    9294            $this->transtype = $this->get_option('transtype');
     95
    9396            $this->send_shipping = $this->get_option('send_shipping');
    9497            $this->sagepay_cardtypes = $this->get_option('sagepay_cardtypes');
     
    9699            $this->sagepay_zerocurrency = array("BIF", "CLP", "DJF", "GNF", "JPY", "KMF", "KRW", "MGA", "PYG", "RWF", "VND", "VUV", "XAF", "XOF", "XPF", "GBP");
    97100
    98             add_action('init', array($this, 'wsap_auth_success'));
    99             add_action('woocommerce_api_woocommerce_sagepay', array($this, 'wsap_auth_success'));
     101            add_action('init', array($this, 'wsa_auth_success'));
     102
     103            add_action('woocommerce_api_woocommerce_' . $this->id, array($this, 'wsa_auth_success'));
     104
    100105            add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
    101             add_action('woocommerce_order_status_processing_to_cancelled', array($this, 'wsap_restore_order_stock'), 10, 1);
    102             add_action('woocommerce_order_status_completed_to_cancelled', array($this, 'wsap_restore_order_stock'), 10, 1);
    103             add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'wsap_restore_order_stock'), 10, 1);
    104             add_action('woocommerce_order_status_processing_to_refunded', array($this, 'wsap_restore_order_stock'), 10, 1);
    105            
    106             add_action('woocommerce_receipt_sagepay', array($this, 'receipt_page'));
    107             add_action('woocommerce_order_status_completed_to_refunded', array($this, 'wsap_restore_order_stock'), 10, 1);
    108             add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'wsap_restore_order_stock'), 10, 1);
     106
     107            add_action('woocommerce_order_status_processing_to_cancelled', array($this, 'wsa_restore_order_stock'), 10, 1);
     108
     109            add_action('woocommerce_order_status_completed_to_cancelled', array($this, 'wsa_restore_order_stock'), 10, 1);
     110
     111            add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'wsa_restore_order_stock'), 10, 1);
     112
     113            add_action('woocommerce_order_status_processing_to_refunded', array($this, 'wsa_restore_order_stock'), 10, 1);
     114
     115            add_action('woocommerce_receipt_' . $this->id, array($this, 'receipt_page'));
     116
     117            add_action('woocommerce_order_status_completed_to_refunded', array($this, 'wsa_restore_order_stock'), 10, 1);
     118
     119            add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'wsa_restore_order_stock'), 10, 1);
     120
    109121            add_filter('woocommerce_credit_card_form_fields', array($this, 'sagepay_card_type'), 10, 2);
     122
    110123        }
    111124
     
    170183            if ('yes' == get_option('woocommerce_sagepay_ssl_checkout')) {
    171184                $url = str_replace('http:', 'https:', $url);
     185                echo $url;die;
    172186            }
    173187            return $url;
     
    264278            global $woocommerce;
    265279
    266             if (empty(sanitize_text_field($_POST['sagepay-card-name']))) {
     280            if (empty(sanitize_text_field($_POST['sagepay_psdv2-card-name']))) {
    267281                wc_add_notice('<strong>Card Name</strong> ' . __('is required.', 'woocommerce'), 'error');
    268282            }
    269283
    270             if (!$this->wsap_if_credit_card_is_empty(sanitize_text_field($_POST['sagepay-card-number']))) {
     284            if (!$this->wsa_if_credit_card_is_empty(sanitize_text_field($_POST['sagepay_psdv2-card-number']))) {
    271285                wc_add_notice('<strong>Credit Card Number</strong> ' . __('is required.', 'woocommerce'), 'error');
    272             } elseif (!$this->wsap_is_valid_credit_card(sanitize_text_field($_POST['sagepay-card-number']))) {
     286            } elseif (!$this->wsa_is_valid_credit_card(sanitize_text_field($_POST['sagepay_psdv2-card-number']))) {
    273287                wc_add_notice('<strong>Credit Card Number</strong> ' . __('is not a valid credit card number.', 'woocommerce'), 'error');
    274288            }
    275289
    276             if (!$this->wsap_if_expire_date_is_empty(sanitize_text_field($_POST['sagepay-card-expiry']))) {
     290            if (!$this->wsa_if_expire_date_is_empty(sanitize_text_field($_POST['sagepay_psdv2-card-expiry']))) {
    277291                wc_add_notice('<strong>Card Expiry Date</strong> ' . __('is required.', 'woocommerce'), 'error');
    278             } elseif (!$this->wsap_is_valid_expire_date(sanitize_text_field($_POST['sagepay-card-expiry']))) {
     292            } elseif (!$this->wsa_is_valid_expire_date(sanitize_text_field($_POST['sagepay_psdv2-card-expiry']))) {
    279293                wc_add_notice('<strong>Card Expiry Date</strong> ' . __('is not a valid expiry date.', 'woocommerce'), 'error');
    280294            }
    281295
    282             if (!$this->wsap_if_cvv_number_is_empty(sanitize_text_field($_POST['sagepay-card-cvc']))) {
     296            if (!$this->wsa_if_cvv_number_is_empty(sanitize_text_field($_POST['sagepay_psdv2-card-cvc']))) {
    283297                wc_add_notice('<strong>CVV Number</strong> ' . __('is required.', 'woocommerce'), 'error');
    284298            }
    285299        }
    286300
    287         private function wsap_if_credit_card_is_empty($credit_card)
     301        private function wsa_if_credit_card_is_empty($credit_card)
    288302        {
    289303            if (empty($credit_card)) {
     
    298312        }
    299313
    300         private function wsap_if_expire_date_is_empty($expiry_date)
     314        private function wsa_if_expire_date_is_empty($expiry_date)
    301315        {
    302316            $expiry_date = str_replace(' / ', '', $expiry_date);
     
    308322        }
    309323
    310         private function wsap_if_cvv_number_is_empty($ccv_number)
     324        private function wsa_if_cvv_number_is_empty($ccv_number)
    311325        {
    312326            $length = strlen($ccv_number);
    313327            return is_numeric($ccv_number) and $length > 2 and $length < 5;
    314         }
    315 
    316         private function wsap_is_valid_expire_date($expiry_date)
    317         {
    318 
    319             $month = $year = '';
    320             $month = substr($expiry_date, 0, 2);
    321             $year = substr($expiry_date, 5, 7);
    322             $year = '20' . $year;
    323 
    324             if ($month > 12) {
    325                 return false;
    326             }
    327 
    328             if (date("Y-m-d", strtotime($year . "-" . $month . "-01")) > date("Y-m-d")) {
    329                 return true;
    330             }
    331 
    332             return false;
    333         }
    334 
    335         private function wsap_is_valid_credit_card($credit_card)
    336         {
    337             $credit_card = preg_replace('/(?<=\d)\s+(?=\d)/', '', trim($credit_card));
    338             $number = preg_replace('/[^0-9]+/', '', $credit_card);
    339             $strlen = strlen($number);
    340             $sum = 0;
    341             if ($strlen < 13) {
    342                 return false;
    343             }
    344             for ($i = 0; $i < $strlen; $i++) {
    345                 $digit = substr($number, $strlen - $i - 1, 1);
    346 
    347                 if ($i % 2 == 1) {
    348 
    349                     $sub_total = $digit * 2;
    350 
    351                     if ($sub_total > 9) {
    352                         $sub_total = 1 + ($sub_total - 10);
    353                     }
    354                 } else {
    355                     $sub_total = $digit;
    356                 }
    357                 $sum += $sub_total;
    358             }
    359 
    360             if ($sum > 0 and $sum % 10 == 0) {
    361                 return true;
    362             }
    363 
    364             return false;
    365328        }
    366329
     
    408371                    'TermUrl' => $this->notify_url,
    409372                );
     373            } else if (!empty(WC()->session->get('set_creq'))) {
     374                $VPSTxId = WC()->session->get('set_vpstxid');
     375                $VPSTxId = str_replace('{', '', $VPSTxId);
     376                $VPSTxId = str_replace('}', '', $VPSTxId);
     377                $sagepay_args = array(
     378                    'creq' => WC()->session->get('set_creq'),
     379                    'threeDSSessionData' => $VPSTxId,
     380                );
    410381            }
    411382            $sagepay_args_array = array();
     
    414385                $sagepay_args_array[] = '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '" />';
    415386            }
    416            
     387
    417388            wc_enqueue_js('
    418                 jQuery("body").block({
    419           message: "<img src=\"' . esc_url($woocommerce->plugin_url()) . '/assets/images/select2-spinner.gif\" alt=\"Redirecting...\" style=\"float:left; margin-right: 10px;\" />' . __('Thank you for your order. We are now redirecting you to verify your card.', 'woocommerce') . '",
    420                     overlayCSS:
    421           {
    422             background: "#fff",
    423                         opacity: 0.6
    424           },
    425 
    426         });
     389            /* jQuery("body").block({
     390                message: "<img src=\"' . esc_url($woocommerce->plugin_url()) . '/images/ajax-loader.gif\" alt=\"Redirecting...\" style=\"float:left; margin-right: 10px;\" />' . __('Thank you for your order. We are now redirecting you to verify your card.', 'woocommerce') . '",
     391                          overlayCSS:
     392                {
     393                  background: "#fff",
     394                              opacity: 0.6
     395                },
     396
     397              }); */
    427398        jQuery("#submit_sagepay_payment_form").click();
    428399      ');
    429        
    430             return '<form action="' . esc_url(WC()->session->get('set_acsurl')) . '" method="post" id="sagepay_payment_form">
    431       ' . implode('', $sagepay_args_array) . '
    432       <input type="submit" class="button-alt" id="submit_sagepay_payment_form" value="' . __('Submit', 'woocommerce') . '" /> <a class="button cancel" href="' . esc_url($order->get_cancel_order_url()) . '">' . __('Cancel order &amp; restore cart', 'woocommerce') . '</a>
    433       </form>';
    434 
     400            echo '<form style="display:none" action="' . esc_url(WC()->session->get('set_acsurl')) . '" target="3Diframe" method="post" id="sagepay_payment_form">
     401            ' . implode('', $sagepay_args_array) . '
     402            <input type="submit" class="button-alt" id="submit_sagepay_payment_form" value="' . __('Submit', 'woocommerce') . '" />
     403            <a class="button cancel" href="' . esc_url($order->get_cancel_order_url()) . '">' . __('Cancel order &amp; restore cart', 'woocommerce') . '</a>
     404            </form>';
     405            return '<iframe width="800" margin-top="30px" height="300" name="3Diframe" ></iframe>';
    435406        }
    436407
     
    438409        {
    439410            global $woocommerce;
    440            
     411
    441412            $order = new WC_Order($order_id);
    442413
    443             $credit_card = preg_replace('/(?<=\d)\s+(?=\d)/', '', trim(sanitize_text_field($_POST['sagepay-card-number'])));
    444 
    445             $expiry_date = sanitize_text_field($_POST['sagepay-card-expiry']);
     414            $credit_card = preg_replace('/(?<=\d)\s+(?=\d)/', '', trim(sanitize_text_field($_POST['sagepay_psdv2-card-number'])));
     415
     416            $expiry_date = sanitize_text_field($_POST['sagepay_psdv2-card-expiry']);
    446417            $month = substr($expiry_date, 0, 2);
    447418            $year = substr($expiry_date, 5, 7);
     
    467438            $product_item['BillingPhone'] = $order->billing_phone;
    468439
    469             if ($this->wsap_if_meta_product() == true || $this->send_shipping == 'yes') {
     440            if ($this->wsa_if_meta_product() == true || $this->send_shipping == 'yes') {
    470441                $product_item['DeliverySurname'] = $order->billing_last_name;
    471442                $product_item['DeliveryFirstnames'] = $order->billing_first_name;
     
    510481                $product_item['CustomerEMail'] = $order->billing_email;
    511482            }
    512             $product_item['VPSProtocol'] = "3.00";
     483            $product_item['VPSProtocol'] = "4.00";
    513484            $product_item['TxType'] = $this->transtype;
    514485            $product_item['Vendor'] = $this->vendor_name;
     
    518489            $product_item['Description'] = sprintf(__('Order #%s', 'woocommerce'), ltrim($order->get_order_number(), '#'));
    519490            $product_item['DeliveryPhone'] = $order->billing_phone;
    520             $product_item['CardHolder'] = sanitize_text_field($_POST['sagepay-card-name']);
     491            // $product_item['CardHolder'] = sanitize_text_field($_POST['sagepay_psdv2-card-name']);
     492            $product_item['CardHolder'] = 'CHALLENGE';
    521493            $product_item['CardNumber'] = $credit_card;
    522494            $product_item['StartDate'] = '';
    523495            $product_item['ExpiryDate'] = $month . $year;
    524             $product_item['CV2'] = sanitize_text_field($_POST['sagepay-card-cvc']);
    525             $product_item['CardType'] = sanitize_text_field($_POST['sagepay-card-type']);
     496            $product_item['CV2'] = sanitize_text_field($_POST['sagepay_psdv2-card-cvc']);
     497            $product_item['CardType'] = sanitize_text_field($_POST['sagepay_psdv2-card-type']);
    526498            $product_item['CustomerEMail'] = $order->billing_email;
    527499            $product_item['clientipaddress'] = $this->get_the_user_ip();
    528500            $product_item['product_categories'] = $this->get_categories;
    529501            $product_item['customer_email'] = $order->billing_email;
     502            // $product_item['VPSTxID'] = //   $product_item['CreateToken'] = 1;
     503            $product_item['ThreeDSNotificationURL'] = $this->notify_url;
     504            $product_item['BrowserAcceptHeader'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3';
     505            $product_item['BrowserUserAgent'] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36';
     506
     507            $product_item['BrowserLanguage'] = 'en-GB';
     508            $product_item['BrowserJavascriptEnabled'] = true;
     509            $product_item['BrowserJavaEnabled'] = true;
     510            $product_item['BrowserColorDepth'] = 16;
     511            $product_item['BrowserScreenHeight'] = '300';
     512            $product_item['BrowserScreenWidth'] = '300';
     513            $product_item['BrowserTZ'] = '-3180';
     514            $product_item['ChallengeWindowSize'] = '05';
     515            $product_item['Apply3DSecure'] = 3;
    530516
    531517            $post_values = "";
     
    613599                        'redirect' => $redirect_url,
    614600                    );
     601
    615602                } else if ($responce_update['Status'] == "3DAUTH") {
    616603
    617604                    if ($responce_update['3DSecureStatus'] == 'OK') {
    618                         if (isset($responce_update['ACSURL']) && (isset($responce_update['PAReq']))) {
    619 
     605                        // if (isset($responce_update['ACSURL']) && (isset($responce_update['PAReq']))) {
     606                        if (isset($responce_update['ACSURL']) && (isset($responce_update['PAReq']) || isset($responce_update['CReq']))) {
    620607                            WC()->session->set('set_acsurl', $responce_update['ACSURL']);
    621608
     
    624611                            }
    625612
     613                            if (isset($responce_update['CReq']) && !empty($responce_update['CReq'])) {
     614                                WC()->session->set('set_pareq', "");
     615                                WC()->session->set('set_creq', $responce_update['CReq']);
     616                            }
     617
    626618                            WC()->session->set('set_md', $responce_update['MD']);
    627619
    628620                            $redirect = $order->get_checkout_payment_url(true);
     621
    629622                            return array(
    630623                                'result' => 'success',
     
    641634        static public function setStore($key, $value)
    642635        {
    643 
     636         
    644637            if (gettype($value) == "object") {
    645638                $_SESSION[$key] = serialize($value);
     
    651644        public function getSharedUrl($method, $env = '')
    652645        {
    653 
     646         
    654647            $env = $this->_validEnvironment($env);
    655648            if (isset($this->_sharedUrls[$env][$method])) {
     
    659652        }
    660653
    661         function wsap_update_logs($script_name, $msg, $file_name = 'logs.txt')
    662         {
    663 
     654        function wsa_update_logs($script_name, $msg, $file_name = 'logs.txt')
     655        {
     656         
    664657            $file = fopen($file_name, 'r+');
    665658            $message_old = fread($file, filesize($file_name));
     
    670663        }
    671664
    672         public function wsap_restore_order_stock($order_id)
    673         {
    674 
     665        public function wsa_restore_order_stock($order_id)
     666        {
     667           
    675668            $order = new WC_Order($order_id);
    676669
     
    740733        }
    741734
    742         public function thankyou_page()
    743         {
    744             if ($this->instructions) {
    745                 echo wpautop(wptexturize($this->instructions));
    746             }
    747         }
    748 
    749         public function wsap_auth_success()
     735        private function wsa_is_valid_credit_card($credit_card)
     736        {
     737            $credit_card = preg_replace('/(?<=\d)\s+(?=\d)/', '', trim($credit_card));
     738            $number = preg_replace('/[^0-9]+/', '', $credit_card);
     739            $strlen = strlen($number);
     740            $sum = 0;
     741            if ($strlen < 13) {
     742                return false;
     743            }
     744            for ($i = 0; $i < $strlen; $i++) {
     745                $digit = substr($number, $strlen - $i - 1, 1);
     746
     747                if ($i % 2 == 1) {
     748
     749                    $sub_total = $digit * 2;
     750
     751                    if ($sub_total > 9) {
     752                        $sub_total = 1 + ($sub_total - 10);
     753                    }
     754                } else {
     755                    $sub_total = $digit;
     756                }
     757                $sum += $sub_total;
     758            }
     759
     760            if ($sum > 0 and $sum % 10 == 0) {
     761                return true;
     762            }
     763
     764            return false;
     765        }
     766
     767        public function wsa_auth_success()
    750768        {
    751769            global $woocommerce;
    752770
    753             if (isset($_REQUEST['MD']) && isset($_REQUEST['PaRes'])) {
     771            if ((!empty(WC()->session->get('set_vpstxid')) || isset($_REQUEST['MD'])) && (isset($_REQUEST['PaRes']) || isset($_REQUEST['cres']))) {
    754772
    755773                $order = new WC_Order(WC()->session->get('sagepay_oid'));
    756 
    757                 $request_array = array(
    758                     'MD' => sanitize_text_field($_REQUEST['MD']),
    759                     'PaRes' => sanitize_text_field($_REQUEST['PaRes']),
     774                $VPSTxId = WC()->session->get('set_vpstxid');
     775                $VPSTxId = str_replace('{', '', $VPSTxId);
     776                $VPSTxId = str_replace('}', '', $VPSTxId);
     777
     778                $request_psdv1_array = array(
     779                    'MD' => sanitize_text_field(isset($_REQUEST['MD'])),
     780                    'PaRes' => sanitize_text_field(isset($_REQUEST['PaRes'])),
    760781                    'VendorTxCode' => WC()->session->get('sagepay_set'),
    761                     'VPSTxId' => WC()->session->get('set_vpstxid'),
     782                    'VPSTxId' => $VPSTxId,
    762783                );
    763 
    764                 $request = http_build_query($request_array);
     784                $request_psdv2_array = array(
     785                    'CRes' => sanitize_text_field($_REQUEST['cres']),
     786                    'VPSTxId' => sanitize_text_field($VPSTxId),
     787                );
     788
     789                $request = '';
     790                if (isset($_REQUEST['PaRes'])) {
     791                    $request = http_build_query($request_psdv1_array);
     792                } else {
     793                    $request = http_build_query($request_psdv2_array);
     794                }
    765795
    766796                if ($this->mode == 'test') {
     
    833863                    }
    834864
     865                    /* In the real world, the bank will either authorise the transaction (an OK response) or fail it (a
     866                    NOTATUHED response). The Sage Pay gateway prepares either an OK response
     867                    with an authorisation code, a NOTAUTHED response if the bank declined the transaction,  */
     868
    835869                    if ($responce_update['Status'] == "OK" || $responce_update['Status'] == "REGISTERED" || $responce_update['Status'] == "AUTHENTICATED") {
    836870
     
    839873                        $order->payment_complete();
    840874                        $redirect_url = $this->get_return_url($order);
    841 
    842                         wp_redirect($redirect_url);
     875                        ?>
     876                        <script type="text/javascript">
     877                            top.location = '<?=$redirect_url?>';
     878                        </script>
     879                        <?php
    843880                        exit();
    844881
    845882                    } else if ($responce_update['Status'] == "3DAUTH") {
    846883
    847                         if (isset($responce_update['ACSURL']) && (isset($responce_update['PAReq']))) {
     884                        // if (isset($responce_update['ACSURL']) && (isset($responce_update['PAReq']))) {
     885                        if (isset($responce_update['ACSURL']) && (isset($responce_update['PAReq']) || isset($responce_update['CReq']))) {
    848886                            WC()->session->set('set_acsurl', $responce_update['ACSURL']);
    849887
    850888                            if (isset($responce_update['PAReq']) && !empty($responce_update['PAReq'])) {
    851889                                WC()->session->set('set_pareq', $responce_update['PAReq']);
     890                            }
     891
     892                            if (isset($responce_update['CReq']) && !empty($responce_update['CReq'])) {
     893                                WC()->session->set('set_pareq', "");
     894                                WC()->session->set('set_creq', $responce_update['CReq']);
    852895                            }
    853896
     
    872915        }
    873916
    874         private function wsap_if_meta_product()
     917        private function wsa_is_valid_expire_date($expiry_date)
     918        {
     919
     920            $month = $year = '';
     921            $month = substr($expiry_date, 0, 2);
     922            $year = substr($expiry_date, 5, 7);
     923            $year = '20' . $year;
     924
     925            if ($month > 12) {
     926                return false;
     927            }
     928
     929            if (date("Y-m-d", strtotime($year . "-" . $month . "-01")) > date("Y-m-d")) {
     930                return true;
     931            }
     932
     933            return false;
     934        }
     935
     936        private function wsa_if_meta_product()
    875937        {
    876938            global $woocommerce;
     
    897959
    898960    }
    899 
    900961}
Note: See TracChangeset for help on using the changeset viewer.