val = 100 * strtr(sprintf("%.02f", (float)$val), '.', ','); } // }}} // {{{ function form() 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'); // Transaction's reference computation. $prefix = rand_url_id(); $fullref = substr("$prefix-{$pay->id}",-12); // FIXME : check for duplicates $ts = time(); $trans_date = gmdate("YmdHis", $ts); $trans_id = gmdate("His", $ts); // FIXME : check for duplicates // 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' => $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 'vads_payment_config' => 'SINGLE', 'vads_trans_date' => $trans_date, 'vads_trans_id' => $trans_id, 'vads_order_id' => $fullref, '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'); // 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); } // }}} } $api = 'BPLCCyberPlus'; // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>