2 /***************************************************************************
3 * Copyright (C) 2003-2008 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 ***************************************************************************/
22 /** Card numbers for tests.
24 * 4970 1000 0000 0003 Payment accepted (authorized)
26 * 4970 1000 0000 0000 Payment accepted, with user authentication.
27 * 4970 1000 0000 0001 Payment accepted, without user authentication (non 3D-Secure user).
28 * 4970 1000 0000 0002 Must contact card issuer (which must force transaction). Succesful authentication.
29 * 4970 1000 0000 0006 Technical issue while computing payment warranty.
30 * 4970 1000 0000 0007 Technical issue during user authentication.
31 * 4970 1000 0000 0097 Payment refused due to 3D-Secure authentication failure (user failed to authenticate).
32 * 4970 1000 0000 0098 Payment refused (user credit limit overrun).
33 * 4970 1000 0000 0099 Payment refused (invalid credit card visual cryptogramm).
43 var $nomsite = "la BP Lorraine Champagne";
49 function BPLCCyberPlus($val)
51 // Improvement: number of digits after the coma might depend from the currency.
52 $this->val
= 100 * strtr(sprintf("%.02f", (float)$val), '.', ',');
56 // {{{ function form()
58 private static function replaceNonAlpha($string)
60 return trim(preg_replace('/\s\s+/', ' ', preg_replace('/[^a-zA-Z0-9]/', ' ', $string)));
63 function prepareform($pay)
65 global $globals, $platal;
68 // Transaction's reference computation.
69 $prefix = ($pay->flags
->hasflag('unique')) ?
str_pad("",15,"0") : rand_url_id();
70 $fullref = substr("$prefix-{$pay->id}",-12); // FIXME : check for duplicates
72 $trans_date = date("YmdHis", $ts);
73 $trans_id = date("His", $ts); // FIXME : check for duplicates
76 $this->urlform
= "https://systempay.cyberpluspaiement.com/vads-payment/";
77 $this->infos
['commercant'] = Array(
78 'vads_site_id' => $globals->money
->cyperplus_account
,
79 'vads_return_mode' => 'NONE',
80 'vads_url_return' => $pay->url ?
$pay->url
: $globals->baseurl
. '/' . $platal->ns
);
81 $this->infos
['client'] = Array(
82 'vads_cust_email' => S
::user()->bestEmail(),
83 'vads_cust_id' => S
::v('uid'),
84 'vads_cust_name' => substr(self
::replaceNonAlpha(replace_accent(S
::user()->shortName())), 0, 127));
85 $this->infos
['commande'] = Array(
86 'vads_amount' => $this->val
,
87 'vads_currency' => '978', # Euro
88 'vads_payment_config' => 'SINGLE',
89 'vads_trans_date' => $trans_date,
90 'vads_trans_id' => $trans_id,
91 'vads_order_id' => $fullref,
92 'vads_order_info' => substr(self
::replaceNonAlpha(replace_accent(Env
::v('comment'))), 0, 255),
93 'vads_order_info2' => Post
::i('display'));
94 $this->infos
['divers'] = Array(
95 'vads_version' => 'V2',
96 'vads_ctx_mode' => $globals->money
->cyperplus_prod
,
97 'vads_page_action' => 'PAYMENT',
98 'vads_action_mode' => 'INTERACTIVE');
100 // Entry key computation.
101 $all_params = array_merge($this->infos
['commercant'],$this->infos
['client'],$this->infos
['commande'],$this->infos
['divers']);
103 $this->infos
['divers']['signature'] = sha1(join('+',$all_params).'+'.$globals->money
->cyperplus_key
);
109 $api = 'BPLCCyberPlus';
111 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: