b58cea68e23f6af4d3a353a87b2f34f94de6b1d5
2 /***************************************************************************
3 * Copyright (C) 2003-2011 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 ***************************************************************************/
26 var $nomsite = "PayPal";
33 $this->val_number
= $val;
36 function prepareform($pay)
39 // https://www.paypal.com/developer
40 // Warning: the automatic return only works if we force the
41 // users to create a paypal account. We do not use it; thus
42 // the user must come back on the site.
43 global $globals, $platal;
45 $this->urlform
= 'https://' . $globals->money
->paypal_site
. '/cgi-bin/webscr';
48 $roboturl = str_replace("https://","http://",$globals->baseurl
)
49 . '/' . $platal->ns
. "payment/paypal_return/" . S
::v('uid')
50 . "?comment=" . urlencode(Env
::v('comment'));
53 'commercant' => array(
54 'business' => $globals->money
->paypal_compte
,
56 'return' => $roboturl,
57 'cn' => 'Commentaires',
59 'cbt' => empty($GLOBALS['IS_XNET_SITE']) ?
'Revenir sur polytechnique.org.' : 'Revenir sur polytechnique.net.'
64 'first_name' => $user->firstName(),
65 'last_name' => $user->lastName(),
66 'email' => $user->bestEmail()
69 if ($user->hasProfile()) {
70 $res = XDB
::query("SELECT pa.text, pace2.short_name AS city, pace3.short_name AS zip, pace1.short_name AS country,
71 IF(pp1.display_tel != '', pp1.display_tel, pp2.display_tel) AS night_phone_b
72 FROM profile_addresses AS pa
73 LEFT JOIN profile_phones AS pp1 ON (pp1.pid = pa.pid AND pp1.link_type = 'address' AND pp1.link_id = pa.id)
74 LEFT JOIN profile_phones AS pp2 ON (pp2.pid = pa.pid AND pp2.link_type = 'user' AND pp2.link_id = 0)
75 LEFT JOIN profile_addresses_components_enum AS pace1 ON (FIND_IN_SET('country', pace1.types))
76 LEFT JOIN profile_addresses_components_enum AS pace2 ON (FIND_IN_SET('locality', pace2.types))
77 LEFT JOIN profile_addresses_components_enum AS pace3 ON (FIND_IN_SET('postal_code', pace3.types))
78 LEFT JOIN profile_addresses_components AS pac1 ON (pa.pid = pac1.pid AND pa.jobid = pac1.jobid AND pa.groupid = pac1.groupid
79 AND pa.id = pac1.id AND pa.type = pac1.type AND pace1.id = pac1.component_id)
80 LEFT JOIN profile_addresses_components AS pac2 ON (pa.pid = pac2.pid AND pa.jobid = pac2.jobid AND pa.groupid = pac2.groupid
81 AND pa.id = pac2.id AND pa.type = pac2.type AND pace2.id = pac2.component_id)
82 LEFT JOIN profile_addresses_components AS pac3 ON (pa.pid = pac3.pid AND pa.jobid = pac3.jobid AND pa.groupid = pac3.groupid
83 AND pa.id = pac3.id AND pa.type = pac3.type AND pace3.id = pac3.component_id)
85 WHERE pa.pid = {?} AND FIND_IN_SET('current', pa.flags)
86 GROUP BY pa.pid, pa.jobid, pa.groupid, pa.id, pa.type
88 $user->profile()->id());
89 $this->infos
['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
90 list($this->infos
['client']['address1'], $this->infos
['client']['address2']) =
91 explode("\n", Geocoder
::getFirstLines($this->infos
['client']['text'],
92 $this->infos
['client']['zip'], 2));
93 unset($this->infos
['client']['text']);
95 $this->infos
['client'] = replace_accent($info_client);
98 // We build the transaction's reference
99 $prefix = ($pay->flags
->hasflag('unique')) ?
str_pad("", 15, "0") : rand_url_id();
100 $fullref = substr("$prefix-xorg-{$pay->id}", -15);
102 $this->infos
['commande'] = array(
103 'item_name' => replace_accent($pay->text
),
104 'amount' => $this->val_number
,
105 'currency_code' => 'EUR',
109 $this->infos
['divers'] = array('cmd' => '_xclick');
115 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: