/[drupal]/contributions/modules/uc_atos/uc_atos.module
ViewVC logotype

Contents of /contributions/modules/uc_atos/uc_atos.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Nov 4 10:52:14 2008 UTC (12 months, 3 weeks ago) by zmove
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5, DRUPAL-6--1
File MIME type: text/x-php
Initial release for Drupal 6.x
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Integrates the ATOS redirected payment service.
7 *
8 * Developped by zmove for Ubercart community
9 * Under GNU license
10 */
11
12 /*******************************************************************************
13 * Hook Functions (Drupal)
14 ******************************************************************************/
15
16 /**
17 * Implementation of hook_menu().
18 */
19 function uc_atos_menu() {
20 $items['cart/atos/complete'] = array(
21 'title' => 'Order complete',
22 'page callback' => 'uc_atos_complete',
23 'access callback' => 'user_access',
24 'access arguments' => array('access content'),
25 'type' => MENU_CALLBACK,
26 );
27 $items['cart/atos/cancel'] = array(
28 'title' => 'Order cancelled',
29 'page callback' => 'uc_atos_cancel',
30 'access callback' => 'user_access',
31 'access arguments' => array('access content'),
32 'type' => MENU_CALLBACK,
33 );
34 $items['cart/atos/autoresponse'] = array(
35 'title' => 'Page for autoresponse system',
36 'page callback' => 'uc_atos_autoresponse',
37 'access callback' => 'user_access',
38 'access arguments' => array('access content'),
39 'type' => MENU_CALLBACK,
40 );
41 return $items;
42 }
43
44 /**
45 * Implementation of hook_form_alter().
46 */
47 function uc_atos_form_alter(&$form, &$form_state, $form_id) {
48 if ($form_id == 'uc_cart_checkout_review_form' && ($order_id = intval($_SESSION['cart_order'])) > 0) {
49 $order = uc_order_load($order_id);
50 if ($order->payment_method == 'atos') {
51 unset($form['submit']);
52 unset($form['back']);
53 $form['#prefix'] = '<table style="display: inline; padding-top: 1em;"><tr><td>';
54 $form['#suffix'] = '</td><td>'. uc_atos_form($order) .'</td></tr></table>';
55 }
56 }
57 }
58
59
60 /*******************************************************************************
61 * Hook Functions (Ubercart)
62 ******************************************************************************/
63
64 /**
65 * Implementation of hook_payment_method().
66 */
67 function uc_atos_payment_method() {
68 $path = base_path() . drupal_get_path('module', 'uc_payment');
69 $title = variable_get('uc_atos_method_title', t('Credit card on a secure server'));
70
71 $methods[] = array(
72 'id' => 'atos',
73 'name' => t('atos'),
74 'title' => $title,
75 'review' => t('Credit card'),
76 'desc' => t('Redirect to atos to pay by credit card or eCheck.'),
77 'callback' => 'uc_payment_method_atos',
78 'weight' => 3,
79 'checkout' => TRUE,
80 'no_gateway' => TRUE,
81 );
82
83 return $methods;
84 }
85
86 /**
87 * Implementation of hook_store_status()
88 *
89 * Currently gives some infos/warning about uc_atos configuration
90 */
91 function uc_atos_store_status() {
92 $statuses = array();
93 //warning about "demo mode"
94 if (variable_get('uc_atos_mid', '') == '') {
95 $statuses[] = array(
96 'status' => 'warning',
97 'title' => t('ATOS/SIPS Configuration'),
98 'desc' => t('No merchant ID defined. ATOS/SIPS is working in "demo mode".'),
99 );
100 }
101
102 //error about the API pathfile not found (means the rest of the config is probably broken...)
103 if ( ! is_file(variable_get('uc_atos_api_pathfile', $_SERVER['DOCUMENT_ROOT'].'/atos/param/pathfile'))) {
104 $statuses[] = array(
105 'status' => 'error',
106 'title' => t('ATOS/SIPS Configuration'),
107 'desc' => t('The "pathfile" could not be found. Please ensure your settings are correct.'),
108 );
109 }
110 return $statuses;
111 }
112
113 /*******************************************************************************
114 * Callback Functions, Forms, and Tables
115 ******************************************************************************/
116
117 /**
118 * Callback for atos payment method settings.
119 */
120 function uc_payment_method_atos($op, &$arg1) {
121 switch ($op) {
122 case 'cart-details':
123 $details = variable_get('uc_atos_method_description', t('The transaction is totally secured in out bank server'));
124 return $details;
125
126 case 'cart-process':
127 $_SESSION['pay_method'] = $_POST['pay_method'];
128 return;
129
130 case 'settings':
131 $form['uc_atos_bank'] = array(
132 '#type' => 'select',
133 '#title' => t('Bank'),
134 '#description' => t('Choose your bank ATOS solution provider.'),
135 '#options' => array(
136 'etransaction' => t('Credit agricole (E-transaction)'),
137 'sogenactif' => t('Societe generale (Sogenactif)'),
138 'cyberplus' => t('Banque populaire (Cyberplus)'),
139 'mercanet' => t('BNP Paribas (Mercanet)'),
140 'scellius' => t('La poste (Scellius)'),
141 'sherlocks' => t('LCL : Le Credit Lyonnais (Sherlocks)'),
142 'webaffaires' => t('Crédit du Nord (Webaffaires)'),
143 ),
144 '#default_value' => variable_get('uc_atos_bank', FALSE),
145 );
146
147 $form['uc_atos_mid'] = array(
148 '#type' => 'textfield',
149 '#title' => t('Merchant ID'),
150 '#description' => t('Your atos merchant ID. If you don\'t fill this field, the "demo mode number" will be used.'),
151 '#default_value' => uc_atos_get_mid(),
152 '#size' => 32,
153 );
154 $form['uc_atos_language'] = array(
155 '#type' => 'select',
156 '#title' => t('Language preference'),
157 '#description' => t('Adjust language on atos pages. If you have a multilanguage website, the language selected by user will overwrite this setting'),
158 '#options' => array(
159 'en' => t('English'),
160 'fr' => t('French'),
161 'ge' => t('Germany'),
162 'sp' => t('Spain'),
163 'it' => t('Italia'),
164 ),
165 '#default_value' => variable_get('uc_atos_language', 'en'),
166 );
167 $form['uc_atos_method_title'] = array(
168 '#type' => 'textfield',
169 '#title' => t('Payment method title'),
170 '#description' => t('Title that appear on the payment selection page'),
171 '#default_value' => variable_get('uc_atos_method_title', t('Credit card on a secure server')),
172 );
173 $form['uc_atos_method_description'] = array(
174 '#type' => 'textfield',
175 '#maxlength' => 1024,
176 '#title' => t('Payment method description'),
177 '#description' => t('Description that appear under the title when selected'),
178 '#default_value' => variable_get('uc_atos_method_description', t('The transaction is totally secured in out bank server')),
179 );
180 $form['uc_atos_api'] = array(
181 '#type' => 'fieldset',
182 '#title' => t('ATOS/SIPS API configuration settings'),
183 '#description' => t('Please enter here the informations needing by the ATOS/SIPS binaries.')
184 . '<br />' . t('If something does not work as expected, you might wish to enter those settings in the param file :')
185 . '<ul>'
186 . '<li>RETURN_URL!' . url('cart/atos/complete', array('absolute' => TRUE)) . '!</li>'
187 . '<li>CANCEL_URL!' . url('cart/atos/cancel', array('absolute' => TRUE)) . '!</li>'
188 . '<li>AUTO_RESPONSE_URL!' . url('cart/atos/autoresponse', array('absolute' => TRUE)) . '!</li>'
189 // . '<li>AUTO_RESPONSE_URL!http://'.$_SERVER['SERVER_NAME'] . '/'.drupal_get_path('module', 'uc_atos') . '/call_autoresponse.php!</li>'
190 . '</ul>'
191 . t('Please note that any values pre-entered here are just common defaults, not autodetected values. Adjust to your configuration.').'<br />'
192 . t('Don\'t forget to configure your pathfile file. On windows system you will have to put double backslashes in your pathfile path. (example : F_PARAM!c:\\\\drupal\\\\atos\\\\param\\\\parmcom!)'),
193 '#collapsible' => TRUE,
194 '#collapsed' => FALSE,
195 );
196 $form['uc_atos_api']['uc_atos_api_version'] = array(
197 '#type' => 'select',
198 '#title' => t('API Version'),
199 '#options' => array(
200 'LIN_500' => t('Linux v5'),
201 'WIN_500' => t('Win32 v5'),
202 'LIN_600' => t('Linux v6'),
203 'WIN_600' => t('Win32 v6'),
204 ),
205 '#default_value' => variable_get('uc_atos_api_version', 'LIN_600'),
206 '#description' => t("Please choose the version of the API provided by your bank."),
207 '#required' => TRUE,
208 );
209 $form['uc_atos_api']['uc_atos_api_pathfile'] = array(
210 '#type' => 'textfield',
211 '#default_value' => variable_get('uc_atos_api_pathfile', $_SERVER['DOCUMENT_ROOT'].'/atos/param/pathfile'),
212 '#title' => t('Path to "pathfile"'),
213 '#description' => t("Full server-side path to the \"pathfile\" configuration file. On Windows platform, double the backslashes (example : c:\\\\www\\\\drupal\\\\atos\\\\param\\\\pathfile)"),
214 '#size' => 40,
215 '#maxlength' => 256,
216 '#required' => TRUE,
217 );
218 $form['uc_atos_api']['uc_atos_api_pathrequest'] = array(
219 '#type' => 'textfield',
220 '#default_value' => variable_get('uc_atos_api_pathrequest', $_SERVER['DOCUMENT_ROOT'].'/atos/request'),
221 '#title' => t('Path to the "request" executable'),
222 '#description' => t("Full server-side path to the request binary file. On Windows platform, double the backslashes (example : c:\\\\www\\\\drupal\\\\atos\\\\bin\\\\request.exe)"),
223 '#size' => 40,
224 '#maxlength' => 256,
225 '#required' => TRUE,
226 );
227 $form['uc_atos_api']['uc_atos_api_pathresponse'] = array(
228 '#type' => 'textfield',
229 '#default_value' => variable_get('uc_atos_api_pathresponse', $_SERVER['DOCUMENT_ROOT'].'/atos/response'),
230 '#title' => t('Path to the "response" executable'),
231 '#description' => t("Full server-side path to the response binary file. On Windows platform, double the backslashes (example : c:\\www\\\\drupal\\\\atos\\\\bin\\\\response.exe)"),
232 '#size' => 40,
233 '#maxlength' => 256,
234 '#required' => TRUE,
235 );
236 return $form;
237 }
238 }
239
240 // Form to build the submission to atos.com.
241 function uc_atos_form($order) {
242
243 $merchant_id = uc_atos_get_mid();
244 $merchant_country = strtolower(db_result(db_query("SELECT country_iso_code_2 FROM {uc_countries} WHERE country_id = ".variable_get('uc_store_country', '250'))));
245
246 $order_total = round($order->order_total * 100, 0);
247 $currency = uc_atos_get_currency_code(variable_get('uc_currency_code', 'EUR'));
248 $pathfile = variable_get('uc_atos_api_pathfile', $_SERVER['DOCUMENT_ROOT'].'/atos/param/pathfile');
249 if ($GLOBALS['locale']) { $language = $GLOBALS['locale']; } else { $language = variable_get('uc_atos_language', 'en'); }
250
251 $parm =
252 'merchant_id='.$merchant_id
253 .' merchant_country='.$merchant_country
254 .' amount='.$order_total
255 .' currency_code='.$currency
256 .' pathfile='.$pathfile
257 .' customer_id='.$order->uid
258 .' customer_email='.$order->primary_email
259 .' order_id='.$order->order_id
260 .' language='.$language
261 .' caddie='.uc_cart_get_id()
262 .' normal_return_url='.url('cart/atos/complete', array('absolute' => TRUE))
263 .' cancel_return_url='.url('cart/atos/cancel', array('absolute' => TRUE))
264 // .' automatic_response_url=http://'.$_SERVER['SERVER_NAME'] . '/'.drupal_get_path('module', 'uc_atos').'/call_autoresponse.php'
265 .' automatic_response_url='.url('cart/atos/autoresponse', array('absolute' => TRUE))
266 .' header_flag=yes';
267 //drupal_set_message('<pre>'.print_r($parm, true).'</pre>');
268 //$path_bin = $_SERVER['DOCUMENT_ROOT'].'atos/request';
269
270 $path_bin = variable_get('uc_atos_api_pathrequest', $_SERVER['DOCUMENT_ROOT'].'/atos/request');
271 $result=stripslashes(exec("$path_bin $parm"));
272 $hash = explode ("!", "$result");
273
274 $code = $hash[1];
275 $error = $hash[2];
276 $message = $hash[3];
277
278 // Analyse of return code
279 if (( $code == "" ) && ( $error == "" )) {
280 drupal_set_message(t('Request call error : Request executable file not found'), 'error');
281 }
282
283 // Erreur, display the error message
284 else if ($code != 0){
285 drupal_set_message(t('Payment API call error'), 'error');
286 drupal_set_message($error, 'error');
287 }
288 // OK, display the form
289 else {
290 // If debug = YES, show the parameters
291 drupal_set_message($error);
292 return $message;
293 }
294 }
295
296 /**
297 * When an order is complete : See call_autocomplete.php for more documentation
298 */
299 function uc_atos_complete($order_id = 0) {
300 if ( ! isset($_POST['DATA'])) {
301 drupal_set_message(t('You are not allowed to see this page, please, return to homepage.'));
302 drupal_goto('cart');
303 }
304
305 $status = _uc_atos_complete_order(FALSE);
306 if ($status === TRUE) {
307 //we empty the cart
308 uc_cart_empty(uc_cart_get_id());
309
310 $_SESSION['do_complete'] = TRUE;
311
312 drupal_goto('cart/checkout/complete');
313 }
314 else {
315 drupal_set_message($status, 'error');
316 drupal_goto('cart');
317 }
318 }
319
320 /**
321 * Autoresponse callback
322 */
323 function uc_atos_autoresponse() {
324 if (isset($_POST['DATA'])) {
325 _uc_atos_complete_order(TRUE);
326 }
327
328 exit; //Don't launch all the theme thing for this (hope it doesn't break anything :)
329 }
330
331 /**
332 * Cancel callback. In case we received an autoresponse for that order, we just tag the cancel.
333 */
334 function uc_atos_cancel() {
335 global $user;
336
337 unset($_SESSION['cart_order']);
338
339 if (isset($_POST['DATA'])) {
340 drupal_set_message(t('Error during order process, please, try again or contact administrator.'));
341 drupal_goto('cart');
342 return;
343 }
344
345 $response = _uc_atos_response_extract($_POST['DATA']);
346 if ( ! (isset($response['order_id']) and is_numeric($response['order_id']))) {
347 drupal_set_message(t('Error during order process, please, try again or contact administrator.'));
348 drupal_goto('cart');
349 return;
350 }
351
352 uc_order_comment_save(intval($response['order_id']), $user->uid, t('This order has been explicitly canceled by the user.'), 'order');
353 if (uc_order_update_status($response['order_id'], uc_order_state_default('canceled'))) {
354 drupal_set_message(t('Votre ordre a bien été annulé.'), 'status');
355 }
356 else {
357 drupal_set_message(t('Error during order process, please, try again or contact administrator.'));
358 watchdog('uc_atos', t("The order @order couldn't be marked as 'Canceled'.", array('@order' => intval($response['order_id']))), WATCHDOG_WARNING, NULL);
359 }
360
361 drupal_goto('cart');
362 }
363
364 /**
365 * Get the merchant ID. If empty, return a demo ID.
366 *
367 * if arg(1) is true, the function just test if we are in
368 * "demo-mode"
369 */
370 function uc_atos_get_mid($test = FALSE) {
371 $mid = variable_get('uc_atos_mid', '');
372 $banks_mid = array(
373 'etransaction' => '013044876511111',
374 'sogenactif' => '014213245611111',
375 'cyberplus' => '038862749811111',
376 'mercanet' => '082584341411111',
377 'scellius' => '014141675911111',
378 'sherlocks' => '014295303911111',
379 'webaffaires' => '014022286611111',
380 );
381
382 if (!empty($mid)) {
383 //If $test is TRUE, we just check whether we are in demo mode
384 if ($test) {
385 return in_array($mid, $banks_mid);
386 }
387 return $mid;
388 } else {
389 //If $test is TRUE, well, we are in demo mode...
390 if ($test) {
391 return TRUE;
392 }
393
394 if (isset($banks_mid[variable_get('uc_atos_bank', '')])) {
395 return $banks_mid[variable_get('uc_atos_bank', '')];
396 }
397 else {
398 //No bank by default, hence the output is empty if no bank is configured
399 return;
400 }
401 }
402 }
403
404 // Get the ID currency depending on the store currency
405 function uc_atos_get_currency_code($store_currency) {
406 $currencies = array(
407 'EUR' => '978',
408 'USD' => '840',
409 'CHF' => '756',
410 'GBP' => '826',
411 'CAD' => '124',
412 'JPY' => '392',
413 'MXP' => '484',
414 'TRL' => '792',
415 'AUD' => '036',
416 'NZD' => '554',
417 'NOK' => '578',
418 'BRC' => '986',
419 'ARP' => '032',
420 'KHR' => '116',
421 'TWD' => '901',
422 'SEK' => '752',
423 'DKK' => '208',
424 'KRW' => '410',
425 'SGD' => '702',
426 );
427 foreach($currencies as $key => $currency) {
428 if ($key == $store_currency) {
429 return $currency;
430 }
431 }
432 }
433
434 /**
435 * This function is used to parse the response
436 * from the bank server using the "response" binary.
437 *
438 * Argument should be the _POST data,
439 * Output is an array with the response items.
440 */
441 function _uc_atos_response_extract($message) {
442 $params = array(
443 'pathfile' => variable_get('uc_atos_api_pathfile', $_SERVER['DOCUMENT_ROOT'].'/atos/param/pathfile'),
444 'message' => $message,
445 );
446
447 //We launch the response binary
448 $launcher = variable_get('uc_atos_api_pathresponse', $_SERVER['DOCUMENT_ROOT'].'/atos/response');
449 foreach($params as $key => $value) {
450 $launcher .= ( empty($params[$key]) ? '' : ' ' . escapeshellarg($key . '=' . $value));
451 }
452
453 $result=stripslashes(exec($launcher));
454
455 //We parse the result
456 $tmp = explode('!', $result);
457
458 $i = 1;
459 $output = array(
460 'code' => $tmp[$i++],
461 'error' => $tmp[$i++],
462 'merchant_id' => $tmp[$i++],
463 'merchant_country' => $tmp[$i++],
464 'amount' => $tmp[$i++],
465 'transaction_id' => $tmp[$i++],
466 'payment_means' => $tmp[$i++],
467 'transmission_date' => $tmp[$i++],
468 'payment_time' => $tmp[$i++],
469 'payment_date' => $tmp[$i++],
470 'response_code' => $tmp[$i++],
471 'payment_certificate' => $tmp[$i++],
472 'authorisation_id' => $tmp[$i++],
473 'currency_code' => $tmp[$i++],
474 'card_number' => $tmp[$i++],
475 'cvv_flag' => $tmp[$i++],
476 'cvv_response_code' => $tmp[$i++],
477 'bank_response_code' => $tmp[$i++],
478 'complementary_code' => $tmp[$i++],
479 'complementary_info' => ( substr(variable_get('uc_atos_api_version', 'LIN_600'), 0 -3) == '500' ? NULL : $tmp[$i++] ),
480 'return_context' => $tmp[$i++],
481 'caddie' => $tmp[$i++],
482 'receipt_complement' => $tmp[$i++],
483 'merchant_language' => $tmp[$i++],
484 'language' => $tmp[$i++],
485 'customer_id' => $tmp[$i++],
486 'order_id' => $tmp[$i++],
487 'customer_email' => $tmp[$i++],
488 'customer_ip_address' => $tmp[$i++],
489 'capture_day' => $tmp[$i++],
490 'capture_mode' => $tmp[$i++],
491 'data' => $tmp[$i++],
492 );
493
494 return $output;
495 }
496
497 /**
498 * This function analyze the data returned by the bank and
499 * flags the order when necessary
500 *
501 * argument : $autoresponse = TRUE if called for 'autoresponse' ( TODO : what difference ? )
502 * return : TRUE if payment accepted, the error message otherwise
503 */
504 function _uc_atos_complete_order($autoresponse = FALSE) {
505 global $user; //In case of autoresponse, it will be anonymous
506
507 //we check there is DATA to check
508 if (empty($_POST['DATA'])) {
509 //Simple warning, as it may be a searchbot
510 watchdog('uc_atos', t("The 'autoresponse' function was called without any POST data."), WATCHDOG_WARNING, NULL);
511 // return FALSE;
512 return t("We didn't receive data from the bank.");
513 }
514
515 //Extraction of the data
516 $response = _uc_atos_response_extract($_POST['DATA']);
517 if ( ! ( isset($response['code'])
518 and $response['code'] == 0
519 and isset($response['order_id'])
520 and is_numeric($response['order_id'])
521 and isset($response['response_code'])
522 )) {
523 watchdog('uc_atos', t('API ATOS/SIPS error : ') . ( isset($response['error']) ? strip_tags($response['error']) : '[no message]'));
524 return t("ATOS/SIPS error : Error during order data analyze. Please, try again or contact administrator.");
525 }
526
527 //We check that the bank accepted the payment
528 if ($response['response_code'] != '00') {
529 //Payment refused
530 watchdog('uc_atos', t("The transaction wasn't authorized."), WATCHDOG_NOTICE, NULL);
531 return t("The transaction wasn't authorised by the bank...");
532 }
533
534 //We simply check that the order exists
535 if ( ! ($order = uc_order_load(intval($response['order_id'])))) {
536 watchdog('uc_atos', t("The _uc_atos_complete_order function got a invalid order_id from the bank : @orderid", array('@orderid' => $response['order_id'])), WATCHDOG_WARNING, NULL);
537 return t("Internal error : this order is not in our database. Please contact the site administrator.");
538 }
539
540 //To differentiate several payments, we need the authorisation_id
541 // field, so we just log if it isn't there
542 if ( empty($response['authorisation_id'])) {
543 watchdog('uc_atos', t("The _uc_atos_complete_order function got a response without authorisation_id field."), WATCHDOG_WARNING, NULL);
544 uc_order_comment_save($order->order_id, $user->uid, t("The uc_atos module got a payment without authorisation_id. Use this info with caution. The user has been warned. Amount : @amount, user : @username", array('@amount' => $response['amount'], '@username' => $user->name)), 'order', $order->order_status, FALSE);
545 return t("The data sent by the bank didn't contain everything we needed to definitely validate the order. It has however been saved so please contact the site administrator in case of trouble.");
546 }
547
548 //We check that, for this order, there isn't already a paiement
549 // (Some genius could do previous page / forward page to get multiple payment)
550 // (Normally, since the order_id is certified, the user shouldn't be able to get another order paid with the same authorisation ID)
551 $payments = uc_payment_load_payments($order->order_id);
552 if ($payments) {
553 //There may be several payments for an order...
554 foreach($payments as $payment) {
555 // if ( $payment->method == 'atos') { //$payment->method contains the t("Credit card") !!! Not sufficiently reliable, we check all payments...
556 if (($tmp = unserialize($payment->data)) and ! empty($tmp['authorisation_id'])) {
557 if ($tmp['authorisation_id'] == $response['authorisation_id'] ) {
558 if ($autoresponse) {
559 //The user came back before the autoresponse arrived ? Well... that's something to log :)
560 watchdog('uc_atos', t("The autoresponse call came after the user come back ! lol ^^ order : @orderid", array('@orderid' => $order->order_id)), WATCHDOG_WARNING, NULL);
561 return TRUE;
562 }
563
564 //It still could be a previous autoresponse payment...
565 if ( isset($tmp['autoresponse']) and ! $tmp['autoresponse']) {
566 watchdog('uc_atos', t("The user tried to re-validate a payment."), WATCHDOG_WARNING, NULL);
567 return t("You have already validated this payment.");
568 }
569 else {
570 //We log a comment to get the userID (just in case)
571 uc_order_comment_save($order->order_id, $user->uid, t("The user came back from the bank site and validated the payment with ATOS/SIPS"), 'order', $order->order_status, FALSE);
572 return TRUE;
573 // return t("Welcome back ! We already manage your payment and are preparing your command...");
574 }
575 }
576 }
577 //Since we can't distinguish between other type of payments and old atos one, we disable this part
578 /*
579 else {
580 //It's an atos payment and we couldn't unserialize the data field ? Old version ? Quite suspicious. We log and break.
581 watchdog('uc_atos', t("The uc_atos module received another payment for the order @orderid but couldn't determine if the previous one was the same.", array('@orderid' => $order->order_id)), WATCHDOG_WARNING, NULL);
582 return FALSE;
583 }
584 */
585 // }
586 }
587 }
588
589
590 /** All seems ok, we save the payment info. **/
591 //Saving the payment
592 if ($autoresponse) {
593 $message = t("This order has been certified paid by a bank 'autoresponse' with authorization ID : @authid .", array('@authid' => $response['authorisation_id']));
594 }
595 else {
596 $message = t("This order has been certified paid with authorization ID : @authid, by user : @username .", array('@authid' => $response['authorisation_id'], '@username' => $user->name));
597 }
598 uc_payment_enter($order->order_id, 'atos', $response['amount'] / 100, $user->uid, array('authorisation_id' => $response['authorisation_id'], 'autoresponse' => $autoresponse), $message);
599
600 //We log a comment to show the boss who got the payment :)
601 if (uc_atos_get_mid(TRUE)) {
602 uc_order_comment_save($order->order_id, $user->uid, t("Order paid via website with Ubercart ATOS/SIPS [demo mode]"), 'order', $order->order_status, FALSE);
603 }
604 else {
605 uc_order_comment_save($order->order_id, $user->uid, t("Order paid via website with Ubercart ATOS/SIPS"), 'order', $order->order_status, FALSE);
606 }
607
608 //and we update the order status
609 uc_order_update_status($order->order_id, uc_order_state_default('post_checkout'));
610
611
612 /** The end **/
613 return TRUE;
614 }
615
616

  ViewVC Help
Powered by ViewVC 1.1.2