| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2008 Polytechnique.org * |
| 4 | * http://opensource.polytechnique.org/ * |
| 5 | * * |
| 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. * |
| 10 | * * |
| 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. * |
| 15 | * * |
| 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 * |
| 18 | * Foundation, Inc., * |
| 19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | /** Card numbers for tests. |
| 23 | * Non 3D-Secure shop: |
| 24 | * 4970 1000 0000 0003 Payment accepted (authorized) |
| 25 | * 3D-Secure shop: |
| 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). |
| 34 | */ |
| 35 | |
| 36 | class BPLCCyberPlus |
| 37 | { |
| 38 | // {{{ properties |
| 39 | |
| 40 | var $val; |
| 41 | |
| 42 | var $urlform; |
| 43 | var $nomsite = "la BP Lorraine Champagne"; |
| 44 | var $infos; |
| 45 | |
| 46 | // }}} |
| 47 | // {{{ constructor |
| 48 | |
| 49 | function BPLCCyberPlus($val) |
| 50 | { |
| 51 | // Improvement: number of digits after the coma might depend from the currency. |
| 52 | $this->val = 100 * strtr(sprintf("%.02f", (float)$val), '.', ','); |
| 53 | } |
| 54 | |
| 55 | // }}} |
| 56 | // {{{ function form() |
| 57 | |
| 58 | function prepareform($pay) |
| 59 | { |
| 60 | global $globals, $platal; |
| 61 | $log = S::v('log'); |
| 62 | |
| 63 | // Transaction's reference computation. |
| 64 | $prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id(); |
| 65 | $fullref = substr("$prefix-{$pay->id}",-12); // FIXME : check for duplicates |
| 66 | $ts = time(); |
| 67 | $trans_date = date("YmdHis", $ts); |
| 68 | $trans_id = date("His", $ts); // FIXME : check for duplicates |
| 69 | |
| 70 | // Form's content. |
| 71 | $this->urlform = "https://systempay.cyberpluspaiement.com/vads-payment/"; |
| 72 | $this->infos['commercant'] = Array( |
| 73 | 'vads_site_id' => $globals->money->cyperplus_account, |
| 74 | 'vads_return_mode' => 'NONE', |
| 75 | 'vads_url_return' => $pay->url ? $pay->url : $globals->baseurl . '/' . $platal->ns); |
| 76 | $this->infos['client'] = Array( |
| 77 | 'vads_cust_email' => S::user()->bestEmail(), |
| 78 | 'vads_cust_id' => S::v('uid'), |
| 79 | 'vads_cust_name' => replace_accent(S::user()->fullName())); |
| 80 | $this->infos['commande'] = Array( |
| 81 | 'vads_amount' => $this->val, |
| 82 | 'vads_currency' => '978', # Euro |
| 83 | 'vads_payment_config' => 'SINGLE', |
| 84 | 'vads_trans_date' => $trans_date, |
| 85 | 'vads_trans_id' => $trans_id, |
| 86 | 'vads_order_id' => $fullref, |
| 87 | 'vads_order_info' => Env::v('comment')); |
| 88 | $this->infos['divers'] = Array( |
| 89 | 'vads_version' => 'V2', |
| 90 | 'vads_ctx_mode' => $globals->money->cyperplus_prod, |
| 91 | 'vads_page_action' => 'PAYMENT', |
| 92 | 'vads_action_mode' => 'INTERACTIVE'); |
| 93 | |
| 94 | // Entry key computation. |
| 95 | $all_params = array_merge($this->infos['commercant'],$this->infos['client'],$this->infos['commande'],$this->infos['divers']); |
| 96 | ksort($all_params); |
| 97 | $this->infos['divers']['signature'] = sha1(join('+',$all_params).'+'.$globals->money->cyperplus_key); |
| 98 | } |
| 99 | |
| 100 | // }}} |
| 101 | } |
| 102 | |
| 103 | $api = 'BPLCCyberPlus'; |
| 104 | |
| 105 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
| 106 | ?> |