Plugin Directory

Changeset 2801546


Ignore:
Timestamp:
10/20/2022 01:03:36 AM (3 years ago)
Author:
flutterwave
Message:

fix: woocommerce blank page

Location:
rave-woocommerce-payment-gateway
Files:
212 added
5 edited

Legend:

Unmodified
Added
Removed
  • rave-woocommerce-payment-gateway/tags/2.2.9/includes/class.flw_wc_payment_gateway.php

    r2754379 r2801546  
    245245    }
    246246
    247    
    248     /**
    249      * Handles admin notices
    250      *
    251      * @return void
    252      */
    253     public function admin_notices() {
    254 
    255       if ( 'no' == $this->enabled ) {
    256         return;
    257       }
    258 
    259       /**
    260        * Check if public key is provided
    261        */
    262       if ( ! $this->public_key || ! $this->secret_key ) {
    263         $mode = ('yes' === $this->go_live) ? 'live' : 'test';
    264         echo '<div class="error"><p>';
    265         echo sprintf(
    266           'Provide your '.$mode .' public key and secret key <a href="%s">here</a> to be able to use the Rave Payment Gateway plugin. If you don\'t have one, kindly sign up at <a href="https://rave.flutterwave.com" target="_blank>https://rave.flutterwave.com</a>, navigate to the settings page and click on API.',
    267            admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rave' )
    268          );
    269         echo '</p></div>';
    270         return;
    271       }
    272 
    273     }
     247
     248  /**
     249   * Handles admin notices
     250   *
     251   * @return void
     252   */
     253  public function admin_notices()
     254  {
     255
     256      if ( 'yes' === $this->enabled ) {
     257
     258          if ( empty( $this->public_key ) || empty( $this->secret_key ) ) {
     259
     260              echo '<div class="error"><p>' . sprintf( __( 'Flutterwave is enabled, but the <strong>Public Key</strong> and <strong>Secret Key</strong> are not configured. Please <a href="%s">click here</a> to configure it.', 'flw-payments' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rave' ) ) . '</p></div>';
     261
     262          }
     263      }
     264
     265  }
    274266
    275267    /**
     
    447439      }else{
    448440        if(isset($_GET['cancelled']) && isset($_GET['order_id'])){
    449           if(!$order_id){
    450             $order_id = urldecode( $_GET['order_id'] );
    451           }
     441          $order_id = urldecode( $_GET['order_id'] );
    452442          $order = wc_get_order( $order_id );
    453443          $redirectURL = $order->get_checkout_payment_url( true );
     
    457447       
    458448        if ( isset( $_POST['txRef'] ) || isset($_GET['txref']) ) {
    459             $txn_ref = isset($_POST['txRef']) ? $_POST['txRef'] : urldecode($_GET['txref']);
     449            $txn_ref = $_POST['txRef'] ?? urldecode($_GET['txref']);
    460450            $o = explode('_', $txn_ref);
    461451            $order_id = intval( $o[1] );
     
    470460            header("Location: ".$redirect_url);
    471461            die();
    472         }else{
    473           $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option);
    474        
    475           $payment->logger->notice('Error with requerying payment.');
    476             die();
    477462        }
    478463      }
  • rave-woocommerce-payment-gateway/tags/2.3.0/includes/class.flw_wc_payment_gateway.php

    r2772073 r2801546  
    245245    }
    246246
    247    
    248     /**
    249      * Handles admin notices
    250      *
    251      * @return void
    252      */
    253     public function admin_notices() {
    254 
    255       if ( 'no' == $this->enabled ) {
    256         return;
    257       }
    258 
    259       /**
    260        * Check if public key is provided
    261        */
    262       if ( ! $this->public_key || ! $this->secret_key ) {
    263         $mode = ('yes' === $this->go_live) ? 'live' : 'test';
    264         echo '<div class="error"><p>';
    265         echo sprintf(
    266           'Provide your '.$mode .' public key and secret key <a href="%s">here</a> to be able to use the Rave Payment Gateway plugin. If you don\'t have one, kindly sign up at <a href="https://rave.flutterwave.com" target="_blank>https://rave.flutterwave.com</a>, navigate to the settings page and click on API.',
    267            admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rave' )
    268          );
    269         echo '</p></div>';
    270         return;
    271       }
    272 
    273     }
     247
     248  /**
     249   * Handles admin notices
     250   *
     251   * @return void
     252   */
     253  public function admin_notices()
     254  {
     255
     256      if ( 'yes' === $this->enabled ) {
     257
     258          if ( empty( $this->public_key ) || empty( $this->secret_key ) ) {
     259
     260              echo '<div class="error"><p>' . sprintf( __( 'Flutterwave is enabled, but the <strong>Public Key</strong> and <strong>Secret Key</strong> are not configured. Please <a href="%s">click here</a> to configure it.', 'flw-payments' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rave' ) ) . '</p></div>';
     261
     262          }
     263      }
     264
     265  }
    274266
    275267    /**
     
    417409       
    418410        $payment = new Rave($publicKey, $secretKey, $ref, $overrideRef,$logging_option);
    419        
    420         // if($this->modal_logo){
    421         //   $rave_m_logo = $this->modal_logo;
    422         // }
    423411
    424412        //set variables
     
    447435      }else{
    448436        if(isset($_GET['cancelled']) && isset($_GET['order_id'])){
    449           if(!$order_id){
    450             $order_id = urldecode( $_GET['order_id'] );
    451           }
     437          $order_id = urldecode( $_GET['order_id'] );
    452438          $order = wc_get_order( $order_id );
    453439          $redirectURL = $order->get_checkout_payment_url( true );
     
    457443       
    458444        if ( isset( $_POST['txRef'] ) || isset($_GET['txref']) ) {
    459             $txn_ref = isset($_POST['txRef']) ? $_POST['txRef'] : urldecode($_GET['txref']);
     445            $txn_ref = $_POST['txRef'] ?? urldecode($_GET['txref']);
    460446            $o = explode('_', $txn_ref);
    461447            $order_id = intval( $o[1] );
     
    470456            header("Location: ".$redirect_url);
    471457            die();
    472         }else{
    473           $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option);
    474        
    475           $payment->logger->notice('Error with requerying payment.');
    476             die();
    477458        }
    478459      }
     
    494475    if (!$signature) {
    495476        // only a post with rave signature header gets our attention
    496         echo "Access Denied Hash does not match";
     477        echo "Unauthorized request. please check your hash";
    497478        exit();
    498479    }
     
    503484    // confirm the event's signature
    504485    if( $signature !== $local_signature ){
    505       // silently forget this ever happened
     486      echo "Access Denied Hash does not match";
    506487      exit();
    507488    }
     
    517498
    518499    if ($response_version) {
    519 
    520500        switch ($response_version) {
    521501            case 'v3':
     
    526506                $secretKey = $this->secret_key;
    527507                $publicKey = $this->public_key;
     508                $txn_ref = $response->data->tx_ref;
    528509                $order->add_order_note('Webhook verification initiated - v3');
    529                 $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option);
    530                 $payment->eventHandler(new myEventHandler($order))->requeryTransaction($response->data->tx_ref);
     510                $payment = new Rave($publicKey, $secretKey, $txn_ref, true, $this->logging_option);
     511                $payment->eventHandler(new myEventHandler($order))->requeryTransaction($txn_ref);
    531512                do_action('flw_webhook_after_action', json_encode($response->data, TRUE));
    532513                break;
     
    538519                $secretKey = $this->secret_key;
    539520                $publicKey = $this->public_key;
     521                $txn_ref = $response->txRef;
    540522                $order->add_order_note('Webhook verification initiated - v2');
    541                 $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option);
    542                 $payment->eventHandler(new myEventHandler($order))->requeryTransaction($response->txRef);
     523                $payment = new Rave($publicKey, $secretKey, $txn_ref, true, $this->logging_option);
     524                $payment->eventHandler(new myEventHandler($order))->requeryTransaction($txn_ref);
    543525                do_action('flw_webhook_after_action', json_encode($response, TRUE));
    544526                break;
    545527        }
    546528    }
    547     exit();   
    548 
     529    exit();
    549530  }
    550531
  • rave-woocommerce-payment-gateway/trunk/includes/class.flw_wc_payment_gateway.php

    r2772073 r2801546  
    249249
    250250
    251   /**
    252    * Handles admin notices
    253    *
    254    * @return void
    255    */
    256   public function admin_notices()
    257   {
    258 
    259     if ('no' == $this->enabled) {
    260       return;
    261     }
    262 
    263251    /**
    264      * Check if public key is provided
     252     * Handles admin notices
     253     *
     254     * @return void
    265255     */
    266     if (!$this->public_key || !$this->secret_key) {
    267       $mode = ('yes' === $this->go_live) ? 'live' : 'test';
    268       echo '<div class="error"><p>';
    269       echo sprintf(
    270         'Provide your ' . $mode . ' public key and secret key <a href="%s">here</a> to be able to use the Rave Payment Gateway plugin. If you don\'t have one, kindly sign up at <a href="https://rave.flutterwave.com" target="_blank>https://rave.flutterwave.com</a>, navigate to the settings page and click on API.',
    271         admin_url('admin.php?page=wc-settings&tab=checkout&section=rave')
    272       );
    273       echo '</p></div>';
    274       return;
    275     }
    276 
    277   }
     256    public function admin_notices()
     257    {
     258
     259        if ( 'yes' === $this->enabled ) {
     260
     261            if ( empty( $this->public_key ) || empty( $this->secret_key ) ) {
     262
     263                echo '<div class="error"><p>' . sprintf( __( 'Flutterwave is enabled, but the <strong>Public Key</strong> and <strong>Secret Key</strong> are not configured. Please <a href="%s">click here</a> to configure it.', 'flw-payments' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=rave' ) ) . '</p></div>';
     264
     265            }
     266        }
     267
     268    }
    278269
    279270  /**
     
    457448    else {
    458449      if (isset($_GET['cancelled']) && isset($_GET['order_id'])) {
    459         if (!$order_id) {
    460           $order_id = urldecode($_GET['order_id']);
    461         }
     450        $order_id = urldecode($_GET['order_id']);
    462451        $order = wc_get_order($order_id);
    463452        $redirectURL = $order->get_checkout_payment_url(true);
     
    467456
    468457      if (isset($_POST['txRef']) || isset($_GET['txref'])) {
    469         $txn_ref = isset($_POST['txRef']) ? $_POST['txRef'] : urldecode($_GET['txref']);
     458        $txn_ref = $_POST['txRef'] ?? urldecode($_GET['txref']);
    470459        $o = explode('_', $txn_ref);
    471460        $order_id = intval($o[1]);
     
    479468        $redirect_url = $this->get_return_url($order);
    480469        header("Location: " . $redirect_url);
    481         die();
    482       }
    483       else {
    484         $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option);
    485 
    486         $payment->logger->notice('Error with requerying payment.');
    487470        die();
    488471      }
     
    538521          $secretKey = $this->secret_key;
    539522          $publicKey = $this->public_key;
     523          $txn_ref = $response->data->tx_ref;
    540524          $order->add_order_note('Webhook verification initiated - v3');
    541           $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option);
     525          $payment = new Rave($publicKey, $secretKey, $txn_ref, true, $this->logging_option);
    542526          $payment->eventHandler(new myEventHandler($order))->requeryTransaction($response->data->tx_ref);
    543527          do_action('flw_webhook_after_action', json_encode($response->data, TRUE));
     
    550534          $secretKey = $this->secret_key;
    551535          $publicKey = $this->public_key;
     536          $txn_ref = $response->txRef;
    552537          $order->add_order_note('Webhook verification initiated - v2');
    553           $payment = new Rave($publicKey, $secretKey, $txn_ref, $overrideRef, $this->logging_option);
     538          $payment = new Rave($publicKey, $secretKey, $txn_ref, true, $this->logging_option);
    554539          $payment->eventHandler(new myEventHandler($order))->requeryTransaction($response->txRef);
    555540          do_action('flw_webhook_after_action', json_encode($response, TRUE));
  • rave-woocommerce-payment-gateway/trunk/readme.txt

    r2772073 r2801546  
    44Requires at least: 3.1
    55Tested up to: 6.0
    6 Stable tag: 2.3.0
     6Stable tag: 2.3.1
    77License: MIT
    88License URI: https://github.com/Flutterwave/rave-woocommerce/blob/master/LICENSE
  • rave-woocommerce-payment-gateway/trunk/woocommerce-rave.php

    r2772073 r2801546  
    44Plugin Name: Flutterwave WooCommerce
    55Plugin URI: https://rave.flutterwave.com/
    6 Description: Official WooCommerce payment gateway for Rave.
    7 Version: 2.3.0
     6Description: Official WooCommerce payment gateway for Flutterwave.
     7Version: 2.3.1
    88Author: Flutterwave Developers
    99Author URI: http://developer.flutterwave.com
     
    5353
    5454  $rave_settings_url = esc_url(get_admin_url(null, 'admin.php?page=wc-settings&tab=checkout&section=rave'));
    55   array_unshift($links, "<a title='Rave Settings Page' href='$rave_settings_url'>Settings</a>");
     55  array_unshift($links, "<a title='Flutterwave Settings Page' href='$rave_settings_url'>Settings</a>");
    5656
    5757  return $links;
     
    7474    $methods[] = 'FLW_WC_Payment_Gateway_Subscriptions';
    7575
    76   }
    77   else {
     76  } else {
    7877
    7978    $methods[] = 'FLW_WC_Payment_Gateway';
Note: See TracChangeset for help on using the changeset viewer.