* Copyright (C) 2005-2007 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/paybox/lib/paybox.lib.php * \ingroup paybox * \brief Library for common paybox functions */ /** * Show header * * @param string $title Title of page * @param string $head Head string to add int head section * @return void */ function llxHeaderPaybox($title, $head = "") { global $user, $conf, $langs; header("Content-type: text/html; charset=".$conf->file->character_set_client); print ''; //print ''; print "\n"; print "\n"; print "\n"; print ''."\n"; print ''."\n"; print ''."\n"; print "".$title."\n"; if ($head) print $head."\n"; if (! empty($conf->global->PAYBOX_CSS_URL)) print ''."\n"; else { print ''."\n"; print ''; } print "\n"; print ''."\n"; } /** * Show footer * * @return void */ function llxFooterPayBox() { print "\n"; print "\n"; } /** * Create a redirect form to paybox form * * @param int $PRICE Price * @param string $CURRENCY Currency * @param string $EMAIL EMail * @param string $urlok Url to go back if payment is OK * @param string $urlko Url to go back if payment is KO * @param string $TAG Tag * @return int 1 if OK, -1 if ERROR */ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG) { global $conf, $langs, $db; dol_syslog("Paybox.lib::print_paybox_redirect", LOG_DEBUG); // Clean parameters $PBX_IDENTIFIANT="2"; // Identifiant pour v2 test if (! empty($conf->global->PAYBOX_PBX_IDENTIFIANT)) $PBX_IDENTIFIANT=$conf->global->PAYBOX_PBX_IDENTIFIANT; $IBS_SITE="1999888"; // Site test if (! empty($conf->global->PAYBOX_IBS_SITE)) $IBS_SITE=$conf->global->PAYBOX_IBS_SITE; $IBS_RANG="99"; // Rang test if (! empty($conf->global->PAYBOX_IBS_RANG)) $IBS_RANG=$conf->global->PAYBOX_IBS_RANG; $IBS_DEVISE="840"; // Currency (Dollar US by default) if ($CURRENCY == 'EUR') $IBS_DEVISE="978"; if ($CURRENCY == 'USD') $IBS_DEVISE="840"; $URLPAYBOX=""; if ($conf->global->PAYBOX_CGI_URL_V1) $URLPAYBOX=$conf->global->PAYBOX_CGI_URL_V1; if ($conf->global->PAYBOX_CGI_URL_V2) $URLPAYBOX=$conf->global->PAYBOX_CGI_URL_V2; if (empty($IBS_DEVISE)) { dol_print_error('',"Paybox setup param PAYBOX_IBS_DEVISE not defined"); return -1; } if (empty($URLPAYBOX)) { dol_print_error('',"Paybox setup param PAYBOX_CGI_URL_V1 and PAYBOX_CGI_URL_V2 undefined"); return -1; } if (empty($IBS_SITE)) { dol_print_error('',"Paybox setup param PAYBOX_IBS_SITE not defined"); return -1; } if (empty($IBS_RANG)) { dol_print_error('',"Paybox setup param PAYBOX_IBS_RANG not defined"); return -1; } // Definition des parametres vente produit pour paybox $IBS_CMD=$TAG; $IBS_TOTAL=$PRICE*100; // En centimes $IBS_MODE=1; // Mode formulaire $IBS_PORTEUR=$EMAIL; $IBS_RETOUR="montant:M;ref:R;auto:A;trans:T"; // Format des parametres du get de validation en reponse (url a definir sous paybox) $IBS_TXT=' '; // Use a space $IBS_BOUTPI=$langs->trans("Wait"); //$IBS_BOUTPI=''; $IBS_EFFECTUE=$urlok; $IBS_ANNULE=$urlko; $IBS_REFUSE=$urlko; $IBS_BKGD="#FFFFFF"; $IBS_WAIT="2000"; $IBS_LANG="GBR"; // By default GBR=english (FRA, GBR, ESP, ITA et DEU...) if (preg_match('/^FR/i',$langs->defaultlang)) $IBS_LANG="FRA"; if (preg_match('/^ES/i',$langs->defaultlang)) $IBS_LANG="ESP"; if (preg_match('/^IT/i',$langs->defaultlang)) $IBS_LANG="ITA"; if (preg_match('/^DE/i',$langs->defaultlang)) $IBS_LANG="DEU"; if (preg_match('/^NL/i',$langs->defaultlang)) $IBS_LANG="NLD"; if (preg_match('/^SE/i',$langs->defaultlang)) $IBS_LANG="SWE"; $IBS_OUTPUT='E'; $PBX_SOURCE='HTML'; $PBX_TYPEPAIEMENT='CARTE'; dol_syslog("Soumission Paybox", LOG_DEBUG); dol_syslog("IBS_MODE: $IBS_MODE", LOG_DEBUG); dol_syslog("IBS_SITE: $IBS_SITE", LOG_DEBUG); dol_syslog("IBS_RANG: $IBS_RANG", LOG_DEBUG); dol_syslog("IBS_TOTAL: $IBS_TOTAL", LOG_DEBUG); dol_syslog("IBS_DEVISE: $IBS_DEVISE", LOG_DEBUG); dol_syslog("IBS_CMD: $IBS_CMD", LOG_DEBUG); dol_syslog("IBS_PORTEUR: $IBS_PORTEUR", LOG_DEBUG); dol_syslog("IBS_RETOUR: $IBS_RETOUR", LOG_DEBUG); dol_syslog("IBS_EFFECTUE: $IBS_EFFECTUE", LOG_DEBUG); dol_syslog("IBS_ANNULE: $IBS_ANNULE", LOG_DEBUG); dol_syslog("IBS_REFUSE: $IBS_REFUSE", LOG_DEBUG); dol_syslog("IBS_BKGD: $IBS_BKGD", LOG_DEBUG); dol_syslog("IBS_WAIT: $IBS_WAIT", LOG_DEBUG); dol_syslog("IBS_LANG: $IBS_LANG", LOG_DEBUG); dol_syslog("IBS_OUTPUT: $IBS_OUTPUT", LOG_DEBUG); dol_syslog("PBX_IDENTIFIANT: $PBX_IDENTIFIANT", LOG_DEBUG); dol_syslog("PBX_SOURCE: $PBX_SOURCE", LOG_DEBUG); dol_syslog("PBX_TYPEPAIEMENT: $PBX_TYPEPAIEMENT", LOG_DEBUG); header("Content-type: text/html; charset=".$conf->file->character_set_client); print ''."\n"; print ''."\n"; print "\n"; print ''."\n"; print ''."\n"; print "\n"; // Formulaire pour module Paybox print '
'."\n"; // For Paybox V2 (PBX_xxx) print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; print '
'."\n"; print "\n"; print ''."\n"; print "\n"; print ''."\n"; print "\n"; return; } /** * Show footer of company in HTML pages * * @param Societe $fromcompany Third party * @param Translate $langs Output language * @return void */ function html_print_paybox_footer($fromcompany,$langs) { global $conf; // Juridical status $line1=""; if ($fromcompany->forme_juridique_code) { $line1.=($line1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); } // Capital if ($fromcompany->capital) { $line1.=($line1?" - ":"").$langs->transnoentities("CapitalOf",$fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency); } // Prof Id 1 if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) { $field=$langs->transcountrynoentities("ProfId1",$fromcompany->country_code); if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof1; } // Prof Id 2 if ($fromcompany->idprof2) { $field=$langs->transcountrynoentities("ProfId2",$fromcompany->country_code); if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; $line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof2; } // Second line of company infos $line2=""; // Prof Id 3 if ($fromcompany->idprof3) { $field=$langs->transcountrynoentities("ProfId3",$fromcompany->country_code); if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof3; } // Prof Id 4 if ($fromcompany->idprof4) { $field=$langs->transcountrynoentities("ProfId4",$fromcompany->country_code); if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; $line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof4; } // IntraCommunautary VAT if ($fromcompany->tva_intra != '') { $line2.=($line2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; } print '


'."\n"; print '
'."\n"; print $fromcompany->name.'
'; print $line1.'
'; print $line2; print '
'."\n"; }