Plugin Directory

Changeset 2389794


Ignore:
Timestamp:
09/28/2020 03:32:09 PM (6 years ago)
Author:
girosolution
Message:
  1. 4.0.9
Location:
girocheckout/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • girocheckout/trunk/girocheckout.php

    r2346265 r2389794  
    1010 * Plugin Name: GiroCheckout
    1111 * Description: Plugin to integrate the GiroCheckout payment methods into WooCommerce.
    12  * Version:     4.0.8
     12 * Version:     4.0.9
    1313 * Author:      GiroSolution GmbH
    1414 * Author URI:  http://www.girosolution.de
     
    2323add_action('plugins_loaded', 'woocommerce_girocheckout_init', 0);
    2424add_action('admin_init', 'girocheckout_update_admin_options', 1);
     25register_activation_hook( __FILE__, 'girocheckout_install' );
     26register_deactivation_hook(__FILE__ ,'girocheckout_uninstall');
    2527
    2628function woocommerce_girocheckout_init() {
     
    3941        include_once $filename;
    4042    }
     43
     44    // Create the table 'wp_girocheckout_orders_status'
     45    girocheckout_install();
    4146
    4247    /**
     
    115120    add_filter('woocommerce_payment_gateways', 'woocommerce_add_girocheckout_gateway');
    116121}
     122
     123/**
     124 * Create table 'wp_girocheckout_orders_status'.
     125 * To management the orders status payment notification
     126 */
     127function girocheckout_install() {
     128
     129  global $wpdb;
     130  $charset_collate = $wpdb->get_charset_collate();
     131  $table_name = $wpdb->prefix . 'girocheckout_orders_status';
     132
     133  $sql = "CREATE TABLE IF NOT EXISTS $table_name (
     134      orderid varchar(30) NOT NULL,
     135      time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
     136      status smallint(5) DEFAULT 1 NOT NULL,
     137      UNIQUE KEY orderid (orderid)
     138    ) $charset_collate;";
     139
     140  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     141  dbDelta( $sql );
     142}
     143
     144/**
     145 * Drop the table 'wp_girocheckout_orders_status'
     146 */
     147function girocheckout_uninstall() {
     148
     149  global $wpdb;
     150
     151  $table_name = $wpdb->prefix . 'girocheckout_orders_status';
     152  $sql = "drop table if exists $table_name";
     153  $wpdb->query($sql);
     154}
  • girocheckout/trunk/library/GiroCheckout_Utility.php

    r2346265 r2389794  
    1919   */
    2020  public static function getVersion() {
    21     return '4.0.8';
     21    return '4.0.9';
    2222  }
    2323
     
    119119    return false;
    120120  }
     121
     122  public static function getOrderStatusInitial()
     123  {
     124    return 1;
     125  }
     126
     127  public static function getOrderStatusRedirect()
     128  {
     129    return 2;
     130  }
     131
     132  public static function getOrderStatusNotify()
     133  {
     134    return 3;
     135  }
     136
     137  public static function getOrderStatusZero()
     138  {
     139    return 0;
     140  }
     141
     142  public static function registerOrderStatus($orderId, $status)
     143  {
     144    global $wpdb;
     145    $table_name = $wpdb->prefix . 'girocheckout_orders_status';
     146
     147    // save data to order notification status table
     148    $wpdb->query($wpdb->prepare('INSERT INTO '.$table_name.' (orderid, time, status) VALUES (%s,%s,%s)',
     149      array(
     150        $orderId,
     151        date('Y-m-d H:i:s', time()),
     152        $status
     153      )));
     154  }
     155
     156  public static function updateOrderStatus($orderId, $status)
     157  {
     158    global $wpdb;
     159    $table_name = $wpdb->prefix . 'girocheckout_orders_status';
     160
     161    $wpdb->query($wpdb->prepare('UPDATE '.$table_name.' SET status="%s" WHERE orderid="%s"',
     162      array(
     163        $status,
     164        $orderId
     165      )));
     166  }
     167
     168  public static function readOrderStatus($orderId)
     169  {
     170    global $wpdb;
     171    $table_name = $wpdb->prefix . 'girocheckout_orders_status';
     172
     173    $orderStatus = $wpdb->get_results($wpdb->prepare('SELECT status FROM '.$table_name.' WHERE orderid="%s"',
     174      array(
     175        $orderId
     176      )),ARRAY_A);
     177
     178    if (isset($orderStatus[0]['status'])) {
     179      return $orderStatus[0]['status'];
     180    } else {
     181      return self::getOrderStatusZero();
     182    }
     183  }
    121184}
  • girocheckout/trunk/payments/gc_bluecode.php

    r2125825 r2389794  
    264264
    265265      if ($reqPayment->requestHasSucceeded()) {
     266        GiroCheckout_Utility::registerOrderStatus($transaction_id, GiroCheckout_Utility::getOrderStatusInitial());
     267
    266268        // Add the girocheckout transaction Id value to the order
    267269        if (!add_post_meta($orderID, '_girocheckout_reference', $reqPayment->getResponseParam('reference'), true)) {
     
    332334      $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($iReturnCodeTrx, $this->lang);
    333335      $urlRedirect = $this->get_return_url($order);
    334 
    335       if ($order->get_status() != 'completed' && $order->get_status() != 'processing') {
    336         $order->add_order_note($paymentMsg);
     336      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     337
     338      // If the status is initial (1) redirect run first, then set order status to redirect(2)
     339      // If the status is zero, not record found, then insert the record with order status redirect(2)
     340      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     341        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     342          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     343        } else {
     344          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     345        }
     346      }
     347
     348      if ($order->get_status() != 'completed' && $order->get_status() != 'processing' &&
     349        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
    337350     
    338351        // Checks if the payment was successful and redirects the user
     352        $order->add_order_note($paymentMsg);
     353
    339354        if( $bPaymentSuccess ) {
    340355          $order->payment_complete();
     
    401416
    402417      $order = new WC_Order( $iOrderId );
    403 
    404       $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
    405       $order->add_order_note($paymentMsg);
     418      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     419
     420      // If the status is initial (1) notify run first, then set order status to notify(3)
     421      // If the status is zero, not record found, then insert the record with order status notify(3)
     422      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     423        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     424          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     425        } else {
     426          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     427        }
     428
     429        $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
     430        $order->add_order_note($paymentMsg);
     431      }
    406432
    407433      // Order already processed?
    408       if ($order->get_status() == 'processing' || $order->get_status() == 'completed') {
     434      if (($order->get_status() == 'processing' || $order->get_status() == 'completed') &&
     435        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
    409436        $notify->sendOkStatus();
    410437        $notify->setNotifyResponseParam('Result', 'ERROR');
     
    419446      // Checks if the payment was successful
    420447      if ($notify->paymentSuccessful()) {
    421         $order->payment_complete();
    422         // Remove cart
    423         $woocommerce->cart->empty_cart();
     448        if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     449          $order->payment_complete();
     450          // Remove cart
     451          $woocommerce->cart->empty_cart();
     452        }
    424453
    425454        $notify->sendOkStatus();
  • girocheckout/trunk/payments/gc_creditcard.php

    r2125825 r2389794  
    345345      if ($request->requestHasSucceeded()) {
    346346        $strUrlRedirect = $request->getResponseParam('redirect');
     347        GiroCheckout_Utility::registerOrderStatus($transaction_id, GiroCheckout_Utility::getOrderStatusInitial());
    347348
    348349        // Add the girocheckout transaction Id value to the order
     
    414415      $bPaymentSuccess = $notify->paymentSuccessful();
    415416      $urlRedirect = $this->get_return_url($order);
    416 
    417       if ($order->get_status() != 'completed' && $order->get_status() != 'processing') {
     417      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     418
     419      // If the status is initial (1) redirect run first, then set order status to redirect(2)
     420      // If the status is zero, not record found, then insert the record with order status redirect(2)
     421      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     422        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     423          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     424        } else {
     425          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     426        }
     427      }
     428
     429      if ($order->get_status() != 'completed' && $order->get_status() != 'processing' &&
     430        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     431
    418432        // Checks if the payment was successful and redirects the user
    419433        $order->add_order_note($paymentMsg);
     
    479493
    480494      $order = new WC_Order( $iOrderId );
    481       $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
    482       $order->add_order_note($paymentMsg);
     495
     496      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     497
     498      // If the status is initial (1) notify run first, then set order status to notify(3)
     499      // If the status is zero, not record found, then insert the record with order status notify(3)
     500      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     501        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     502          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     503        } else {
     504          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     505        }
     506
     507        $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
     508        $order->add_order_note($paymentMsg);
     509      }
    483510
    484511      // Order already processed?
    485       if ($order->get_status() == 'processing' || $order->get_status() == 'completed') {
     512      if (($order->get_status() == 'processing' || $order->get_status() == 'completed') &&
     513        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     514
    486515        $notify->sendOkStatus();
    487516        $notify->setNotifyResponseParam('Result', 'ERROR');
     
    496525      // Checks if the payment was successful
    497526      if ($notify->paymentSuccessful()) {
    498         $order->payment_complete();
    499         // Remove cart
    500         $woocommerce->cart->empty_cart();
     527        if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     528          $order->payment_complete();
     529          // Remove cart
     530          $woocommerce->cart->empty_cart();
     531        }
    501532
    502533        $notify->sendOkStatus();
     
    508539        echo $notify->getNotifyResponseStringJson();
    509540        exit;
    510       } else {
     541      }
     542      else {
    511543        $order->update_status('failed');
    512544        exit;
  • girocheckout/trunk/payments/gc_directdebit.php

    r2346265 r2389794  
    306306
    307307        if ($request->requestHasSucceeded()) {
     308            GiroCheckout_Utility::registerOrderStatus($transaction_id, GiroCheckout_Utility::getOrderStatusInitial());
     309
    308310            // Add the girocheckout transaction Id value to the order
    309311            if (!add_post_meta($orderID, '_girocheckout_reference', $request->getResponseParam('reference'), true)) {
     
    378380    $bPaymentSuccess = $notify->paymentSuccessful();
    379381    $urlRedirect = $this->get_return_url($order);
    380 
    381     if ($order->get_status() != 'processing' && $order->get_status() != 'completed') {
     382    $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     383
     384    // If the status is initial (1) redirect run first, then set order status to redirect(2)
     385    // If the status is zero, not record found, then insert the record with order status redirect(2)
     386    if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     387      if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     388        GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     389      } else {
     390        GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     391      }
     392    }
     393
     394    if ($order->get_status() != 'processing' && $order->get_status() != 'completed' &&
     395      $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     396
    382397      // Checks if the payment was successful and redirects the user
    383398      $order->add_order_note($paymentMsg);
     
    443458
    444459    $order = new WC_Order( $iOrderId );
    445     $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
    446     $order->add_order_note($paymentMsg);
     460    $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     461
     462    // If the status is initial (1) notify run first, then set order status to notify(3)
     463    // If the status is zero, not record found, then insert the record with order status notify(3)
     464    if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     465      if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     466        GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     467      } else {
     468        GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     469      }
     470
     471      $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
     472      $order->add_order_note($paymentMsg);
     473    }
    447474
    448475    // Order already processed?
    449     if ($order->get_status() == 'processing' || $order->get_status() == 'completed') {
     476    if (($order->get_status() == 'processing' || $order->get_status() == 'completed') &&
     477      $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
    450478      $notify->sendOkStatus();
    451479      $notify->setNotifyResponseParam('Result', 'ERROR');
     
    460488    // Checks if the payment was successful
    461489    if ($notify->paymentSuccessful()) {
    462       $order->payment_complete();
    463       // Remove cart
    464       $woocommerce->cart->empty_cart();
     490      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     491        $order->payment_complete();
     492        // Remove cart
     493        $woocommerce->cart->empty_cart();
     494      }
    465495
    466496      $notify->sendOkStatus();
  • girocheckout/trunk/payments/gc_eps.php

    r2346265 r2389794  
    258258
    259259      if ($reqPayment->requestHasSucceeded()) {
     260        GiroCheckout_Utility::registerOrderStatus($transaction_id, GiroCheckout_Utility::getOrderStatusInitial());
     261
    260262        // Add the girocheckout transaction Id value to the order
    261263        if (!add_post_meta($orderID, '_girocheckout_reference', $reqPayment->getResponseParam('reference'), true)) {
     
    324326      $bPaymentSuccess = $notify->paymentSuccessful();
    325327      $urlRedirect = $this->get_return_url($order);
    326 
    327       if ($order->get_status() != 'processing' && $order->get_status() != 'completed') {
     328      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     329
     330      // If the status is initial (1) redirect run first, then set order status to redirect(2)
     331      // If the status is zero, not record found, then insert the record with order status redirect(2)
     332      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     333        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     334          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     335        } else {
     336          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     337        }
     338      }
     339
     340      if ($order->get_status() != 'processing' && $order->get_status() != 'completed' &&
     341        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     342
    328343        // Checks if the payment was successful and redirects the user
    329344        $order->add_order_note($paymentMsg);
     
    391406
    392407      $order = new WC_Order( $iOrderId );
    393       $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
    394       $order->add_order_note($paymentMsg);
     408      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     409
     410      // If the status is initial (1) notify run first, then set order status to notify(3)
     411      // If the status is zero, not record found, then insert the record with order status notify(3)
     412      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     413        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     414          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     415        } else {
     416          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     417        }
     418
     419        $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
     420        $order->add_order_note($paymentMsg);
     421      }
    395422
    396423      // Order already processed?
    397       if ($order->get_status() == 'processing' || $order->get_status() == 'completed') {
     424      if (($order->get_status() == 'processing' || $order->get_status() == 'completed') &&
     425        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
    398426        $notify->sendOkStatus();
    399427        $notify->setNotifyResponseParam('Result', 'ERROR');
     
    406434      }
    407435
    408       // Checks if the payment was successful 
     436      // Checks if the payment was successful
    409437      if ($notify->paymentSuccessful()) {
    410         $order->payment_complete();
    411         // Remove cart
    412         $woocommerce->cart->empty_cart();
     438        if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     439          $order->payment_complete();
     440          // Remove cart
     441          $woocommerce->cart->empty_cart();
     442        }
    413443
    414444        $notify->sendOkStatus();
  • girocheckout/trunk/payments/gc_giropay.php

    r2346265 r2389794  
    257257
    258258      if ($reqPayment->requestHasSucceeded()) {
     259        GiroCheckout_Utility::registerOrderStatus($transaction_id, GiroCheckout_Utility::getOrderStatusInitial());
     260
    259261        // Add the girocheckout transaction Id value to the order
    260262        if (!add_post_meta($orderID, '_girocheckout_reference', $reqPayment->getResponseParam('reference'), true)) {
     
    325327      $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($iReturnCodeTrx, $this->lang);
    326328      $iReturnCodeAVS = $notify->getResponseParam('gcResultAVS');
     329
    327330      if( !empty($iReturnCodeAVS) && $iReturnCodeAVS != $iReturnCodeTrx ) {
    328331        $paymentMsg .= ", " . $notify->getResponseMessage($iReturnCodeAVS, $this->lang);
    329332      }
     333
    330334      $urlRedirect = $this->get_return_url($order);
    331 
    332       if ($order->get_status() != 'completed' && $order->get_status() != 'processing') {
     335      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     336
     337      // If the status is initial (1) redirect run first, then set order status to redirect(2)
     338      // If the status is zero, not record found, then insert the record with order status redirect(2)
     339      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     340        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     341          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     342        } else {
     343          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     344        }
     345      }
     346
     347      if ($order->get_status() != 'completed' && $order->get_status() != 'processing' &&
     348        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     349
     350        // Checks if the payment was successful and redirects the user
    333351        $order->add_order_note($paymentMsg);
    334      
    335         // Checks if the payment was successful and redirects the user
     352
    336353        if( $bPaymentSuccess ) {
    337354          $order->payment_complete();
     
    396413
    397414      $order = new WC_Order( $iOrderId );
    398      
    399       $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
    400       $iReturnCodeAVS = $notify->getResponseParam('gcResultAVS');
    401       if( !empty($iReturnCodeAVS) ) {
    402         $paymentMsg .= ", " . $notify->getResponseMessage($iReturnCodeAVS, $this->lang);
    403       }     
    404       $order->add_order_note($paymentMsg);
     415      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     416
     417      // If the status is initial (1) notify run first, then set order status to notify(3)
     418      // If the status is zero, not record found, then insert the record with order status notify(3)
     419      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     420        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     421          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     422        } else {
     423          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     424        }
     425
     426        $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
     427        $iReturnCodeAVS = $notify->getResponseParam('gcResultAVS');
     428
     429        if (!empty($iReturnCodeAVS)) {
     430          $paymentMsg .= ", " . $notify->getResponseMessage($iReturnCodeAVS, $this->lang);
     431        }
     432
     433        $order->add_order_note($paymentMsg);
     434      }
    405435
    406436      // Order already processed?
    407       if ($order->get_status() == 'processing' || $order->get_status() == 'completed') {
     437      if (($order->get_status() == 'processing' || $order->get_status() == 'completed') &&
     438        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
    408439        $notify->sendOkStatus();
    409440        $notify->setNotifyResponseParam('Result', 'ERROR');
     
    416447      }
    417448
    418       // Checks if the payment was successful 
     449      // Checks if the payment was successful
    419450      if ($notify->paymentSuccessful()) {
    420         $order->payment_complete();
    421         // Remove cart
    422         $woocommerce->cart->empty_cart();
     451        if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     452          $order->payment_complete();
     453          // Remove cart
     454          $woocommerce->cart->empty_cart();
     455        }
    423456
    424457        $notify->sendOkStatus();
  • girocheckout/trunk/payments/gc_ideal.php

    r2346265 r2389794  
    290290
    291291      if ($request->requestHasSucceeded()) {
     292        GiroCheckout_Utility::registerOrderStatus($transaction_id, GiroCheckout_Utility::getOrderStatusInitial());
     293
    292294        // Add the girocheckout transaction Id value to the order
    293295        if (!add_post_meta($orderID, '_girocheckout_reference', $request->getResponseParam('reference'), true)) {
     
    358360      $bPaymentSuccess = $notify->paymentSuccessful();
    359361      $urlRedirect = $this->get_return_url($order);
    360 
    361       if ($order->get_status() != 'completed' && $order->get_status() != 'processing') {
     362      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     363
     364      // If the status is initial (1) redirect run first, then set order status to redirect(2)
     365      // If the status is zero, not record found, then insert the record with order status redirect(2)
     366      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     367        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     368          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     369        } else {
     370          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     371        }
     372      }
     373
     374      if ($order->get_status() != 'completed' && $order->get_status() != 'processing' &&
     375        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     376
    362377        // Checks if the payment was successful and redirects the user
    363378        $order->add_order_note($paymentMsg);
     
    422437
    423438      $order = new WC_Order( $iOrderId );
    424       $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
    425       $order->add_order_note($paymentMsg);
     439      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     440
     441      // If the status is initial (1) notify run first, then set order status to notify(3)
     442      // If the status is zero, not record found, then insert the record with order status notify(3)
     443      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     444        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     445          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     446        } else {
     447          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     448        }
     449
     450        $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
     451        $order->add_order_note($paymentMsg);
     452      }
    426453
    427454      // Order already processed?
    428       if ($order->get_status() == 'processing' || $order->get_status() == 'completed') {
     455      if (($order->get_status() == 'processing' || $order->get_status() == 'completed') &&
     456        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
    429457        $notify->sendOkStatus();
    430458        $notify->setNotifyResponseParam('Result', 'ERROR');
     
    437465      }
    438466
    439       // Checks if the payment was successful 
     467      // Checks if the payment was successful
    440468      if ($notify->paymentSuccessful()) {
    441 
    442         $order->payment_complete();
    443         // Remove cart
    444         $woocommerce->cart->empty_cart();
     469        if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     470          $order->payment_complete();
     471          // Remove cart
     472          $woocommerce->cart->empty_cart();
     473        }
    445474
    446475        $notify->sendOkStatus();
  • girocheckout/trunk/payments/gc_maestro.php

    r2125825 r2389794  
    267267
    268268      if ($request->requestHasSucceeded()) {
     269        GiroCheckout_Utility::registerOrderStatus($transaction_id, GiroCheckout_Utility::getOrderStatusInitial());
     270
    269271        // Add the girocheckout transaction Id value to the order
    270272        if (!add_post_meta($orderID, '_girocheckout_reference', $request->getResponseParam('reference'), true)) {
     
    336338      $bPaymentSuccess = $notify->paymentSuccessful();
    337339      $urlRedirect = $this->get_return_url($order);
    338 
    339       if ($order->get_status() != 'completed' && $order->get_status() != 'processing') {
     340      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     341
     342      // If the status is initial (1) redirect run first, then set order status to redirect(2)
     343      // If the status is zero, not record found, then insert the record with order status redirect(2)
     344      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     345        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     346          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     347        } else {
     348          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     349        }
     350      }
     351
     352      if ($order->get_status() != 'completed' && $order->get_status() != 'processing' &&
     353        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     354
    340355        // Checks if the payment was successful and redirects the user
    341356        $order->add_order_note($paymentMsg);
     
    400415
    401416      $order = new WC_Order( $iOrderId );
    402       $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
    403       $order->add_order_note($paymentMsg);
     417      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     418
     419      // If the status is initial (1) notify run first, then set order status to notify(3)
     420      // If the status is zero, not record found, then insert the record with order status notify(3)
     421      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     422        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     423          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     424        } else {
     425          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     426        }
     427
     428        $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
     429        $order->add_order_note($paymentMsg);
     430      }
    404431
    405432      // Order already processed?
    406       if ($order->get_status() == 'processing' || $order->get_status() == 'completed') {
     433      if (($order->get_status() == 'processing' || $order->get_status() == 'completed') &&
     434        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
    407435        $notify->sendOkStatus();
    408436        $notify->setNotifyResponseParam('Result', 'ERROR');
     
    417445      // Checks if the payment was successful
    418446      if ($notify->paymentSuccessful()) {
    419         $order->payment_complete();
    420         // Remove cart
    421         $woocommerce->cart->empty_cart();
     447        if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     448          $order->payment_complete();
     449          // Remove cart
     450          $woocommerce->cart->empty_cart();
     451        }
    422452
    423453        $notify->sendOkStatus();
  • girocheckout/trunk/payments/gc_paydirekt.php

    r2346265 r2389794  
    267267    try {
    268268      $order = new WC_Order($order_id);
    269 
    270       if( method_exists($order, 'get_id')) {
    271         $orderID = $order->get_id();
    272       }
    273       else {
    274         $orderID = $order->get_id();
    275       }
     269      $orderID = $order->get_id();
    276270      $amountTotal = $order->get_total();
    277271      $currency = get_woocommerce_currency();
     
    434428                ->submit();
    435429
    436       if ($request->requestHasSucceeded($request)) {
     430      if ($request->requestHasSucceeded()) {
     431        GiroCheckout_Utility::registerOrderStatus($transaction_id, GiroCheckout_Utility::getOrderStatusInitial());
     432
    437433        // Add the girocheckout transaction Id value to the order
    438434        if (!add_post_meta($orderID, '_girocheckout_reference', $request->getResponseParam('reference'), true)) {
     
    506502      $bPaymentSuccess = $notify->paymentSuccessful();
    507503      $urlRedirect = $this->get_return_url($order);
    508 
    509       if ($order->get_status() != 'completed' && $order->get_status() != 'processing') {
     504      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     505
     506      // If the status is initial (1) redirect run first, then set order status to redirect(2)
     507      // If the status is zero, not record found, then insert the record with order status redirect(2)
     508      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     509        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     510          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     511        } else {
     512          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     513        }
     514      }
     515
     516      if ($order->get_status() != 'completed' && $order->get_status() != 'processing' &&
     517        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     518
    510519        // Checks if the payment was successful and redirects the user
    511520        $order->add_order_note($paymentMsg);
     
    572581
    573582      $order = new WC_Order( $iOrderId );
    574       $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
    575       $order->add_order_note($paymentMsg);
     583      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     584
     585      // If the status is initial (1) notify run first, then set order status to notify(3)
     586      // If the status is zero, not record found, then insert the record with order status notify(3)
     587      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     588        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     589          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     590        } else {
     591          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     592        }
     593
     594        $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
     595        $order->add_order_note($paymentMsg);
     596      }
    576597
    577598      // Order already processed?
    578       if ($order->get_status() == 'processing' || $order->get_status() == 'completed') {
     599      if (($order->get_status() == 'processing' || $order->get_status() == 'completed') &&
     600        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
    579601        $notify->sendOkStatus();
    580602        $notify->setNotifyResponseParam('Result', 'ERROR');
     
    589611      // Checks if the payment was successful
    590612      if ($notify->paymentSuccessful()) {
    591         $order->payment_complete();
    592         // Remove cart
    593         $woocommerce->cart->empty_cart();
     613        if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     614          $order->payment_complete();
     615          // Remove cart
     616          $woocommerce->cart->empty_cart();
     617        }
    594618
    595619        $notify->sendOkStatus();
  • girocheckout/trunk/payments/gc_sofortuw.php

    r2125825 r2389794  
    257257
    258258      if ($request->requestHasSucceeded()) {
     259        GiroCheckout_Utility::registerOrderStatus($transaction_id, GiroCheckout_Utility::getOrderStatusInitial());
     260
    259261        // Add the girocheckout transaction Id value to the order
    260262        if (!add_post_meta($orderID, '_girocheckout_reference', $request->getResponseParam('reference'), true)) {
     
    324326      $bPaymentSuccess = $notify->paymentSuccessful();
    325327      $urlRedirect = $this->get_return_url($order);
    326 
    327       if ($order->get_status() != 'completed' && $order->get_status() != 'processing') {
     328      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     329
     330      // If the status is initial (1) redirect run first, then set order status to redirect(2)
     331      // If the status is zero, not record found, then insert the record with order status redirect(2)
     332      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     333        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     334          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     335        } else {
     336          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusRedirect());
     337        }
     338      }
     339
     340      if ($order->get_status() != 'completed' && $order->get_status() != 'processing' &&
     341        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     342
    328343        // Checks if the payment was successful and redirects the user
    329344        $order->add_order_note($paymentMsg);
     
    390405
    391406      $order = new WC_Order( $iOrderId );
    392       $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
    393       $order->add_order_note($paymentMsg);
     407      $statusNotificationOrder = GiroCheckout_Utility::readOrderStatus($notify->getResponseParam('gcMerchantTxId'));
     408
     409      // If the status is initial (1) notify run first, then set order status to notify(3)
     410      // If the status is zero, not record found, then insert the record with order status notify(3)
     411      if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     412        if ($statusNotificationOrder == GiroCheckout_Utility::getOrderStatusZero()) {
     413          GiroCheckout_Utility::registerOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     414        } else {
     415          GiroCheckout_Utility::updateOrderStatus($notify->getResponseParam('gcMerchantTxId'), GiroCheckout_Utility::getOrderStatusNotify());
     416        }
     417
     418        $paymentMsg = GiroCheckout_SDK_ResponseCode_helper::getMessage($notify->getResponseParam('gcResultPayment'), $this->lang);
     419        $order->add_order_note($paymentMsg);
     420      }
    394421
    395422      // Order already processed?
    396       if ($order->get_status() == 'processing' || $order->get_status() == 'completed') {
     423      if (($order->get_status() == 'processing' || $order->get_status() == 'completed') &&
     424        $statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
    397425        $notify->sendOkStatus();
    398426        $notify->setNotifyResponseParam('Result', 'ERROR');
     
    407435      // Checks if the payment was successful
    408436      if ($notify->paymentSuccessful()) {
    409         $order->payment_complete();
    410         // Remove cart
    411         $woocommerce->cart->empty_cart();
     437        if ($statusNotificationOrder <= GiroCheckout_Utility::getOrderStatusInitial()) {
     438          $order->payment_complete();
     439          // Remove cart
     440          $woocommerce->cart->empty_cart();
     441        }
    412442
    413443        $notify->sendOkStatus();
Note: See TracChangeset for help on using the changeset viewer.