osCommerce France : Accueil Forum Portail osCommerce France Réponses aux questions Foire aux contributions

Bienvenue invité ( Connexion | Inscription )

2 Pages V   1 2 >  
Reply to this topicStart new topic
> PayPal IPN V1.2 + Stock avec QTPRO 4.2, [RESOLU] comme un grand !
xavkick
posté 16 Jun 2006, 11:31
Message #1


Ceinture orange+ OSC
Icône de groupe

Groupe : Membres
Messages : 461
Inscrit : 16-June 05
Lieu : 22980
Membre no 6229



VOila,

J'ai installé la contrib Paypal IPN v1.2...

Tout marche nickel, sauf que lors des commandes les articles de mon stock se mettent a jours sans soucis sauf pour tous les articles avec attributs gérer par QTPRO.... la quantité ne change pas...

J'ai renseigné sur le site de paypal le checkout_process.php mais rien n'y fait...

avez vous une idée?

merci

xav

Ce message a été modifié par xavkick - 16 Jun 2006, 13:49.


--------------------

MS2 machin truc (thema 3) 6.1.2 Patchée + QTPRO 4.2 + Discount Plus + Fancier Invoice + Master Pasword + Dangling Carrot + Kelkoo + SEO urls + SEO assisstant + diverses contrib
Go to the top of the page
 
xavkick
posté 16 Jun 2006, 13:46
Message #2


Ceinture orange+ OSC
Icône de groupe

Groupe : Membres
Messages : 461
Inscrit : 16-June 05
Lieu : 22980
Membre no 6229



Bon j'ai la solution ....

Bien sauvegarder sa base et ses fichiers avant....

il faut avoir qtpro 4.25 et paypal_ipn.php v1.2 installé

alors dans le fichier /includes/modules/payment/paypal_ipn.php

cherchez
CODE
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
            $sql_data_array = array('orders_id' => $insert_id,
                                    'products_id' => tep_get_prid($order->products[$i]['id']),
                                    'products_model' => $order->products[$i]['model'],
                                    'products_name' => $order->products[$i]['name'],
                                    'products_price' => $order->products[$i]['price'],
                                    'final_price' => $order->products[$i]['final_price'],
                                    'products_tax' => $order->products[$i]['tax'],
                                    'products_quantity' => $order->products[$i]['qty']);


remplacez par :
CODE
//++++ QT Pro: Begin Changed code
  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
    $products_stock_attributes=null;
    if (STOCK_LIMITED == 'true') {
      $products_attributes = $order->products[$i]['attributes'];

      $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename
                          FROM " . TABLE_PRODUCTS . " p
                          LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                           ON p.products_id=pa.products_id
                          LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                           ON pa.products_attributes_id=pad.products_attributes_id
                          WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";

                          
      if (is_array($products_attributes)) {
        $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
      }
      $stock_query = tep_db_query($stock_query_raw);
      if (tep_db_num_rows($stock_query) > 0) {
        $stock_values = tep_db_fetch_array($stock_query);

         $actual_stock_bought = $order->products[$i]['qty'];
        $download_selected = false;
        if ((DOWNLOAD_ENABLED == 'true') && isset($stock_values['products_attributes_filename']) && tep_not_null($stock_values['products_attributes_filename'])) {
          $download_selected = true;
          $products_stock_attributes='$$DOWNLOAD$$';
        }
//      If not downloadable and attributes present, adjust attribute stock
        if (!$download_selected && is_array($products_attributes)) {
          $all_nonstocked = true;
          $products_stock_attributes_array = array();
          foreach ($products_attributes as $attribute) {
            $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
            
            asort($products_stock_attributes_array, SORT_NUMERIC);
            $products_stock_attributes = implode(",", $products_stock_attributes_array);
            }
        }
    }
} else {
    if ( is_array($order->products[$i]['attributes']) ) {
      $products_stock_attributes_array = array();
      foreach ($order->products[$i]['attributes'] as $attribute) {
          $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
        }
        asort($products_stock_attributes_array, SORT_NUMERIC);
        $products_stock_attributes = implode(",", $products_stock_attributes_array);
    }
}    

            if (!isset($products_stock_attributes)) $products_stock_attributes=null;  
              $sql_data_array = array('orders_id' => $insert_id,
                                    'products_id' => tep_get_prid($order->products[$i]['id']),
                                    'products_model' => $order->products[$i]['model'],
                                    'products_name' => $order->products[$i]['name'],
                                    'products_price' => $order->products[$i]['price'],
                                    'final_price' => $order->products[$i]['final_price'],
                                    'products_tax' => $order->products[$i]['tax'],
                                    'products_quantity' => $order->products[$i]['qty'],
                            'products_stock_attributes' => $products_stock_attributes);
//++++ QT Pro: End Changed Code


puis cherchez
CODE
function before_process() {
      global $customer_id, $order, $sendto, $billto, $payment, $currencies, $cart, $cart_PayPal_IPN_ID;
      global $$payment;


et remplacez par :

CODE
    function before_process() {
      global $customer_id, $order, $sendto, $billto, $payment, $languages_id, $currencies, $cart, $cart_PayPal_IPN_ID;
      global $$payment;


cherchez :
CODE
// Stock Update - Joao Correia
        if (STOCK_LIMITED == 'true') {
          if (DOWNLOAD_ENABLED == 'true') {


remplacez par :
CODE
// Stock Update - Joao Correia
//++++ QT Pro: Begin Changed code
    $products_stock_attributes=null;
    if (STOCK_LIMITED == 'true') {
        $products_attributes = $order->products[$i]['attributes'];
//      if (DOWNLOAD_ENABLED == 'true') {
//++++ QT Pro: End Changed Code


cherchez :

CODE
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
            $products_attributes = $order->products[$i]['attributes'];
            if (is_array($products_attributes)) {
              $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
            }
            $stock_query = tep_db_query($stock_query_raw);
          } else {
            $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
          }
          if (tep_db_num_rows($stock_query) > 0) {
            $stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
            if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {
              $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
            } else {
              $stock_left = $stock_values['products_quantity'];
            }
            tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
            if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
              tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
            }
          }
        }

// Update products_ordered (for bestsellers list)


remplacez par :

CODE
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
//++++ QT Pro: Begin Changed code
//      $products_attributes = $order->products[$i]['attributes'];
//++++ QT Pro: End Changed Code
      if (is_array($products_attributes)) {
        $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
      }
      $stock_query = tep_db_query($stock_query_raw);
      if (tep_db_num_rows($stock_query) > 0) {
        $stock_values = tep_db_fetch_array($stock_query);

//++++ QT Pro: Begin Changed code
        $actual_stock_bought = $order->products[$i]['qty'];
        $download_selected = false;
        if ((DOWNLOAD_ENABLED == 'true') && isset($stock_values['products_attributes_filename']) && tep_not_null($stock_values['products_attributes_filename'])) {
          $download_selected = true;
          $products_stock_attributes='$$DOWNLOAD$$';
        }
//      If not downloadable and attributes present, adjust attribute stock
        if (!$download_selected && is_array($products_attributes)) {
          $all_nonstocked = true;
          $products_stock_attributes_array = array();
          foreach ($products_attributes as $attribute) {

//**si** 14-11-05 fix missing att list
//            if ($attribute['track_stock'] == 1) {
//              $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
$products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
if ($attribute['track_stock'] == 1) {
//**si** 14-11-05 end

              $all_nonstocked = false;
            }
          }
          if ($all_nonstocked) {
            $actual_stock_bought = $order->products[$i]['qty'];

//**si** 14-11-05 fix missing att list
asort($products_stock_attributes_array, SORT_NUMERIC);
$products_stock_attributes = implode(",", $products_stock_attributes_array);
//**si** 14-11-05 end

          }  else {
            asort($products_stock_attributes_array, SORT_NUMERIC);
            $products_stock_attributes = implode(",", $products_stock_attributes_array);
            $attributes_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
            if (tep_db_num_rows($attributes_stock_query) > 0) {
              $attributes_stock_values = tep_db_fetch_array($attributes_stock_query);
              $attributes_stock_left = $attributes_stock_values['products_stock_quantity'] - $order->products[$i]['qty'];
              tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '" . $attributes_stock_left . "' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
              $actual_stock_bought = ($attributes_stock_left < 1) ? $attributes_stock_values['products_stock_quantity'] : $order->products[$i]['qty'];
            } else {
              $attributes_stock_left = 0 - $order->products[$i]['qty'];
              tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " (products_id, products_stock_attributes, products_stock_quantity) values ('" . tep_get_prid($order->products[$i]['id']) . "', '" . $products_stock_attributes . "', '" . $attributes_stock_left . "')");
              $actual_stock_bought = 0;
            }
          }
        }
//        $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
//      }
//      if (tep_db_num_rows($stock_query) > 0) {
//        $stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
        if (!$download_selected) {
          $stock_left = $stock_values['products_quantity'] - $actual_stock_bought;
          tep_db_query("UPDATE " . TABLE_PRODUCTS . "
                        SET products_quantity = products_quantity - '" . $actual_stock_bought . "'
                        WHERE products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
//++++ QT Pro: End Changed Code            
if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
              tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
            }
          }
        }
//++++ QT Pro: Begin Changed code
    }


//**si** 14-11-05 fix missing att list
else {
    if ( is_array($order->products[$i]['attributes']) ) {
      $products_stock_attributes_array = array();
      foreach ($order->products[$i]['attributes'] as $attribute) {
          $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
        }
        asort($products_stock_attributes_array, SORT_NUMERIC);
        $products_stock_attributes = implode(",", $products_stock_attributes_array);
    }
}
//**si** 14-11-05 end



//++++ QT Pro: End Changed Code
// Update products_ordered (for bestsellers list)



voila...


--------------------

MS2 machin truc (thema 3) 6.1.2 Patchée + QTPRO 4.2 + Discount Plus + Fancier Invoice + Master Pasword + Dangling Carrot + Kelkoo + SEO urls + SEO assisstant + diverses contrib
Go to the top of the page
 
Vecto
posté 17 Oct 2006, 09:32
Message #3


Ceinture blanche OSC
Icône de groupe

Groupe : Membres
Messages : 11
Inscrit : 7-October 06
Lieu : 76000
Membre no 12502



Bonjour

J'ai le meme soucis mais j'ai la version Paypal IPN 3.1.5 et Qtpro 4.2.5, du coup je n'ai pas vraiment la meme arborescence de fichiers et je m'y perd un peu.

Si quelqu'un a résolu ce soucis avec ces versions !

Ce message a été modifié par Vecto - 17 Oct 2006, 09:32.
Go to the top of the page
 
Phocea
posté 17 Oct 2006, 14:32
Message #4


Ceinture marron OSC
Icône de groupe

Groupe : Membres
Messages : 1447
Inscrit : 12-March 05
Lieu : Chuiche
Membre no 5120



va voir dans includes/payments/paypal/catalogue/checkout_process.inc.php je crois.

j ai regardé rapidos le prioblèem sane le resoudre mais il me semble que cette contrib bypass le checkout process en utilisant le sien ..faut donc faire les changements apporté par QTpro dans ces fichiers la aussi
Go to the top of the page
 
Vecto
posté 17 Oct 2006, 14:53
Message #5


Ceinture blanche OSC
Icône de groupe

Groupe : Membres
Messages : 11
Inscrit : 7-October 06
Lieu : 76000
Membre no 12502



Merci,

Je vais allez test ca, mais je pensais pas qu'il prenait le dessus avec son propre checkout process mais ca pourrait sans doute expliquer pourquoi ca le fait que avec ce moyen de paiement !

Enfin j'espere, on va voir.
Go to the top of the page
 
Vecto
posté 17 Oct 2006, 17:31
Message #6


Ceinture blanche OSC
Icône de groupe

Groupe : Membres
Messages : 11
Inscrit : 7-October 06
Lieu : 76000
Membre no 12502



Je viens de faire des tests de modifs
mais pas résolu le problème ... sad.gif

Pas de confirmation de paiement du coté admin et pas de mise a jour stock, donc vraiment a coté smile.gif
mais coté client la paiement passe.

Pour info je ne suis pasune star en code.

J'ai fait des modifs dans :

includes/payments/paypal/catalogue/checkout_process.inc.php

et dans includes/payments/paypal/classes/osC/order_class.php

et reprenant des modifs de Xavkick mais sans trop etre sur de ce que je fais ...

Je sais qu'il faut pas faire que demander, mais la j'ai cherché mais ca depasse mes connaissances !

Help me please smile.gif

Simon


Go to the top of the page
 
Vecto
posté 2 Mar 2007, 10:52
Message #7


Ceinture blanche OSC
Icône de groupe

Groupe : Membres
Messages : 11
Inscrit : 7-October 06
Lieu : 76000
Membre no 12502



Salut,

Moi avec le version Paypal V1.2, je n'ai pas de fichier /includes/modules/payment/paypal_ipn.php mais paypal.php

et il n'y pas le code qui doit etre modifier ?

Est ce bien le version 1.2 de paypal ?

Merci
Go to the top of the page
 
lbpf
posté 14 Mar 2007, 15:49
Message #8


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 32
Inscrit : 1-February 07
Membre no 15048



PAYPAL IPN 2.2 ET QTPRO 4.25

Salut a tous

J'ai essaye d'appliquer ces modifs sur IPN 2.2 en suivant la syntaxe (mais sur 2 fichiers differents puisqu'ils sont scindes sur les dernieres versions : ipn.php et paypal_ipn.php).

Le resultat est moyennement satisfaisant car il y a quelques ameliorations.
- Tout comme avant, les commandes sans paypal fonctionnent nickel

Pour les commandes via paypal, certaines choses sont les memes qu'avant :
- l'article n'est toujours pas deduit du stock
- le paiement paypal est valide et bien recu

Par contre il y a quelques changements :
- maintenant, l'email de facturation est envoye au client et a l'admin
- si j'annule la commande en cliquant sur le bouton de restockage, le stock est incremente (je peux donc me retrouver avec un stock superieur a la realite si je ne fais pas attention)

Je m'arrache les cheveux a faire cohabiter ces 2 plug ins, j'ai lu des dizaines de forums. Et la seule compatibilite toruvee a ce jour est IPN 1.x avec QTpro 4.25.
Pour le moment je gere le stock a la main, car je ne veux pas desinstaller IPN pour revenir au module paypal par defaut et risquer de tout casser. L'install d'IPN necessite de modifier beaucoup de changements dans les scripts, alors j'attends impatiemment qu'un pro de la prog nous trouve une solution.
Est ce que l'un d'entre vous aurait une idee ou experience similaire ??

Merci

Kris




--------------------
^_^
K....
Go to the top of the page
 
lbpf
posté 14 Mar 2007, 15:51
Message #9


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 32
Inscrit : 1-February 07
Membre no 15048



CITATION(lbpf @ 14 Mar 2007, 16:49) [snapback]225818[/snapback]
PAYPAL IPN 2.2 ET QTPRO 4.25

Salut a tous

J'ai essaye d'appliquer ces modifs sur IPN 2.2 en suivant la syntaxe (mais sur 2 fichiers differents puisqu'ils sont scindes sur les dernieres versions : ipn.php et paypal_ipn.php).

Le resultat est moyennement satisfaisant car il y a quelques ameliorations.
- Tout comme avant, les commandes sans paypal fonctionnent nickel

Pour les commandes via paypal, certaines choses sont les memes qu'avant :
- l'article n'est toujours pas deduit du stock
- le paiement paypal est valide et bien recu

Par contre il y a quelques changements :
- maintenant, l'email de facturation est envoye au client et a l'admin
- si j'annule la commande en cliquant sur le bouton de restockage, le stock est incremente (je peux donc me retrouver avec un stock superieur a la realite si je ne fais pas attention)

Je m'arrache les cheveux a faire cohabiter ces 2 plug ins, j'ai lu des dizaines de forums. Et la seule compatibilite toruvee a ce jour est IPN 1.x avec QTpro 4.25.
Pour le moment je gere le stock a la main, car je ne veux pas desinstaller IPN pour revenir au module paypal par defaut et risquer de tout casser. L'install d'IPN necessite de modifier beaucoup de changements dans les scripts, alors j'attends impatiemment qu'un pro de la prog nous trouve une solution.
Est ce que l'un d'entre vous aurait une idee ou experience similaire ??

Merci

Kris



sinon y'a une personne sur ce forum http://forums.oscommerce.com/index.php?sho...917&st=2240 qui dit au'il a reussi mais ne dit pas comment... si c'est l'un d'entre vous, je suis la rolleyes.gif


--------------------
^_^
K....
Go to the top of the page
 
brousaille
posté 16 Mar 2007, 12:03
Message #10


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 51
Inscrit : 28-July 06
Membre no 11317



Bon je pense avoir solutionner ce problème,
je fais mes derniers tests et je vous tiens au courant


--------------------
[edit NO_PUB]
Go to the top of the page
 
brousaille
posté 16 Mar 2007, 13:25
Message #11


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 51
Inscrit : 28-July 06
Membre no 11317



Donc premiere chose
Modifier la classe Order, et principalement la function query() car elle ne remonte pas les valeurs et les id des attributs.
CODE
function query($order_id) {
      global $languages_id;

      $order_id = tep_db_prepare_input($order_id);

      $order_query = tep_db_query("select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
      $order = tep_db_fetch_array($order_query);

      $totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order");
      while ($totals = tep_db_fetch_array($totals_query)) {
        $this->totals[] = array('title' => $totals['title'],
                                'text' => $totals['text']);
      }

      $order_total_query = tep_db_query("select text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_total'");
      $order_total = tep_db_fetch_array($order_total_query);

      $shipping_method_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_shipping'");
      $shipping_method = tep_db_fetch_array($shipping_method_query);

      $order_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . $order['orders_status'] . "' and language_id = '" . (int)$languages_id . "'");
      $order_status = tep_db_fetch_array($order_status_query);

      $this->info = array('currency' => $order['currency'],
                          'currency_value' => $order['currency_value'],
                          'payment_method' => $order['payment_method'],
                          'cc_type' => $order['cc_type'],
                          'cc_owner' => $order['cc_owner'],
                          'cc_number' => $order['cc_number'],
                          'cc_expires' => $order['cc_expires'],
                          'date_purchased' => $order['date_purchased'],
                          'orders_status' => $order_status['orders_status_name'],
                          'last_modified' => $order['last_modified'],
                          'total' => strip_tags($order_total['text']),
                          'shipping_method' => ((substr($shipping_method['title'], -1) == ':') ? substr(strip_tags($shipping_method['title']), 0, -1) : strip_tags($shipping_method['title'])));

      $this->customer = array('id' => $order['customers_id'],
                              'name' => $order['customers_name'],
                              'company' => $order['customers_company'],
                              'street_address' => $order['customers_street_address'],
                              'suburb' => $order['customers_suburb'],
                              'city' => $order['customers_city'],
                              'postcode' => $order['customers_postcode'],
                              'state' => $order['customers_state'],
                              'country' => $order['customers_country'],
                              'format_id' => $order['customers_address_format_id'],
                              'telephone' => $order['customers_telephone'],
                              'email_address' => $order['customers_email_address']);

      $this->delivery = array('name' => $order['delivery_name'],
                              'company' => $order['delivery_company'],
                              'street_address' => $order['delivery_street_address'],
                              'suburb' => $order['delivery_suburb'],
                              'city' => $order['delivery_city'],
                              'postcode' => $order['delivery_postcode'],
                              'state' => $order['delivery_state'],
                              'country' => $order['delivery_country'],
                              'format_id' => $order['delivery_address_format_id']);

      if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) {
        $this->delivery = false;
      }

      $this->billing = array('name' => $order['billing_name'],
                             'company' => $order['billing_company'],
                             'street_address' => $order['billing_street_address'],
                             'suburb' => $order['billing_suburb'],
                             'city' => $order['billing_city'],
                             'postcode' => $order['billing_postcode'],
                             'state' => $order['billing_state'],
                             'country' => $order['billing_country'],
                             'format_id' => $order['billing_address_format_id']);

      $index = 0;
      $orders_products_query = tep_db_query("select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
      while ($orders_products = tep_db_fetch_array($orders_products_query)) {
        $this->products[$index] = array('qty' => $orders_products['products_quantity'],
                                    'id' => $orders_products['products_id'],
                                        'name' => $orders_products['products_name'],
                                        'model' => $orders_products['products_model'],
                                        'tax' => $orders_products['products_tax'],
                                        'price' => $orders_products['products_price'],
                                        'final_price' => $orders_products['final_price']);

        $subindex = 0;
        $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");
        
        if (tep_db_num_rows($attributes_query)) {
          while ($attributes = tep_db_fetch_array($attributes_query)) {
                //++++ QT Pro: End Changed Code
             $attributes_query = tep_db_query("select products_options_id,products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . "  where products_options_name = '" . $attributes['products_options'] . "' and language_id=" . (int)$languages_id);
             $singleAttribute = tep_db_fetch_array($attributes_query);    
             $option_id = $singleAttribute["products_options_id"];
             $products_options_track_stock = $singleAttribute["products_options_track_stock"];
            
             $attributes_query = tep_db_query("select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES . "  where products_options_values_name = '" . $attributes['products_options_values'] . "' and language_id=" . (int)$languages_id);
             $singleAttribute = tep_db_fetch_array($attributes_query);
             $option_value_id    = $singleAttribute["products_options_values_id"];                
            //++++ QT Pro: End Changed Code
            $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'],
                                                                     'value' => $attributes['products_options_values'],
                                                                     'prefix' => $attributes['price_prefix'],
                                                                     'option_id' => $option_id,
                                                                     'value_id' => $option_value_id,
                                                                     'price' => $attributes['options_values_price'],
                                                                     'track_stock' => $products_options_track_stock);

            $subindex++;
          }
        }

        $this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1';

        $index++;
      }
    }


Ensuite le fichier ipn.php ( La modification met à jour les stocks ainsi que les points de la contibution POINT AND REWARD)

CODE
<?php
/*
$Id: paypal_ipn.php,v 2.1.0.0 13/01/2007 16:30:21 Edith Karnitsch Exp $

Copyright (c) 2004 osCommerce
Released under the GNU General Public License

Original Authors: Harald Ponce de Leon, Mark Evans
Updates by PandA.nl, Navyhost, Zoeticlight, David, gravyface, AlexStudio, windfjf, Monika in Germany and Terra

*/

chdir('../../../../');
require('includes/application_top.php');
include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS);

$parameters = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
    $parameters .= '&' . $key . '=' . urlencode(stripslashes($value));
}

if (MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER == 'Live') {
    $server = 'www.paypal.com';
} else {
    $server = 'www.sandbox.paypal.com';
}

$fsocket = false;
$curl = false;
$result = false;

if ( (PHP_VERSION >= 4.3) && ($fp = @fsockopen('ssl://' . $server, 443, $errno, $errstr, 30)) ) {
    $fsocket = true;
} elseif (function_exists('curl_exec')) {
    $curl = true;
} elseif ($fp = @fsockopen($server, 80, $errno, $errstr, 30)) {
    $fsocket = true;
}

if ($fsocket == true) {
    $header = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n" .
    'Host: ' . $server . "\r\n" .
    'Content-Type: application/x-www-form-urlencoded' . "\r\n" .
    'Content-Length: ' . strlen($parameters) . "\r\n" .
    'Connection: close' . "\r\n\r\n";

    @fputs($fp, $header . $parameters);

    $string = '';
    while (!@feof($fp)) {
        $res = @fgets($fp, 1024);
        $string .= $res;

        if ( ($res == 'VERIFIED') || ($res == 'INVALID') ) {
            $result = $res;

            break;
        }
    }

    @fclose($fp);
} elseif ($curl == true) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, 'https://' . $server . '/cgi-bin/webscr');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    $result = curl_exec($ch);

    curl_close($ch);
}

if ($result == 'VERIFIED') {
    if (isset($_POST['invoice']) && is_numeric($_POST['invoice']) && ($_POST['invoice'] > 0)) {
        $order_query = tep_db_query("select currency, currency_value from " . TABLE_ORDERS . " where orders_id = '" . $_POST['invoice'] . "' and customers_id = '" . (int)$_POST['custom'] . "'");
        if (tep_db_num_rows($order_query) > 0) {
            $order_db = tep_db_fetch_array($order_query);

            // let's re-create the required arrays
            require(DIR_WS_CLASSES . 'order.php');
            $order = new order($_POST['invoice']);

            require(DIR_WS_CLASSES . 'payment.php');
            $payment_modules = new payment(paypal_ipn);

            // let's update the order status
            $total_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $_POST['invoice'] . "' and class = 'ot_total' limit 1");
            $total = tep_db_fetch_array($total_query);

            $comment_status = $_POST['payment_status'] . ' (' . ucfirst($_POST['payer_status']) . '; ' . $currencies->format($_POST['mc_gross'], false, $_POST['mc_currency']) . ')';

            if ($_POST['payment_status'] == 'Pending') {
                $comment_status .= '; ' . $_POST['pending_reason'];
            } elseif ( ($_POST['payment_status'] == 'Reversed') || ($_POST['payment_status'] == 'Refunded') ) {
                $comment_status .= '; ' . $_POST['reason_code'];
            } elseif ( ($_POST['payment_status'] == 'Completed') && (MODULE_PAYMENT_PAYPAL_IPN_SHIPPING == 'True') ) {
                $comment_status .= ", \n" . PAYPAL_ADDRESS . ": " . $_POST['address_name'] . ", " . $_POST['address_street'] . ", " . $_POST['address_city'] . ", " . $_POST['address_zip'] . ", " . $_POST['address_state'] . ", " . $_POST['address_country'] . ", " . $_POST['address_country_code'] . ", " . $_POST['address_status'];
            }

            $order_status_id = DEFAULT_ORDERS_STATUS_ID;

            // modified AlexStudio's Rounding error bug fix
            // variances of up to 0.05 on either side (plus / minus) are ignored
            if (
            (((number_format($total['value'] * $order_db['currency_value'], $currencies->get_decimal_places($order_db['currency']))) -  $_POST['mc_gross']) <= 0.05)
            &&
            (((number_format($total['value'] * $order_db['currency_value'], $currencies->get_decimal_places($order_db['currency']))) -  $_POST['mc_gross']) >= -0.05)
            ) {

                // previous validation
                //        if ($_POST['mc_gross'] == number_format($total['value'] * $order_db['currency_value'], $currencies->get_decimal_places($order_db['currency']))) {

                // Terra -> modified update. If payment status is "completed" than a completed order status is chosen based on the admin settings
                if ( (MODULE_PAYMENT_PAYPAL_IPN_COMP_ORDER_STATUS_ID > 0) && ($_POST['payment_status'] == 'Completed') ) {
                    $order_status_id = MODULE_PAYMENT_PAYPAL_IPN_COMP_ORDER_STATUS_ID;
                } elseif (MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID > 0) {
                    $order_status_id = MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID;
                }

            }

            // Let's see what the PayPal payment status is and set the notification accordingly
            // more info: https://www.paypal.com/IntegrationCenter/ic_ipn-pdt-variable-reference.html
            if ( ($_POST['payment_status'] == 'Pending') || ($_POST['payment_status'] == 'Completed')) {
                $customer_notified = '1';
            } else {
                $customer_notified = '0';
            }


            tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . $order_status_id . "', last_modified = now() where orders_id = '" . $_POST['invoice'] . "'");

            $sql_data_array = array('orders_id' => $_POST['invoice'],
            'orders_status_id' => $order_status_id,
            'date_added' => 'now()',
            'customer_notified' => $customer_notified,
            'comments' => 'PayPal IPN Verified [' . $comment_status . ']');

            tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

            // If the order is pending, then we want to send a notification email to the customer




            // If the order is completed, then we want to send the order email and update the stock
            if ($_POST['payment_status'] == 'Completed') { // START STATUS == COMPLETED LOOP

                // initialized for the email confirmation
                $products_ordered = '';
                $total_tax = 0;

                #### Points/Rewards Module V2.00 balance customer points BOF ####
                                
                //**********************************************************
                if ((USE_POINTS_SYSTEM == 'true') && (USE_REDEEM_SYSTEM == 'true')) {
                    // customer pending points added
                    if (($order->info['total'] > 0) && (get_award_discounted($order) == true)) {

                        
                        $points_toadd = get_points_toadd($order);
                        

                        $points_comment = 'TEXT_DEFAULT_COMMENT';
                        $points_type = 'SP';
                        if ((get_redemption_awards($customer_shopping_points_spending) == true) && ($points_toadd >0)) {
                            tep_add_pending_points((int)$_POST['custom'], $_POST['invoice'], $points_toadd, $points_comment, $points_type);
                        }
                    }

                    // customer shoppping points account balanced
                    if ($customer_shopping_points_spending) {
                        tep_redeemed_points((int)$_POST['custom'], $_POST['invoice'], $customer_shopping_points_spending);
                    }
                }
                #### Points/Rewards Module V2.00 balance customer points EOF ####*/

                // let's update the stock
                #######################################################
                for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { // PRODUCT LOOP STARTS HERE

                    // Stock Update - Joao Correia
                    //++++ QT Pro: Begin Changed code
                    $products_stock_attributes=null;
                    if (STOCK_LIMITED == 'true') {
                        $products_attributes = $order->products[$i]['attributes'];
                        //      if (DOWNLOAD_ENABLED == 'true') {
                        //++++ QT Pro: End Changed Code
                        $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename
                            FROM " . TABLE_PRODUCTS . " p
                            LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                             ON p.products_id=pa.products_id
                            LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                             ON pa.products_attributes_id=pad.products_attributes_id
                            WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";

                        // Will work with only one option for downloadable products
                        // otherwise, we have to build the query dynamically with a loop
                        //++++ QT Pro: Begin Changed code
                        //      $products_attributes = $order->products[$i]['attributes'];
                        //++++ QT Pro: End Changed Code
                        if (is_array($products_attributes)) {
                            $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
                        }
                        $stock_query = tep_db_query($stock_query_raw);

                        if (tep_db_num_rows($stock_query) > 0) {

                            $stock_values = tep_db_fetch_array($stock_query);

                            //++++ QT Pro: Begin Changed code
                            $actual_stock_bought = $order->products[$i]['qty'];
                            $download_selected = false;
                            if ((DOWNLOAD_ENABLED == 'true') && isset($stock_values['products_attributes_filename']) && tep_not_null($stock_values['products_attributes_filename'])) {
                                $download_selected = true;
                                $products_stock_attributes='$$DOWNLOAD$$';
                            }
                            //      If not downloadable and attributes present, adjust attribute stock
                            if (!$download_selected && is_array($products_attributes)) {
                                $all_nonstocked = true;
                                $products_stock_attributes_array = array();
                                foreach ($products_attributes as $attribute) {

                                    //**si** 14-11-05 fix missing att list
                                    //            if ($attribute['track_stock'] == 1) {
                                    //              $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
                                    $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
                                    if ($attribute['track_stock'] == 1) {
                                        //**si** 14-11-05 end

                                        $all_nonstocked = false;
                                    }
                                }
                                if ($all_nonstocked) {
                                    $actual_stock_bought = $order->products[$i]['qty'];

                                    //**si** 14-11-05 fix missing att list
                                    asort($products_stock_attributes_array, SORT_NUMERIC);
                                    $products_stock_attributes = implode(",", $products_stock_attributes_array);
                                    //**si** 14-11-05 end

                                }  else {
                                    asort($products_stock_attributes_array, SORT_NUMERIC);
                                    $products_stock_attributes = implode(",", $products_stock_attributes_array);
                                    $attributes_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
                                    if (tep_db_num_rows($attributes_stock_query) > 0) {
                                        $attributes_stock_values = tep_db_fetch_array($attributes_stock_query);
                                        $attributes_stock_left = $attributes_stock_values['products_stock_quantity'] - $order->products[$i]['qty'];
                                        tep_db_query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity = '" . $attributes_stock_left . "' where products_stock_attributes = '$products_stock_attributes' AND products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
                                        $actual_stock_bought = ($attributes_stock_left < 1) ? $attributes_stock_values['products_stock_quantity'] : $order->products[$i]['qty'];
                                    } else {
                                        $attributes_stock_left = 0 - $order->products[$i]['qty'];
                                        tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " (products_id, products_stock_attributes, products_stock_quantity) values ('" . tep_get_prid($order->products[$i]['id']) . "', '" . $products_stock_attributes . "', '" . $attributes_stock_left . "')");
                                        $actual_stock_bought = 0;
                                    }
                                }
                            }
                            //        $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
                            //      }
                            //      if (tep_db_num_rows($stock_query) > 0) {
                            //        $stock_values = tep_db_fetch_array($stock_query);
                            // do not decrement quantities if products_attributes_filename exists
                            if (!$download_selected) {

                                $stock_left = $stock_values['products_quantity'] - $actual_stock_bought;
                                tep_db_query("UPDATE " . TABLE_PRODUCTS . "
                                                SET products_quantity = products_quantity - '" . $actual_stock_bought . "'
                                                WHERE products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
                                //++++ QT Pro: End Changed Code
                                if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
                                    tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
                                }
                            }
                        }
                        //++++ QT Pro: Begin Changed code
                    }


                    //**si** 14-11-05 fix missing att list
                    else {
                        if ( is_array($order->products[$i]['attributes']) ) {
                            $products_stock_attributes_array = array();
                            foreach ($order->products[$i]['attributes'] as $attribute) {
                                $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
                            }
                            asort($products_stock_attributes_array, SORT_NUMERIC);
                            $products_stock_attributes = implode(",", $products_stock_attributes_array);
                        }
                    }
                    //**si** 14-11-05 end

                    //++++ QT Pro: End Changed Code
                    // Update products_ordered (for bestsellers list)

                    // Update products_ordered (for bestsellers list)
                    tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");



                    // Let's get all the info together for the email
                    $total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);
                    $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
                    $total_cost += $total_products_price;

                    // Let's get the attributes
                    $products_ordered_attributes = '';
                    if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
                        for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
                            $products_ordered_attributes .= "\n\t" . $order->products[$i]['attributes'][$j]['option'] . ' ' . $order->products[$i]['attributes'][$j]['value'];
                        }
                    }

                    // Let's format the products model
                    $products_model = '';
                    if ( !empty($order->products[$i]['model']) ) {
                        $products_model = ' (' . $order->products[$i]['model'] . ')';
                    }

                    // Let's put all the product info together into a string
                    $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . $products_model . ' = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";


                }        // PRODUCT LOOP ENDS HERE
                #######################################################


                // lets start with the email confirmation
                // $order variables have been changed from checkout_process to work with the variables from the function query () instead of cart () in the order class
                $email_order = STORE_NAME . "\n" .
                EMAIL_SEPARATOR . "\n" .
                EMAIL_TEXT_ORDER_NUMBER . ' ' . $_POST['invoice'] . "\n" .
                EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $_POST['invoice'], 'SSL', false) . "\n" .
                EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
                if ($order->info['comments']) {
                    $email_order .= tep_db_output($order->info['comments']) . "\n\n";
                }
                $email_order .= EMAIL_TEXT_PRODUCTS . "\n" .
                EMAIL_SEPARATOR . "\n" .
                $products_ordered .
                EMAIL_SEPARATOR . "\n";

                for ($i=0, $n=sizeof($order->totals); $i<$n; $i++) {
                    $email_order .= strip_tags($order->totals[$i]['title']) . ' ' . strip_tags($order->totals[$i]['text']) . "\n";
                }

                if ($order->content_type != 'virtual') {
                    $email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" .
                    EMAIL_SEPARATOR . "\n" .
                    tep_address_format($order->delivery['format_id'], $order->delivery,  0, '', "\n") . "\n";
                }

                $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" .
                EMAIL_SEPARATOR . "\n" .
                tep_address_format($order->billing['format_id'], $order->billing, 0, '', "\n") . "\n\n";
                if (is_object($$payment)) {
                    $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" .
                    EMAIL_SEPARATOR . "\n";
                    $payment_class = $$payment;
                    $email_order .= $payment_class->title . "\n\n";
                    if ($payment_class->email_footer) {
                        $email_order .= $payment_class->email_footer . "\n\n";
                    }
                }
                tep_mail($order->customer['name'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);


                // send emails to other people
                if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
                    tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
                }

                //emptying cart for everyone! by Monika in Germany
                tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$_POST['custom'] . "'");
                tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$_POST['custom'] . "'");
                //end emptying cart for everyone


            } // END STATUS == COMPLETED LOOP

            if ($_POST['payment_status'] == 'Pending') { // START STATUS == PENDING LOOP

                $email_order = STORE_NAME . "\n" .
                EMAIL_SEPARATOR . "\n" .
                EMAIL_TEXT_ORDER_NUMBER . ' ' . $_POST['invoice'] . "\n" .
                EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $_POST['invoice'], 'SSL', false) . "\n" .
                EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n" .
                EMAIL_SEPARATOR . "\n" .
                EMAIL_PAYPAL_PENDING_NOTICE . "\n\n";

                tep_mail($order->customer['name'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);


                // send emails to other people
                if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
                    tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
                }
            }
            // END STATUS == PENDING LOOP

        }
    }
} else {
    if (tep_not_null(MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL)) {
        $email_body = '$_POST:' . "\n\n";
        foreach ($_POST as $key => $value) {
            $email_body .= $key . '=' . $value . "\n";
        }
        $email_body .= "\n" . '$_GET:' . "\n\n";
        foreach ($_GET as $key => $value) {
            $email_body .= $key . '=' . $value . "\n";
        }

        tep_mail('', MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL, 'PayPal IPN Invalid Process', $email_body, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
    }

    if (isset($_POST['invoice']) && is_numeric($_POST['invoice']) && ($_POST['invoice'] > 0)) {
        $check_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . $_POST['invoice'] . "' and customers_id = '" . (int)$_POST['custom'] . "'");
        if (tep_db_num_rows($check_query) > 0) {
            $comment_status = $_POST['payment_status'];

            if ($_POST['payment_status'] == 'Pending') {
                $comment_status .= '; ' . $_POST['pending_reason'];
            } elseif ( ($_POST['payment_status'] == 'Reversed') || ($_POST['payment_status'] == 'Refunded') ) {
                $comment_status .= '; ' . $_POST['reason_code'];
            }

            tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . ((MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID > 0) ? MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID : DEFAULT_ORDERS_STATUS_ID) . "', last_modified = now() where orders_id = '" . $_POST['invoice'] . "'");

            $sql_data_array = array('orders_id' => $_POST['invoice'],
            'orders_status_id' => (MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID > 0) ? MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID : DEFAULT_ORDERS_STATUS_ID,
            'date_added' => 'now()',
            'customer_notified' => '0',
            'comments' => 'PayPal IPN Invalid [' . $comment_status . ']');

            tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
        }
    }
}

require('includes/application_bottom.php');
?>





--------------------
[edit NO_PUB]
Go to the top of the page
 
brousaille
posté 16 Mar 2007, 13:27
Message #12


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 51
Inscrit : 28-July 06
Membre no 11317



Et enfin le fichier paypal_ipn.php

CODE
<?php
/*
  $Id: paypal_ipn.php,v 2.1.0.0 13/01/2007 16:30:28 Edith Karnitsch Exp $

  Copyright (c) 2004 osCommerce
  Released under the GNU General Public License
  
  Original Authors: Harald Ponce de Leon, Mark Evans
  Updates by PandA.nl, Navyhost, Zoeticlight, David, gravyface, AlexStudio, windfjf and Terra
    
*/

  class paypal_ipn {
    var $code, $title, $description, $enabled, $identifier;

// class constructor
    function paypal_ipn() {
      global $order;

      $this->code = 'paypal_ipn';
      $this->title = MODULE_PAYMENT_PAYPAL_IPN_TEXT_TITLE;
      $this->description = MODULE_PAYMENT_PAYPAL_IPN_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_PAYMENT_PAYPAL_IPN_SORT_ORDER;
      $this->enabled = ((MODULE_PAYMENT_PAYPAL_IPN_STATUS == 'True') ? true : false);
      $this->email_footer = MODULE_PAYMENT_PAYPAL_IPN_TEXT_EMAIL_FOOTER;
      $this->identifier = 'osCommerce PayPal IPN v2.1';

      if ((int)MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID > 0) {
        $this->order_status = MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID;
      }

      if (is_object($order)) $this->update_status();

      if (MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER == 'Live') {
        $this->form_action_url = 'https://www.paypal.com/cgi-bin/webscr';
      } else {
        $this->form_action_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
      }
    }

// class methods
    function update_status() {
      global $order;

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_IPN_ZONE > 0) ) {
        $check_flag = false;
        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYPAL_IPN_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
        while ($check = tep_db_fetch_array($check_query)) {
          if ($check['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check['zone_id'] == $order->billing['zone_id']) {
            $check_flag = true;
            break;
          }
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }
    }

    function javascript_validation() {
      return false;
    }

    function selection() {
      return array('id' => $this->code,
                   'module' => $this->title);
    }

    function pre_confirmation_check() {
      return false;
    }

    function confirmation() {
      global $cartID, $cart_PayPal_IPN_ID, $customer_id, $languages_id, $order, $order_total_modules;

     // if (tep_session_is_registered('cartID')) {
     // PandA.nl: register_globals fix
     if (array_key_exists('cartID', $_SESSION)) {
        $insert_order = false;

        if (tep_session_is_registered('cart_PayPal_IPN_ID')) {
          $order_id = substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-')+1);

          $curr_check = tep_db_query("select currency from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
          $curr = tep_db_fetch_array($curr_check);

           //if ( ($curr['currency'] != $order->info['currency']) || ($cartID != substr($cart_PayPal_IPN_ID, 0, strlen($cartID))) ) {
            //$check_query = tep_db_query('select orders_id from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int)$order_id . '" limit 1');
            $check_query = tep_db_query('select orders_id from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int)$order_id . '" limit 2');  //1.4

            $update_order = false;//1.4
            
            //if (tep_db_num_rows($check_query) < 1) {
              //tep_db_query('delete from ' . TABLE_ORDERS . ' where orders_id = "' . (int)$order_id . '"');
            if (tep_db_num_rows($check_query) == 1) { //1.4
              $update_order = true; //1.4
              tep_db_query('delete from ' . TABLE_ORDERS_TOTAL . ' where orders_id = "' . (int)$order_id . '"');
              tep_db_query('delete from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int)$order_id . '"');
              tep_db_query('delete from ' . TABLE_ORDERS_PRODUCTS . ' where orders_id = "' . (int)$order_id . '"');
              tep_db_query('delete from ' . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . ' where orders_id = "' . (int)$order_id . '"');
              tep_db_query('delete from ' . TABLE_ORDERS_PRODUCTS_DOWNLOAD . ' where orders_id = "' . (int)$order_id . '"');
            }

            $insert_order = true;
          //}    
        } else {
          $insert_order = true;
        }

        if ($insert_order == true) {
          $order_totals = array();
          if (is_array($order_total_modules->modules)) {
            reset($order_total_modules->modules);
            while (list(, $value) = each($order_total_modules->modules)) {
              $class = substr($value, 0, strrpos($value, '.'));
              if ($GLOBALS[$class]->enabled) {
                for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {
                  if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {
                    $order_totals[] = array('code' => $GLOBALS[$class]->code,
                                            'title' => $GLOBALS[$class]->output[$i]['title'],
                                            'text' => $GLOBALS[$class]->output[$i]['text'],
                                            'value' => $GLOBALS[$class]->output[$i]['value'],
                                            'sort_order' => $GLOBALS[$class]->sort_order);
                  }
                }
              }
            }
          }

          $sql_data_array = array('customers_id' => $customer_id,
                                  'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'],
                                  'customers_company' => $order->customer['company'],
                                  'customers_street_address' => $order->customer['street_address'],
                                  'customers_suburb' => $order->customer['suburb'],
                                  'customers_city' => $order->customer['city'],
                                  'customers_postcode' => $order->customer['postcode'],
                                  'customers_state' => $order->customer['state'],
                                  'customers_country' => $order->customer['country']['title'],
                                  'customers_telephone' => $order->customer['telephone'],
                                  'customers_email_address' => $order->customer['email_address'],
                                  'customers_address_format_id' => $order->customer['format_id'],
                                  'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],
                                  'delivery_company' => $order->delivery['company'],
                                  'delivery_street_address' => $order->delivery['street_address'],
                                  'delivery_suburb' => $order->delivery['suburb'],
                                  'delivery_city' => $order->delivery['city'],
                                  'delivery_postcode' => $order->delivery['postcode'],
                                  'delivery_state' => $order->delivery['state'],
                                  'delivery_country' => $order->delivery['country']['title'],
                                  'delivery_address_format_id' => $order->delivery['format_id'],
                                  'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'],
                                  'billing_company' => $order->billing['company'],
                                  'billing_street_address' => $order->billing['street_address'],
                                  'billing_suburb' => $order->billing['suburb'],
                                  'billing_city' => $order->billing['city'],
                                  'billing_postcode' => $order->billing['postcode'],
                                  'billing_state' => $order->billing['state'],
                                  'billing_country' => $order->billing['country']['title'],
                                  'billing_address_format_id' => $order->billing['format_id'],
                                  'payment_method' => $order->info['payment_method'],
                                  'cc_type' => $order->info['cc_type'],
                                  'cc_owner' => $order->info['cc_owner'],
                                  'cc_number' => $order->info['cc_number'],
                                  'cc_expires' => $order->info['cc_expires'],
                                  'date_purchased' => 'now()',
                                  'orders_status' => $order->info['order_status'],
                                  'currency' => $order->info['currency'],
                                  'currency_value' => $order->info['currency_value']);

          //+1.4
          if ( $update_order ){  
            tep_db_perform(TABLE_ORDERS, $sql_data_array, 'update', 'orders_id = "' . (int)$order_id . '"');
            $insert_id = (int)$order_id;
          } else {
          //-1.4
          tep_db_perform(TABLE_ORDERS, $sql_data_array);

          $insert_id = tep_db_insert_id();
          }//1.4

          for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
            $sql_data_array = array('orders_id' => $insert_id,
                                    'title' => $order_totals[$i]['title'],
                                    'text' => $order_totals[$i]['text'],
                                    'value' => $order_totals[$i]['value'],
                                    'class' => $order_totals[$i]['code'],
                                    'sort_order' => $order_totals[$i]['sort_order']);

            tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
          }
          //+1.4
          $sql_data_array = array('orders_id' => $insert_id,
                                    'orders_status_id' => $order->info['order_status'],
                                    'date_added' => 'now()',
                         'customer_notified' => '0',
                                    'comments' => $order->info['comments']);
          tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
          //-1.4

          /*for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
            $sql_data_array = array('orders_id' => $insert_id,
                                    'products_id' => tep_get_prid($order->products[$i]['id']),
                                    'products_model' => $order->products[$i]['model'],
                                    'products_name' => $order->products[$i]['name'],
                                    'products_price' => $order->products[$i]['price'],
                                    'final_price' => $order->products[$i]['final_price'],
                                    'products_tax' => $order->products[$i]['tax'],
                                    'products_quantity' => $order->products[$i]['qty']);*/
            //++++ QT Pro: Begin Changed code
              for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
                $products_stock_attributes=null;
                if (STOCK_LIMITED == 'true') {
                  $products_attributes = $order->products[$i]['attributes'];
            
                  $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename
                                      FROM " . TABLE_PRODUCTS . " p
                                      LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                       ON p.products_id=pa.products_id
                                      LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                                       ON pa.products_attributes_id=pad.products_attributes_id
                                      WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";
            
                                      
                  if (is_array($products_attributes)) {
                    $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
                  }
                  $stock_query = tep_db_query($stock_query_raw);
                  if (tep_db_num_rows($stock_query) > 0) {
                    $stock_values = tep_db_fetch_array($stock_query);
            
                     $actual_stock_bought = $order->products[$i]['qty'];
                    $download_selected = false;
                    if ((DOWNLOAD_ENABLED == 'true') && isset($stock_values['products_attributes_filename']) && tep_not_null($stock_values['products_attributes_filename'])) {
                      $download_selected = true;
                      $products_stock_attributes='$$DOWNLOAD$$';
                    }
            //      If not downloadable and attributes present, adjust attribute stock
                    if (!$download_selected && is_array($products_attributes)) {
                      $all_nonstocked = true;
                      $products_stock_attributes_array = array();
                      foreach ($products_attributes as $attribute) {
                        $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
                        
                        asort($products_stock_attributes_array, SORT_NUMERIC);
                        $products_stock_attributes = implode(",", $products_stock_attributes_array);
                        }
                    }
                }
            } else {
                if ( is_array($order->products[$i]['attributes']) ) {
                  $products_stock_attributes_array = array();
                  foreach ($order->products[$i]['attributes'] as $attribute) {
                      $products_stock_attributes_array[] = $attribute['option_id'] . "-" . $attribute['value_id'];
                    }
                    asort($products_stock_attributes_array, SORT_NUMERIC);
                    $products_stock_attributes = implode(",", $products_stock_attributes_array);
                }
            }    
            
                        if (!isset($products_stock_attributes)) $products_stock_attributes=null;  
                          $sql_data_array = array('orders_id' => $insert_id,
                                                'products_id' => tep_get_prid($order->products[$i]['id']),
                                                'products_model' => $order->products[$i]['model'],
                                                'products_name' => $order->products[$i]['name'],
                                                'products_price' => $order->products[$i]['price'],
                                                'final_price' => $order->products[$i]['final_price'],
                                                'products_tax' => $order->products[$i]['tax'],
                                                'products_quantity' => $order->products[$i]['qty'],
                                                'products_stock_attributes' => $products_stock_attributes);
            //++++ QT Pro: End Changed Code
            tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);

            $order_products_id = tep_db_insert_id();

            $attributes_exist = '0';
            if (isset($order->products[$i]['attributes'])) {
              $attributes_exist = '1';
              for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
                if (DOWNLOAD_ENABLED == 'true') {
                  $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename
                                       from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                       left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                                       on pa.products_attributes_id=pad.products_attributes_id
                                       where pa.products_id = '" . $order->products[$i]['id'] . "'
                                       and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'
                                       and pa.options_id = popt.products_options_id
                                       and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'
                                       and pa.options_values_id = poval.products_options_values_id
                                       and popt.language_id = '" . $languages_id . "'
                                       and poval.language_id = '" . $languages_id . "'";
                  $attributes = tep_db_query($attributes_query);
                } else {
                  $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
                }
                $attributes_values = tep_db_fetch_array($attributes);

                $sql_data_array = array('orders_id' => $insert_id,
                                        'orders_products_id' => $order_products_id,
                                        'products_options' => $attributes_values['products_options_name'],
                                        'products_options_values' => $attributes_values['products_options_values_name'],
                                        'options_values_price' => $attributes_values['options_values_price'],
                                        'price_prefix' => $attributes_values['price_prefix']);

                tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

                if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
                  $sql_data_array = array('orders_id' => $insert_id,
                                          'orders_products_id' => $order_products_id,
                                          'orders_products_filename' => $attributes_values['products_attributes_filename'],
                                          'download_maxdays' => $attributes_values['products_attributes_maxdays'],
                                          'download_count' => $attributes_values['products_attributes_maxcount']);

                  tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
                }
              }
            }
          }

          tep_session_register('cart_PayPal_IPN_ID');
          // Terra register globals fix
          $_SESSION['cart_PayPal_IPN_ID'] = $cartID . '-' . $insert_id;
        }
      }

      return false;
    }

    function process_button() {
      global $customer_id, $order, $languages_id, $currencies, $currency, $cart_PayPal_IPN_ID, $shipping;

      if (MODULE_PAYMENT_PAYPAL_IPN_CURRENCY == 'Selected Currency') {
        $my_currency = $currency;
      } else {
        $my_currency = substr(MODULE_PAYMENT_PAYPAL_IPN_CURRENCY, 5);
      }
      
      if (!in_array($my_currency, array('AUD', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'JPY', 'NOK', 'NZD', 'PLN', 'SEK', 'SGD', 'USD'))) {
        $my_currency = 'USD';
      }
      
      $parameters = array();

      if ( (MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE == 'Per Item') && (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'False') ) {
        $parameters['cmd'] = '_cart';
        $parameters['upload'] = '1';

        for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
          $item = $i+1;

          $tax_value = ($order->products[$i]['tax'] / 100) * $order->products[$i]['final_price'];

          $parameters['item_name_' . $item] = $order->products[$i]['name'];
          $parameters['amount_' . $item] = number_format($order->products[$i]['final_price'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
          $parameters['tax_' . $item] = number_format($tax_value * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
          $parameters['quantity_' . $item] = $order->products[$i]['qty'];

          if ($i == 0) {
            if (DISPLAY_PRICE_WITH_TAX == 'true') {
              $shipping_cost = $order->info['shipping_cost'];
            } else {
              $module = substr($shipping['id'], 0, strpos($shipping['id'], '_'));
              $shipping_tax = tep_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
              $shipping_cost = $order->info['shipping_cost'] + tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);
            }

            $parameters['shipping_' . $item] = number_format($shipping_cost * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
          }

          if (isset($order->products[$i]['attributes'])) {
            for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
              if (DOWNLOAD_ENABLED == 'true') {
                $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                                     on pa.products_attributes_id=pad.products_attributes_id
                                     where pa.products_id = '" . $order->products[$i]['id'] . "'
                                     and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'
                                     and pa.options_id = popt.products_options_id
                                     and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'
                                     and pa.options_values_id = poval.products_options_values_id
                                     and popt.language_id = '" . $languages_id . "'
                                     and poval.language_id = '" . $languages_id . "'";
                $attributes = tep_db_query($attributes_query);
              } else {
                $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
              }
              $attributes_values = tep_db_fetch_array($attributes);

// Unfortunately PayPal only accepts two attributes per product, so the
// third attribute onwards will not be shown at PayPal
              $parameters['on' . $j . '_' . $item] = $attributes_values['products_options_name'];
              $parameters['os' . $j . '_' . $item] = $attributes_values['products_options_values_name'];
            }
          }
        }

        $parameters['num_cart_items'] = $item;
        
              if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
           // PandA.nl move tax to total amount
           $parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
           } else {
           // default
          $parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
      }
        
      } else {
        $parameters['cmd'] = '_ext-enter';
        $parameters['redirect_cmd'] = '_xclick';
        $parameters['item_name'] = STORE_NAME;
        $parameters['shipping'] = '0';
      if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
           // PandA.nl move tax to total amount
           $parameters['amount'] = number_format($order->info['total'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
           } else {
           // default
          $parameters['amount'] = number_format(($order->info['total'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
      }
       }
      
       // billing information fix by gravyface
       // for pre-populating the fiels if customer has no PayPal account
       // only works if force shipping address is set to FALSE
      $state_abbr = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], $order->delivery['state']);
      $name = $order->delivery['firstname'] . ' ' . $order->delivery['lastname'];

      $parameters['business'] = MODULE_PAYMENT_PAYPAL_IPN_ID;
      
      // let's check what has been defined in the shop admin for the shipping address
      if (MODULE_PAYMENT_PAYPAL_IPN_SHIPPING == 'True') {
      // all that matters is that we send the variables
      // what they contain is irrelevant as PayPal overwrites it with the customer's confirmed PayPal address
      // so what we send is probably not what we'll get back
      $parameters['no_shipping'] = '2';  
      $parameters['address_name']         = $name;
      $parameters['address_street']     = $order->delivery['street_address'];
      $parameters['address_city']         = $order->delivery['city'];
      $parameters['address_zip']         = $order->delivery['postcode'];
      $parameters['address_state']         = $state_abbr;
      $parameters['address_country_code']    = $order->delivery['country']['iso_code_2'];
      $parameters['address_country']    = $order->delivery['country']['title'];
      $parameters['payer_email']         = $order->customer['email_address'];          
     } else {      
      $parameters['no_shipping'] = '1';
      $parameters['H_PhoneNumber']           = $order->customer['telephone'];      
      $parameters['first_name']         = $order->delivery['firstname'];
      $parameters['last_name']         = $order->delivery['lastname'];        
      $parameters['address1']         = $order->delivery['street_address'];
      $parameters['address2']         = $order->delivery['suburb'];
      $parameters['city']             = $order->delivery['city'];
      $parameters['zip']             = $order->delivery['postcode'];
      $parameters['state']             = $state_abbr;
      $parameters['country']             = $order->delivery['country']['iso_code_2'];
      $parameters['email']             = $order->customer['email_address'];  
          }      
      
      $parameters['currency_code'] = $my_currency;
      $parameters['invoice'] = substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-')+1);
      $parameters['custom'] = $customer_id;
      $parameters['no_note'] = '1';
      $parameters['notify_url'] = tep_href_link('ext/modules/payment/paypal_ipn/ipn.php', '', 'SSL', false, false);
      $parameters['cbt'] = CONFIRMATION_BUTTON_TEXT;  
      $parameters['return'] = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
      $parameters['cancel_return'] = tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL');
      $parameters['bn'] = $this->identifier;
      $parameters['lc'] = $order->customer['country']['iso_code_2'];
      

      if (tep_not_null(MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE)) {
        $parameters['page_style'] = MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE;
      }

      if (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'True') {
        $parameters['cert_id'] = MODULE_PAYMENT_PAYPAL_IPN_EWP_CERT_ID;

        $random_string = rand(100000, 999999) . '-' . $customer_id . '-';

        $data = '';
        while (list($key, $value) = each($parameters)) {
          $data .= $key . '=' . $value . "\n";
        }

        $fp = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt', 'w');
        fwrite($fp, $data);
        fclose($fp);

        unset($data);

        if (function_exists('openssl_pkcs7_sign') && function_exists('openssl_pkcs7_encrypt')) {
          openssl_pkcs7_sign(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt', MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY), file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY), array('From' => MODULE_PAYMENT_PAYPAL_IPN_ID), PKCS7_BINARY);

          unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt');

// remove headers from the signature
          $signed = file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');
          $signed = explode("\n\n", $signed);
          $signed = base64_decode($signed[1]);

          $fp = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', 'w');
          fwrite($fp, $signed);
          fclose($fp);

          unset($signed);

          openssl_pkcs7_encrypt(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt', file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY), array('From' => MODULE_PAYMENT_PAYPAL_IPN_ID), PKCS7_BINARY);

          unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');

// remove headers from the encrypted result
          $data = file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');
          $data = explode("\n\n", $data);
          $data = '-----BEGIN PKCS7-----' . "\n" . $data[1] . "\n" . '-----END PKCS7-----';

          unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');
        } else {
          exec(MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL . ' smime -sign -in ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt -signer ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY . ' -inkey ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY . ' -outform der -nodetach -binary > ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');
          unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt');

          exec(MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL . ' smime -encrypt -des3 -binary -outform pem ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY . ' < ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt > ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');
          unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');

          $fh = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt', 'rb');
          $data = fread($fh, filesize(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt'));
          fclose($fh);

          unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');
        }

        $process_button_string = tep_draw_hidden_field('cmd', '_s-xclick') .
                                 tep_draw_hidden_field('encrypted', $data);

        unset($data);
      } else {
        while (list($key, $value) = each($parameters)) {
          echo tep_draw_hidden_field($key, $value);
        }
      }

      return $process_button_string;
    }

    function before_process() {
      global $cart;

      $cart->reset(true);

// unregister session variables used during checkout
      tep_session_unregister('sendto');
      tep_session_unregister('billto');
      tep_session_unregister('shipping');
      tep_session_unregister('payment');
      tep_session_unregister('comments');

      tep_session_unregister('cart_PayPal_IPN_ID');

      tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));
    }

    function after_process() {
      return false;
    }

    function output_error() {
      return false;
    }

    function check() {
      if (!isset($this->_check)) {
        $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYPAL_IPN_STATUS'");
        $this->_check = tep_db_num_rows($check_query);
      }
      return $this->_check;
    }

    function install() {
      $check_query = tep_db_query("select orders_status_id from " . TABLE_ORDERS_STATUS . " where orders_status_name = 'Preparing [PayPal IPN]' limit 1");

      if (tep_db_num_rows($check_query) < 1) {
        $status_query = tep_db_query("select max(orders_status_id) as status_id from " . TABLE_ORDERS_STATUS);
        $status = tep_db_fetch_array($status_query);

        $status_id = $status['status_id']+1;

        $languages = tep_get_languages();

        foreach ($languages as $lang) {
          tep_db_query("insert into " . TABLE_ORDERS_STATUS . " (orders_status_id, language_id, orders_status_name) values ('" . $status_id . "', '" . $lang['id'] . "', 'Preparing [PayPal IPN]')");
        }
      } else {
        $check = tep_db_fetch_array($check_query);

        $status_id = $check['orders_status_id'];
      }

      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable PayPal IPN Module', 'MODULE_PAYMENT_PAYPAL_IPN_STATUS', 'False', 'Do you want to accept PayPal IPN payments?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
            tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Gateway Server', 'MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER', 'Testing', 'Use the testing (sandbox) or live gateway server for transactions?', '6', '2', 'tep_cfg_select_option(array(\'Testing\',\'Live\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_PAYPAL_IPN_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '3', now())");            
            tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Force shipping address?', 'MODULE_PAYMENT_PAYPAL_IPN_SHIPPING', 'False', 'If TRUE the address details for the PayPal Seller Protection Policy are sent but customers without a PayPal account must re-enter their details. If set to FALSE order is not eligible for Seller Protection but customers without acount will have their address fiels pre-populated.', '6', '4', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('E-Mail Address', 'MODULE_PAYMENT_PAYPAL_IPN_ID', '', 'The e-mail address to use for the PayPal IPN service', '6', '5', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Currency', 'MODULE_PAYMENT_PAYPAL_IPN_CURRENCY', 'Selected Currency', 'The currency to use for transactions', '6', '10', 'tep_cfg_select_option(array(\'Selected Currency\',\'Only AUD\',\'Only CAD\',\'Only CHF\',\'Only CZK\',\'Only DKK\',\'Only EUR\',\'Only GBP\',\'Only HKD\',\'Only HUF\',\'Only JPY\',\'Only NOK\',\'Only NZD\',\'Only PLN\',\'Only SEK\',\'Only SGD\',\'Only USD\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_PAYPAL_IPN_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '11', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Preparing Order Status', 'MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID', '" . $status_id . "', 'Set the status of prepared orders made with this payment module to this value', '6', '12', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set PayPal Acknowledged Order Status', 'MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '13', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
            tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set PayPal Completed Order Status', 'MODULE_PAYMENT_PAYPAL_IPN_COMP_ORDER_STATUS_ID', '0', 'Set the status of orders which are confirmed as paid (completed) to this value', '6', '13', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Type', 'MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE', 'Aggregate', 'Send individual items to PayPal or aggregate all as one total item?', '6', '14', 'tep_cfg_select_option(array(\'Per Item\',\'Aggregate\'), ', now())");
      // bof PandA.nl move tax to total amount
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Move tax to total amount', 'MOVE_TAX_TO_TOTAL_AMOUNT', 'True', 'Do you want to move the tax to the total amount? If true PayPal will allways show the total amount including tax. (needs Aggregate instead of Per Item to function)', '6', '15', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      // eof PandA.nl move tax to total amount      
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Page Style', 'MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE', '', 'The page style to use for the transaction procedure (defined at your PayPal Profile page)', '6', '20', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Debug E-Mail Address', 'MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL', '', 'All parameters of an Invalid IPN notification will be sent to this email address if one is entered.', '6', '21', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Encrypted Web Payments', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS', 'False', 'Do you want to enable Encrypted Web Payments?', '6', '30', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Your Private Key', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY', '', 'The location of your Private Key to use for signing the data. (*.pem)', '6', '31', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Your Public Certificate', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY', '', 'The location of your Public Certificate to use for signing the data. (*.pem)', '6', '32', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('PayPals Public Certificate', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY', '', 'The location of the PayPal Public Certificate for encrypting the data.', '6', '33', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Your PayPal Public Certificate ID', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_CERT_ID', '', 'The Certificate ID to use from your PayPal Encrypted Payment Settings Profile.', '6', '34', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Working Directory', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY', '', 'The working directory to use for temporary files. (trailing slash needed)', '6', '35', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('OpenSSL Location', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL', '/usr/bin/openssl', 'The location of the openssl binary file.', '6', '36', now())");

    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

   function keys() {
    // PandA.nl move tax to total amount added: ", 'MOVE_TAX_TO_TOTAL_AMOUNT'"
     return array('MODULE_PAYMENT_PAYPAL_IPN_STATUS', 'MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER', 'MODULE_PAYMENT_PAYPAL_IPN_ID', 'MODULE_PAYMENT_PAYPAL_IPN_SORT_ORDER', 'MODULE_PAYMENT_PAYPAL_IPN_CURRENCY', 'MODULE_PAYMENT_PAYPAL_IPN_ZONE', 'MODULE_PAYMENT_PAYPAL_IPN_SHIPPING', 'MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYPAL_IPN_COMP_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE', 'MOVE_TAX_TO_TOTAL_AMOUNT', 'MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE', 'MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL',  'MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_CERT_ID', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL');
   }
  }
?>


Voili Voilo, n'oubliez pas de faire un back up avant.


--------------------
[edit NO_PUB]
Go to the top of the page
 
lbpf
posté 16 Mar 2007, 14:00
Message #13


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 32
Inscrit : 1-February 07
Membre no 15048



Merci beaucoup broussaille

Je vais essayer d'appliquer ces modifs en esperant que ca ne va pas chambouler mes autres contribs de paiement (virement bancaire, moneybookers et carte postepay). et en esperant que ca marchera avec ma version 2.2.

Je viendrai egalement vous tenir au courant du resultat.

wink.gif

Ce message a été modifié par lbpf - 16 Mar 2007, 14:03.


--------------------
^_^
K....
Go to the top of the page
 
lbpf
posté 16 Mar 2007, 14:39
Message #14


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 32
Inscrit : 1-February 07
Membre no 15048




Ca y est je viens de mettre ca en place, ca fonctionne nickel !!! Brousaille je te dois une biere !!
Tu pourrais meme publier ce script dans les contribs officielles car qui peut vendre sans paypal + gestion de stock ???

Merci encore 100000 fois
rolleyes.gif


--------------------
^_^
K....
Go to the top of the page
 
lbpf
posté 17 Mar 2007, 19:42
Message #15


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 32
Inscrit : 1-February 07
Membre no 15048



Salut tout le monde

Je viens de decouvrir un nouveau bug avec cette combinaison paypal ipn + qtpro

Avec le code de brousaille, tout fonctionne nickel en France, mais pas si le paiement paypal vient d'un client italien : dans ce cas le stock n'est pas mis a jour ! (mais le statut de la commande est mis a jour et les emails sont bien envoyes >> ipn.php fait son boulot)

Alors la je seche ... Ou peut se situer le probleme ???


--------------------
^_^
K....
Go to the top of the page
 
brousaille
posté 17 Mar 2007, 19:57
Message #16


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 51
Inscrit : 28-July 06
Membre no 11317



Je comprend pas trop pourquoi ca ne marcherai pas avec un client italien ???
Est ce qu'il y a une difference de gestion de l'information en fonction du pays ? Est ce que le paiement se fait de la meme facon ou bien tu dois faires des validations supplémentaires ?

Pour la contrib officiel je vais voir a la publier sur le site officiel.
Pas de problème pour la bière !!!


--------------------
[edit NO_PUB]
Go to the top of the page
 
brousaille
posté 17 Mar 2007, 19:58
Message #17


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 51
Inscrit : 28-July 06
Membre no 11317



Hmmm je pense peut etre savoir pourquoi , est ce que tes attributs sur les produits sont traduis en Italien ? As tu plusieurs langues sur le site ? C'est quoi l'adresse de ton site pour que j'y jette un oeil ?

Ce message a été modifié par brousaille - 17 Mar 2007, 20:01.


--------------------
[edit NO_PUB]
Go to the top of the page
 
lbpf
posté 18 Mar 2007, 10:02
Message #18


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 32
Inscrit : 1-February 07
Membre no 15048



CITATION(brousaille @ 17 Mar 2007, 20:58) [snapback]226416[/snapback]
Hmmm je pense peut etre savoir pourquoi , est ce que tes attributs sur les produits sont traduis en Italien ? As tu plusieurs langues sur le site ? C'est quoi l'adresse de ton site pour que j'y jette un oeil ?


Oui mon site est en francais (defaut. id=1), anglais et italien.
Je pense qu'il y a un probleme au niveau des parametres de langage, surement autour de $languages_id, mais je n'arrive pas a trouver d'ou ca vient.

Deja je viens de corriger un autre bug car les emails etaient toujours envoyes en francais si on payait avec paypal.
J'ai modifie paypal_ipn.php :
CODE
$parameters['notify_url'] = tep_href_link('ext/modules/payment/paypal_ipn/ipn.php', 'language=' . $_SESSION['language'], 'SSL', false, false);


puis ipn.php :
CODE
include(DIR_WS_LANGUAGES . $_GET['language'] . '/' . FILENAME_CHECKOUT_PROCESS);


Alors en effet, maintenant les emails sont dans la bonne langue.

Par contre si le visiteur n'est pas en langue francaise (pas seulement italien), le stock ne sera pas mis a jour... Dans mes attributs/produits, j'ai une seule option avec un nom different en fonction de la langue: Size/Taille/Taglia.
Par contre, chaque valeur pour cette option porte le meme nom dans les 3 langues (M, L, XL...).

Tu pensais a quoi comme probleme ?

a+

Kris

Ce message a été modifié par lbpf - 31 Mar 2007, 08:48.


--------------------
^_^
K....
Go to the top of the page
 
brousaille
posté 18 Mar 2007, 13:13
Message #19


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 51
Inscrit : 28-July 06
Membre no 11317



Bah en fait j'ai modifié la classe order ( la function query)

CODE
//++++ QT Pro: End Changed Code
             $attributes_query = tep_db_query("select products_options_id,products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . "  where products_options_name = '" . $attributes['products_options'] . "' and language_id=" . (int)$languages_id);
             $singleAttribute = tep_db_fetch_array($attributes_query);    
             $option_id = $singleAttribute["products_options_id"];
             $products_options_track_stock = $singleAttribute["products_options_track_stock"];
            
             $attributes_query = tep_db_query("select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES . "  where products_options_values_name = '" . $attributes['products_options_values'] . "' and language_id=" . (int)$languages_id);
             $singleAttribute = tep_db_fetch_array($attributes_query);
             $option_value_id    = $singleAttribute["products_options_values_id"];                
            //++++ QT Pro: End Changed Code


Dans ce bout de code j'ai deux requetes pour récupérer les id des options et des values, je me demande si ces deux requetes remontent de l'information.Car le WHERE se fait à partir d'un libellé. Elle ferait le WHERE sur un libellé en francais et pas en Italien ou un truc comme ca !!! Peux tu vérifier ?



--------------------
[edit NO_PUB]
Go to the top of the page
 
lbpf
posté 18 Mar 2007, 15:23
Message #20


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 32
Inscrit : 1-February 07
Membre no 15048



Merci.

Je ne sais pas comment verifier car mes connaissances php sont limitees, mais cela confirme mon doute sur $languages_id qui doit se perdre quelque part (la preuve : dans ipn.php on perdait la langue en cours et les emails etaient en Francais)

N'y aurait il pas une commande qui permettre de faire un truc du genre $languages_id = langue de la session en cours ?
Ou bien ne peut on pas faire les requetes sur les ID au lieu des noms des options ?


--------------------
^_^
K....
Go to the top of the page
 
brousaille
posté 19 Mar 2007, 10:26
Message #21


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 51
Inscrit : 28-July 06
Membre no 11317



Je pense que le problème qui se pose, c'est que IPN est appellé par le serveur de paypal.
Donc l'action se trouve en dehors de la session utilisateur, du coup "$language" n'est pas initialisé avec la bonne langue, je pense qu'il faut que paypal fournisse la langue de l'utilisateur afin qu'on puisse initialiser la variable

global $language

Je regarde ca


--------------------
[edit NO_PUB]
Go to the top of the page
 
lbpf
posté 19 Mar 2007, 11:08
Message #22


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 32
Inscrit : 1-February 07
Membre no 15048



oui c est pour ca que dans ipn.php j'avais remplace

CODE
include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS);


par

CODE
include(DIR_WS_LANGUAGES . $_GET['language'] . '/' . FILENAME_CHECKOUT_PROCESS);


Mais a part cette ligne, je ne voit pas ou on parle de "language" dans le reste du fichier blink.gif

correction : a ben si, on appelle la class order.php, et on revient donc encore et toujours au meme code qui doit pas recevoir $languages_id

Ce message a été modifié par lbpf - 19 Mar 2007, 11:11.


--------------------
^_^
K....
Go to the top of the page
 
brousaille
posté 19 Mar 2007, 11:22
Message #23


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 51
Inscrit : 28-July 06
Membre no 11317



Essai d'ajouter dans ipn.php le code suivant :

CODE
gobal $language;

$language = $_GET['language'];


juste apres la ligne

require('includes/application_top.php');

et refait un essai pour voir



--------------------
[edit NO_PUB]
Go to the top of the page
 
lbpf
posté 19 Mar 2007, 13:20
Message #24


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 32
Inscrit : 1-February 07
Membre no 15048



ouh la la ca fout la grosse pagaille. Meme pour une commande en francais, plus rien n'est pris en compte, meme le statut du paiement.
et il y a un error log :

CODE
[19-Mar-2007 05:58:22] PHP Parse error:  syntax error, unexpected T_VARIABLE in xxx/catalog/ext/modules/payment/paypal_ipn/ipn.php on line 17


je suis donc revenu a la version precedente, et continue a tracker le stock manuellement pour les commandes non francaises sad.gif


--------------------
^_^
K....
Go to the top of the page
 
brousaille
posté 20 Mar 2007, 10:49
Message #25


Ceinture jaune OSC
Icône de groupe

Groupe : Membres
Messages : 51
Inscrit : 28-July 06
Membre no 11317



J'ai oublié de mettre un "l" à "global"

donc ca fait

CODE
global $language;

$language = $_GET['language'];


--------------------
[edit NO_PUB]
Go to the top of the page
 

2 Pages V   1 2 >
Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



RSS Version bas débit Nous sommes le : 20th May 2013 - 01:34
Ce site est déclaré auprès de la commision Nationale
de l'Informatique et des Libertés (déclaration n°: 1043896)