PEEL Shopping
Open source ecommerce : PEEL Shopping
ipn.php
Go to the documentation of this file.
1 <?php
2 // This file should be in UTF8 without BOM - Accents examples: éèê
3 // +----------------------------------------------------------------------+
4 // | Copyright (c) 2004-2015 Advisto SAS, service PEEL - contact@peel.fr |
5 // +----------------------------------------------------------------------+
6 // | This file is part of PEEL Shopping 8.0.0, which is subject to an |
7 // | opensource GPL license: you are allowed to customize the code |
8 // | for your own needs, but must keep your changes under GPL |
9 // | More information: https://www.peel.fr/lire/licence-gpl-70.html |
10 // +----------------------------------------------------------------------+
11 // | Author: Advisto SAS, RCS 479 205 452, France, https://www.peel.fr/ |
12 // +----------------------------------------------------------------------+
13 // $Id: ipn.php 46935 2015-09-18 08:49:48Z gboussin $
14 include("../../configuration.inc.php");
15 
16 
17 if (empty($_POST)) {
18  die();
19 }
20 
21 $checknumber=strtoupper(md5(vb($_POST['merchant_id']).vb($_POST['transaction_id']).strtoupper(md5($GLOBALS['site_parameters']['secret_word'])).vb($_POST['amount']).vb($_POST['currency']).vb($_POST['status'])));
22 
23 if ($checknumber == vb($_POST['md5sig'])) {
24  //responce is sent By Moneybookers
25  $status = vn($_POST['status']);
26  $transaction_id = vn($_POST['transaction_id']);
27  $amount = vn($_POST['amount']);
28  $pay_to_email = vn($_POST['pay_to_email']);
29  if ($pay_to_email == $GLOBALS['site_parameters']['email_moneybookers']) {
30  $q = query('SELECT *
31  FROM peel_commandes
32  WHERE id="' . intval($transaction_id) . '" AND ' . get_filter_site_cond('commandes') . '
33  LIMIT 1');
34  if ($r = fetch_assoc($q)) {
35  if (round($r['montant'], 2) == round($amount, 2)) {
36  switch ($status) {
37  case '-2' :
38  // failed
39  $update_status = 'cancelled';
40  break;
41 
42  case '2' :
43  // processed
44  $update_status = 'completed';
45  break;
46 
47  case '0' :
48  // pending
49  $update_status = 'pending';
50  break;
51 
52  case '-1' :
53  // cancelled
54  $update_status = 'cancelled';
55  break;
56 
57  default :
58  $update_status = 'pending';
59  break;
60  }
61  if(in_array($update_status, array('being_checked', 'completed'))) {
62  $data = $_POST;
63  $data['MONTANT_CREDIT'] = $amount;
64  accounting_insert_transaction($transaction_id, 'moneybookers', $_POST);
65  }
66  if(in_array($update_status, array('completed'))) {
68  }
69  update_order_payment_status($transaction_id, $update_status, true, null, null,false, 'moneybookers');
70  } else {
71  send_email($GLOBALS['support'], 'Alerte : Montant de la transaction CB ' . $transaction_id . ' altéré', str_replace(",", "", fprix($r['montant'])) . ' = ' . $amount);
72  }
73  }
74  }
75 } else {
76  //responce is NOT sent By Moneybookers
77  send_email($GLOBALS['support'], 'Alerte : problème sur transaction CB commande ' . $transaction_id . '', 'Les informations Moneybookers semblent incorrectes ' . "\n\n" . print_r($_REQUEST, true));
78 }
foreach(array('date1', 'date2', 'type', 'renewals', 'width') as $item) $data
Definition: chart-data.php:29
if(empty($_POST)) $checknumber
Definition: ipn.php:21
foreach($_POST as $key=> $value) if(!empty($_POST['item_number'])) elseif(!empty($_POST['custom'])) $q
Definition: ipn.php:40
if(empty($_GET['id'])) $transaction_id
Definition: nok.php:19
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
Definition: fonctions.php:4643
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
Definition: database.php:158
vb(&$var, $default=null)
Variable blanche if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:97
if(!defined('IN_PEEL')) send_email($to, $mail_subject= '', $mail_content= '', $template_technical_code=null, $template_tags=null, $format=null, $sender=null, $html_add_structure=true, $html_correct_conformity=false, $html_convert_url_to_links=true, $reply_to=null, $attached_files_infos_array=null, $lang=null, $additional_infos_array=array(), $attachment_not_sent_by_email=false)
Envoi d'un email à un utilisateur.
Definition: emails.php:38
accounting_insert_transaction($order_id, $technical_code, $data)
Crée une transaction d'encaissement.
Definition: order.php:113
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
$GLOBALS['page_columns_count']
email_commande($order_id)
email_commande()
Definition: order.php:970
vn(&$var, $default=0)
Variable nulle if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:110
fprix($price, $display_currency=false, $currency_code_or_default=null, $convertion_needed_into_currency=true, $currency_rate=null, $display_iso_currency_code=false, $format=true, $force_format_separator=null, $add_rdfa_properties=false, $round_even_if_no_format=false)
fprix formatte le prix donné en le convertissant si nécessaire au préalable et en ajoutant éventuelle...
Definition: fonctions.php:242
update_order_payment_status($order_id, $status_or_is_payment_validated, $allow_update_paid_orders=true, $statut_livraison_new=null, $delivery_tracking=null, $no_stock_decrement_already_done=false, $payment_technical_code=null)
Met à jour le status de paiement et/ou de livraison d'une commande, et gère les stocks suivant le sta...
Definition: order.php:178

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:32 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.