Перенаправление оформления заказа Woocommerce не работает должным образом после нескольких попыток

#php #wordpress #woocommerce #plu&ins

#php #wordpress #woocommerce #Плагины

Вопрос:

Я разрабатываю плагин платежного шлюза WooCommerce с WordPress версии 5.4.2 и WooCommerce версии 3.8.0.

Плагин работает нормально в течение нескольких 3-4 попыток, но после этого я не могу перенаправиться на страницу оформления заказа. Он продолжает перенаправлять на страницу корзины.

Я также проверил журналы, но там ничего не найдено.

Я не профессионал в WordPress.

Плагин имеет живую демонстрацию

Вы можете увидеть код ниже

 // Submit payment and handle response
    public function process_payment($order_id) {
        &lobal $woocommerce;
        &lobal $current_user;
        //&et user details   
        $current_user   = wp_&et_current_user();

        $user_email     = $current_user-&&t;user_email;
        $first_name     = $current_user-&&t;shippin&_first_name;
        $last_name      = $current_user-&&t;shippin&_last_name;
        $phone_number   = $current_user-&&t;billin&_phone;
        $country        = $current_user-&&t;shippin&_country;
        $state          = $current_user-&&t;shippin&_state;
        $city           = $current_user-&&t;shippin&_city;
        $postcode       = $current_user-&&t;shippin&_postcode;
        $address_1      = $current_user-&&t;shippin&_address_1;
        $address_2      = $current_user-&&t;shippin&_address_2;
        $udf1           = $first_name." ".$last_name;
        $udf2           = $user_email;
        $udf3           = $phone_number;
        $udf4           = $country." ".$state." ".shippin&_city." ".$address_1." ".$address_2." ".$postcode;

        $user_email     = $_POST['billin&_email'];
        $first_name     = $_POST['billin&_first_name'];
        $last_name      = $_POST['billin&_last_name'];
        $phone_number   = $_POST['billin&_phone'];
        $country        = $_POST['billin&_country'];
        $state          = $_POST['billin&_state'];
        $city           = $_POST['billin&_city'];
        $postcode       = $_POST['billin&_postcode'];
        $address_1      = $_POST['billin&_address_1'];
        $address_2      = $_POST['billin&_address_2'];
        $udf1       = $first_name." ".$last_name;
        $udf2       = $user_email;
        $udf3       = $phone_number;
        $udf4       = $country." ".$state." ".shippin&_city." ".$address_1." ".$address_2." ".$postcode;

        $order          = new WC_Order( $order_id );
        $atom_lo&in_id  = $this-&&t;lo&in_id;
        $atom_password  = $this-&&t;password;
        $atom_prod_id   = $this-&&t;atom_product_id;
        $amount         = $order-&&t;&et_total();
        $currency       = "INR";
        $custacc        = "1234567890";
        $txnid          = $order_id;    
        $clientcode     = urlencode(base64_encode(007));
        $datenow        = date("d/m/Y h:m:s");
        $encodedDate    = str_replace(" ", " ", $datenow);
        
        if(!function_exists('wc_&et_checkout_url')){ 
            require_once '/includes/wc-core-functions.php'; 
        } 

        $ru = wc_&et_checkout_url(); 

        $data["lo&in"] = $atom_lo&in_id;
        $data["pass"] = $atom_password;
        $data["prodid"] = $atom_prod_id;
        $data['txnid']=$txnid;
        $data['amt'] = $amount;
        $data['reqHashCode'] = $this-&&t;req_hash_code;
        
        $data['requestEncypritonKey'] = $this-&&t;req_enc_key;
        $data['salt'] = $this-&&t;req_salt_key;
       
        $si&nature = $this-&&t;&etChecksum($data);

        $param = "lo&in=".$atom_lo&in_id."amp;pass=".$atom_password."amp;ttype=NBFundTransfer"."amp;prodid=".$atom_prod_id."amp;amt=".$amount."amp;txncurr=".$currency."amp;txnscamt=0"."amp;clientcode=".$clientcode."amp;txnid=".$txnid."amp;date=".$encodedDate ."amp;custacc=".$custacc."amp;udf1=".$udf1."amp;udf2=".$udf2."amp;udf3=".$udf3."amp;udf4=".$udf4."amp;ru=".$ru;
        $param = $param."amp;si&nature=".$si&nature;
     
        $atomenc = new AtomAES();
        $encData = $atomenc-&&t;encrypt($param, $data['requestEncypritonKey'], $data['salt']);

        &lobal $wpdb, $woocommerce;
        return array('result' =&&t; 'success', 'redirect' =&&t; $this-&&t;url."?" ."lo&in=".$atom_lo&in_id."amp;encdata=".strtoupper($encData));
        exit;
    }


// checkin& response from payment &ateway and show messa&es on checkout pa&e
function check_atom_response(){
        &lobal $woocommerce;
        &lobal $wpdb, $woocommerce;
     
        $atomenc = new AtomAES();
        $decrypted = $atomenc-&&t;decrypt($_POST['encdata'], $this-&&t;res_enc_key, $this-&&t;res_salt_key);
        $array_response = explode('amp;', $decrypted); //chan&e amp; to | for production
        
        $equalSplit = array();
        foreach ($array_response as $ar) {
            $equalSub = explode('=', $ar);
            if(!empty($equalSub[1]) amp;amp; !empty($equalSub[0])){
                $temp = array(
                    $equalSub[0] =&&t; $equalSub[1],
                );
                $equalSplit  = $temp;
            }
        }
     
        
        if(isset($equalSplit['f_code']) amp;amp; $this-&&t;validateResponse($equalSplit)){
            
            $order = new WC_Order($equalSplit['mer_txn']);
          
            $order_id = $equalSplit['mer_txn'];
            $VERIFIED       =   $equalSplit['f_code'];
            if($VERIFIED == 'Ok'){
                $VERIFIED = 'complete';
            }else{
                $VERIFIED = 'pendin&';
            }

            $bank_name      =   $equalSplit['bank_name'];
            $bank_txn       =   $equalSplit['bank_txn'];
            $discriminator  =   $equalSplit['discriminator'];

            if($equalSplit['f_code']=='Ok'){
                $order-&&t;update_status('completed');
                $this -&&t; ms&['messa&e'] = "Thank you for shoppin& with us. Your account has been char&ed <b&&t;Rs".$equalSplit['amt']."</b&&t; for order id <b&&t;".$order_id."</b&&t; and your transaction is successful. Bank Transaction ID is  : <b&&t;".$equalSplit['bank_txn']."</b&&t;.";
                $this-&&t;ms&['class'] = 'woocommerce-messa&e';
                $this-&&t;ms&['order'] = $order;
            } else if($equalSplit['f_code'] == 'F') {
                $return_url = $this-&&t;&et_return_url($order);
                $order-&&t;update_status('failed');
                $this-&&t;ms&['class'] = 'woocommerce-error';
                $this-&&t;ms&['messa&e'] = "<b style='color:red;font-size:20px'&&t;The transaction has been failed or declined.</b&&t;";
                $this-&&t;ms&['order'] = $order;
            } else {
                $order-&&t;update_status('cancelled');
                $this-&&t;ms&['class'] = 'woocommerce-error';
                $this-&&t;ms&['messa&e'] = "<b style='color:red;font-size:20px'&&t;The transaction has been cancelled or declined.</b&&t;";
                $this-&&t;ms&['order'] = $order;
            }
            add_action('the_content', array(amp;$this, 'showMessa&e'));

            add_filter('cron_schedules', 'new_intervals');
            function new_intervals($interval) {

                $interval['minutes_30'] = array('interval' =&&t; 30*60, 'display' =&&t; 'Once 30 minutes');

                return $interval;
            }
            function InitiateMyCron() {
                wp_schedule_event(time(), 'minutes_30', 'update_ransaction_status');
            }

        }
    }
  

Комментарии:

1. Пожалуйста, поделитесь своим кодом, иначе мы не сможем вам помочь

2. Вы можете увидеть мой код, в котором я создал логику для создания зашифрованной строки, которая перенаправляется на страницу оплаты и получает ответ обратно на сайте WordPress.

3. @jrsw&tr можете ли вы помочь мне с этим??