2 /***************************************************************************
3 * Copyright (C) 2003-2009 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
28 var $nomsite = "PayPal";
38 $this->val_number
= $val;
42 // {{{ function form()
44 function prepareform(&$pay)
47 // https://www.paypal.com/fr_FR/pdf/integration_guide.pdf
48 // attention : le renvoi automatique ne fonctionne que si
49 // on oblige les gens à créer un compte paypal
50 // nous ne l'utilisons pas ; il faut donc que l'utilisateur
51 // revienne sur le site
52 global $globals, $platal;
54 $this->urlform
= 'https://'.$globals->money
->paypal_site
.'/cgi-bin/webscr';
56 $name = $user->lastName();
58 $roboturl = str_replace("https://","http://",$globals->baseurl
)
59 . '/' . $platal->ns
. "payment/paypal_return/".S
::v('uid')."?comment=".urlencode(Env
::v('comment'));
61 $this->infos
= Array();
63 $this->infos
['commercant'] = Array(
64 'business' => $globals->money
->paypal_compte
,
66 'return' => $roboturl,
67 'cn' => 'Commentaires',
69 'cbt' => empty($GLOBALS['IS_XNET_SITE']) ?
70 'Revenir sur polytechnique.org' :
71 'Revenir sur polytechnique.net');
74 'first_name' => S
::v('prenom'),
76 'email' => S
::user()->bestEmail());
78 // XXX: waiting for port of adresses.
80 "SELECT a.adr1 AS address1, a.adr2 AS address2,
81 a.city, a.postcode AS zip, a.country,
82 IF(t1.display_tel != '', t1.display_tel, t2.display_tel) AS night_phone_b
83 FROM auth_user_quick AS q
84 LEFT JOIN adresses AS a ON (q.user_id = a.uid AND FIND_IN_SET('active', a.statut))
85 LEFT JOIN profile_phones AS t1 ON (t1.uid = a.uid AND t1.link_type = 'address' AND t1.link_id = a.adrid)
86 LEFT JOIN profile_phones AS t2 ON (t2.uid = a.uid AND t2.link_type = 'user' AND t2.link_id = 0)
88 LIMIT 1", S
::v('uid'));
89 $this->infos
['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
91 // on constuit la reference de la transaction
92 $prefix = ($pay->flags
->hasflag('unique')) ?
str_pad("",15,"0") : rand_url_id();
93 $fullref = substr("$prefix-xorg-{$pay->id}",-15);
95 $this->infos
['commande'] = Array(
96 'item_name' => replace_accent($pay->text
),
97 'amount' => $this->val_number
,
98 'currency_code' => 'EUR',
99 'custom' => $fullref);
101 $this->infos
['divers'] = Array('cmd' => '_xclick');
109 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: