From 9b947ed0b79a856d8702a054f374da0c897c5226 Mon Sep 17 00:00:00 2001 From: Damien Bobillot Date: Wed, 23 Jun 2010 02:02:59 +0200 Subject: [PATCH] Integration of the new BPLC payment system. Schmurtz --- modules/payment/money/bplccyberplus.inc.php | 95 +++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 modules/payment/money/bplccyberplus.inc.php diff --git a/modules/payment/money/bplccyberplus.inc.php b/modules/payment/money/bplccyberplus.inc.php new file mode 100644 index 0000000..ae8fdbb --- /dev/null +++ b/modules/payment/money/bplccyberplus.inc.php @@ -0,0 +1,95 @@ +val = 100 * strtr(sprintf("%.02f", (float)$val), '.', ','); + } + + // }}} + // {{{ function form() + + function prepareform(&$pay) + { + global $globals, $platal; + $log = S::v('log'); + + $url_return = str_replace("https://","http://", $globals->baseurl) + . '/' . $platal->ns . "payment/cyber2_return/"; + + // on constuit la reference de la transaction + $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : 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 + + // contenu du formulaire + $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' => $url_return); + $this->infos['client'] = Array( + 'vads_cust_email' => S::user()->bestEmail(), + 'vads_cust_id' => S::v('uid'), + 'vads_cust_name' => replace_accent(S::user()->fullName())); + $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' => Env::v('comment')); + $this->infos['divers'] = Array( + 'vads_version' => 'V2', + 'vads_ctx_mode' => 'TEST', + 'vads_page_action' => 'PAYMENT', + 'vads_action_mode' => 'INTERACTIVE'); + + // calcul de la clé d'acceptation en entrée + $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: +?> -- 2.1.4