* 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 2 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ */ /** * \file htdocs/paypal/lib/paypal.lib.php * \brief Library for common paypal functions * \version $Id$ */ function llxHeaderPaypal($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 ($conf->global->PAYPAL_CSS_URL) print ''."\n"; else { print ''."\n"; print ''; } print "\n"; print ''."\n"; } function llxFooterPaypal() { print "\n"; print "\n"; } /** * \brief Create a redirect form to paypal form * \return int 1 if OK, -1 if ERROR */ function print_paypal_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG) { global $conf, $langs, $db; global $PAYPAL_API_USER, $PAYPAL_API_PASSWORD, $PAYPAL_API_SIGNATURE; global $PAYPAL_API_DEVISE, $PAYPAL_API_OK, $PAYPAL_API_KO; global $PAYPAL_API_SANDBOX; dol_syslog("Paypal.lib::print_paypal_redirect", LOG_DEBUG); // Clean parameters $PAYPAL_API_USER=""; if ($conf->global->PAYPAL_API_USER) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; $PAYPAL_API_PASSWORD=""; if ($conf->global->PAYPAL_API_PASSWORD) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; $PAYPAL_API_SIGNATURE=""; if ($conf->global->PAYPAL_API_SIGNATURE) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; $PAYPAL_API_SANDBOX=""; if ($conf->global->PAYPAL_API_SANDBOX) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; if (empty($PAYPAL_API_USER)) { dol_print_error('',"Paypal setup param PAYPAL_API_USER not defined"); return -1; } if (empty($PAYPAL_API_PASSWORD)) { dol_print_error('',"Paypal setup param PAYPAL_API_PASSWORD not defined"); return -1; } if (empty($PAYPAL_API_SIGNATURE)) { dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); return -1; } // Other $PAYPAL_API_DEVISE="EUR"; if ($CURRENCY == 'EUR') $PAYPAL_API_DEVISE="EUR"; if ($CURRENCY == 'USD') $PAYPAL_API_DEVISE="USD"; $PAYPAL_API_OK=$urlok; $PAYPAL_API_KO=$urlko; dol_syslog("Soumission Paypal", LOG_DEBUG); dol_syslog("PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG); dol_syslog("PAYPAL_API_PASSWORD: $PAYPAL_API_PASSWORD", LOG_DEBUG); dol_syslog("PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG); dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG); dol_syslog("PAYPAL_API_OK: $PAYPAL_API_OK", LOG_DEBUG); dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG); dol_syslog("PAYPAL_API_SANDBOX: $PAYPAL_API_SANDBOX", 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"; $_SESSION["Payment_Amount"]=$PRICE; // A redirect is added if API call successfull require_once(DOL_DOCUMENT_ROOT."/paypal/expresscheckout.php"); // Formulaire pour module Paybox // print '
'."\n"; //print " // // //
"; // print ''."\n"; // print "\n"; // print ''."\n"; // print "\n"; print ''."\n"; print "\n"; return; } /** * Show footer of company in HTML pages * * @param $fromcompany * @param $langs */ function html_print_paypal_footer($fromcompany,$langs) { global $conf; // Juridical status $ligne1=""; if ($fromcompany->forme_juridique_code) { $ligne1.=($ligne1?" - ":"").$langs->convToOutputCharset(getFormeJuridiqueLabel($fromcompany->forme_juridique_code)); } // Capital if ($fromcompany->capital) { $ligne1.=($ligne1?" - ":"").$langs->transnoentities("CapitalOf",$fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->monnaie); } // Prof Id 1 if ($fromcompany->idprof1 && ($fromcompany->pays_code != 'FR' || ! $fromcompany->idprof2)) { $field=$langs->transcountrynoentities("ProfId1",$fromcompany->pays_code); if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; $ligne1.=($ligne1?" - ":"").$field.": ".$langs->convToOutputCharset($fromcompany->idprof1); } // Prof Id 2 if ($fromcompany->idprof2) { $field=$langs->transcountrynoentities("ProfId2",$fromcompany->pays_code); if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; $ligne1.=($ligne1?" - ":"").$field.": ".$langs->convToOutputCharset($fromcompany->idprof2); } // Second line of company infos $ligne2=""; // Prof Id 3 if ($fromcompany->idprof3) { $field=$langs->transcountrynoentities("ProfId3",$fromcompany->pays_code); if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; $ligne2.=($ligne2?" - ":"").$field.": ".$langs->convToOutputCharset($fromcompany->idprof3); } // Prof Id 4 if ($fromcompany->idprof4) { $field=$langs->transcountrynoentities("ProfId4",$fromcompany->pays_code); if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; $ligne2.=($ligne2?" - ":"").$field.": ".$langs->convToOutputCharset($fromcompany->idprof4); } // IntraCommunautary VAT if ($fromcompany->tva_intra != '') { $ligne2.=($ligne2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$langs->convToOutputCharset($fromcompany->tva_intra); } print '


'."\n"; print '
'."\n"; print $fromcompany->nom.'
'; print $ligne1.'
'; print $ligne2; print '
'."\n"; } ?>