X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fpayment%2Fmoney%2Fbplccyberplus.inc.php;h=0b273a58b4bc63716ad0ae5fa33c3ed03d46b33b;hb=5096676e03dcd626d6e64696cb9d6ee5d8e054da;hp=3f40979170b7d8eb239d18f01992c0adca78a44a;hpb=164566891eef6e4027b2dfccda0040d37f10605b;p=platal.git diff --git a/modules/payment/money/bplccyberplus.inc.php b/modules/payment/money/bplccyberplus.inc.php index 3f40979..0b273a5 100644 --- a/modules/payment/money/bplccyberplus.inc.php +++ b/modules/payment/money/bplccyberplus.inc.php @@ -1,6 +1,6 @@ val = 100 * strtr(sprintf("%.02f", (float)$val), '.', ','); + // Improvement: number of digits after the coma might depend from the currency. + $this->val = 100 * strtr($val, ',', '.'); } // }}} // {{{ function form() - function prepareform(&$pay) + private static function replaceNonAlpha($string) + { + return trim(preg_replace('/\s\s+/', ' ', preg_replace('/[^a-zA-Z0-9]/', ' ', $string))); + } + + function prepareform($pay, $user) { global $globals, $platal; $log = S::v('log'); - // on constuit la reference de la transaction - $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id(); + // Transaction's reference computation. + $prefix = rand_url_id(); $fullref = substr("$prefix-{$pay->id}",-12); // FIXME : check for duplicates $ts = time(); - $trans_date = date("YmdHis", $ts); - $trans_id = date("His", $ts); // FIXME : check for duplicates + $trans_date = gmdate("YmdHis", $ts); + $trans_id = gmdate("His", $ts); // FIXME : check for duplicates - // contenu du formulaire + // Form's content. $this->urlform = "https://systempay.cyberpluspaiement.com/vads-payment/"; $this->infos['commercant'] = Array( 'vads_site_id' => $globals->money->cyperplus_account, 'vads_return_mode' => 'NONE', 'vads_url_return' => $pay->url ? $pay->url : $globals->baseurl . '/' . $platal->ns); $this->infos['client'] = Array( - 'vads_cust_email' => S::user()->bestEmail(), - 'vads_cust_id' => S::v('uid'), - 'vads_cust_name' => replace_accent(S::user()->fullName())); + 'vads_cust_email' => $user->bestEmail(), + 'vads_cust_id' => $user->id(), + 'vads_cust_name' => substr(self::replaceNonAlpha(replace_accent($user->shortName())), 0, 127)); $this->infos['commande'] = Array( 'vads_amount' => $this->val, 'vads_currency' => '978', # Euro @@ -85,14 +89,15 @@ class BPLCCyberPlus 'vads_trans_date' => $trans_date, 'vads_trans_id' => $trans_id, 'vads_order_id' => $fullref, - 'vads_order_info' => Env::v('comment')); + 'vads_order_info' => substr(self::replaceNonAlpha(replace_accent(Env::v('comment'))), 0, 255), + 'vads_order_info2' => Post::i('display')); $this->infos['divers'] = Array( 'vads_version' => 'V2', 'vads_ctx_mode' => $globals->money->cyperplus_prod, 'vads_page_action' => 'PAYMENT', 'vads_action_mode' => 'INTERACTIVE'); - // calcul de la clé d'acceptation en entrée + // Entry key computation. $all_params = array_merge($this->infos['commercant'],$this->infos['client'],$this->infos['commande'],$this->infos['divers']); ksort($all_params); $this->infos['divers']['signature'] = sha1(join('+',$all_params).'+'.$globals->money->cyperplus_key); @@ -103,5 +108,5 @@ class BPLCCyberPlus $api = 'BPLCCyberPlus'; -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>