Work on paypal module

This commit is contained in:
Laurent Destailleur 2010-10-31 18:57:11 +00:00
parent ed5f35d0f5
commit 5ba2e98adc
8 changed files with 152 additions and 109 deletions

View File

@ -786,6 +786,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
$vat_rate=str_replace('*','',$vat_rate);
$localtax1_rate=get_localtax($vat_rate,1,$object->client);
$localtax2_rate=get_localtax($vat_rate,2,$object->client);
$up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice');
// On verifie que le prix minimum est respecte
$productid = $_POST['productid'] ;
@ -794,21 +795,21 @@ if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST
$product = new Product($db) ;
$res=$product->fetch($productid) ;
}
if ($productid && $product->price_min && ( price2num($_POST['subprice'])*(1-price2num($_POST['remise_percent'])/100) < price2num($product->price_min)))
if ($productid && $product->price_min && (price2num($up_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($product->price_min)))
{
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($product->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
}
else
{
$result = $object->updateline($_POST['lineid'],
$_POST['subprice'],
$up_ht,
$_POST['qty'],
$_POST['remise_percent'],
$vat_rate,
$localtax1_rate,
$localtax2_rate,
$_POST['desc'],
'HT',
'HT',
$info_bits);
// Define output language

View File

@ -452,7 +452,8 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
{
if($prod->price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($prod->price_min)))
{
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($prod->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
//print "CantBeLessThanMinPrice ".$up_ht." - ".GETPOST('remise_percent')." - ".$product->price_min;
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($prod->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
}
else
{
@ -522,6 +523,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
$date_start=dol_mktime(0, 0, 0, $_POST['date_start'.$suffixe.'month'], $_POST['date_start'.$suffixe.'day'], $_POST['date_start'.$suffixe.'year']);
$date_end=dol_mktime(0, 0, 0, $_POST['date_end'.$suffixe.'month'], $_POST['date_end'.$suffixe.'day'], $_POST['date_end'.$suffixe.'year']);
$description=dol_htmlcleanlastbr($_POST['desc']);
$up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice');
// Define info_bits
$info_bits=0;
@ -547,7 +549,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
$product->fetch($productid);
$type=$product->type;
}
if ($product->price_min && ($_POST['productid']!='') && ( price2num($_POST['pu'])*(1-price2num($_POST['elremise_percent'])/100) < price2num($product->price_min)))
if ($product->price_min && GETPOST('productid') && (price2num($up_ht)*(1-price2num($_POST['elremise_percent'])/100) < price2num($product->price_min)))
{
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($product->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>' ;
$result=-1;
@ -567,7 +569,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POS
{
$result = $object->updateline($_POST['lineid'],
$description,
$_POST['pu'],
$up_ht,
$_POST['qty'],
$_POST['elremise_percent'],
$vat_rate,

View File

@ -963,6 +963,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
$date_start=dol_mktime($_POST['date_start'.$suffixe.'hour'],$_POST['date_start'.$suffixe.'min'],$_POST['date_start'.$suffixe.'sec'],$_POST['date_start'.$suffixe.'month'],$_POST['date_start'.$suffixe.'day'],$_POST['date_start'.$suffixe.'year']);
$date_end=dol_mktime($_POST['date_end'.$suffixe.'hour'],$_POST['date_end'.$suffixe.'min'],$_POST['date_end'.$suffixe.'sec'],$_POST['date_end'.$suffixe.'month'],$_POST['date_end'.$suffixe.'day'],$_POST['date_end'.$suffixe.'year']);
$description=dol_htmlcleanlastbr($_POST['desc']);
$up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice');
// Define info_bits
$info_bits=0;
@ -988,9 +989,9 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
$product->fetch($productid);
$type=$product->type;
}
if ($product->price_min && GETPOST('productid') && (price2num(GETPOST('subprice'))*(1-price2num(GETPOST('remise_percent'))/100) < price2num($product->price_min)))
if ($product->price_min && GETPOST('productid') && (price2num($up_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($product->price_min)))
{
print "CantBeLessThanMinPrice ".GETPOST('subprice')." - ".GETPOST('remise_percent')." - ".$product->price_min;
//print "CantBeLessThanMinPrice ".$up_ht." - ".GETPOST('remise_percent')." - ".$product->price_min;
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($product->price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)).'</div>';
$result=-1;
}
@ -1004,7 +1005,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
{
$result = $object->updateline(GETPOST('lineid'),
$description,
GETPOST('subprice'),
$up_ht,
GETPOST('qty'),
GETPOST('remise_percent'),
$date_start,

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -59,17 +59,18 @@ $langs->load("paybox");
// tag (a free text, required if type is empty)
// currency (iso code)
if (empty($_REQUEST["currency"])) $currency=$conf->global->MAIN_MONNAIE;
else $currency=$_REQUEST["currency"];
$suffix=GETPOST("suffix");
$amount=GETPOST("amount");
if (! GETPOST("currency")) $currency=$conf->global->MAIN_MONNAIE;
else $currency=GETPOST("currency");
if (! GETPOST("action"))
{
if (empty($_REQUEST["amount"]) && empty($_REQUEST["source"]))
if (! GETPOST("amount") && ! GETPOST("source"))
{
dol_print_error('',$langs->trans('ErrorBadParameters')." - amount or source");
exit;
}
$amount=$_REQUEST["amount"];
if (is_numeric($amount) && empty($_REQUEST["tag"]) && empty($_REQUEST["source"]))
{
dol_print_error('',$langs->trans('ErrorBadParameters')." - tag or source");
@ -81,8 +82,24 @@ if (! GETPOST("action"))
exit;
}
}
$suffix=GETPOST("suffix");
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root);
$urlok=$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/paymentok.php?';
$urlko=$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/paymentko.php?';
$TAG=GETPOST("tag");
$FULLTAG=GETPOST("fulltag"); // fulltag is tag with more informations
if (!empty($TAG))
{
$urlok.='tag='.$TAG.'&';
$urlko.='tag='.$TAG.'&';
}
if (!empty($FULLTAG))
{
$urlok.='fulltag='.$FULLTAG.'&';
$urlko.='fulltag='.$FULLTAG.'&';
}
/*
@ -90,24 +107,22 @@ $suffix=GETPOST("suffix");
*/
if ($_REQUEST["action"] == 'dopayment')
{
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root);
$PRICE=$_REQUEST["newamount"];
$EMAIL=$_REQUEST["EMAIL"];
$urlok=$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/paymentok.php';
$urlko=$urlwithouturlroot.DOL_URL_ROOT.'/public/paybox/paymentko.php';
$TAG=$_REQUEST["newtag"];
$ID=$_REQUEST["id"];
$PAYPAL_API_PRICE=price2num(GETPOST("newamount"));
$EMAIL=GETPOST("EMAIL");
$ID=GETPOST("id");
$mesg='';
if (empty($PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount"));
elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail"));
elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL);
elseif (empty($TAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode"));
elseif (empty($FULLTAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode"));
if (empty($mesg))
{
dol_syslog("newpayment.php call paybox api and do redirect", LOG_DEBUG);
print_paybox_redirect($PRICE, $conf->monnaie, $EMAIL, $urlok, $urlko, $TAG, $ID);
session_destroy();
exit;
}
@ -128,16 +143,22 @@ $paramcreditor='PAYBOX_CREDITOR_'.$suffix;
if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor;
else if (! empty($conf->global->PAYBOX_CREDITOR)) $creditor=$conf->global->PAYBOX_CREDITOR;
print '<span id="dolpaymentspan"></span>'."\n";
print '<center>';
print '<form name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<form id="dolpaymentform" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="dopayment">';
print '<input type="hidden" name="amount" value="'.$_REQUEST["amount"].'">';
print '<input type="hidden" name="tag" value="'.$_REQUEST["tag"].'">';
print '<input type="hidden" name="suffix" value="'.$_REQUEST["suffix"].'">';
print "\n";
print '<!-- Form to send a Paybox payment -->'."\n";
print '<!-- PAYBOX_CREDITOR = '.$conf->global->PAYPAL_CREDITOR.' -->'."\n";
print '<!-- urlok = '.$urlok.' -->'."\n";
print '<!-- urlko = '.$urlko.' -->'."\n";
print "\n";
print '<table style="font-size:14px;" summary="Logo" width="80%">'."\n";
print '<table id="dolpaymenttable" style="font-size:14px;" summary="Payment form" width="80%">'."\n";
// Show logo (search order: logo defined by PAYBOX_LOGO_suffix, then PAYBOX_LOGO, then small company logo, large company logo, theme logo, common logo)
$width=0;
@ -163,7 +184,7 @@ elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$lo
if ($urllogo)
{
print '<tr>';
print '<td align="center"><img title="'.$title.'" src="'.$urllogo.'"';
print '<td align="center"><img id="dolpaymentlogo" title="'.$title.'" src="'.$urllogo.'"';
if ($width) print ' width="'.$width.'"';
print '></td>';
print '</tr>'."\n";
@ -188,7 +209,7 @@ if (empty($_REQUEST["source"]))
{
$found=true;
$tag=$_REQUEST["tag"];
$newtag=$tag;
$fulltag=$tag;
// Creditor
$var=!$var;
@ -203,6 +224,7 @@ if (empty($_REQUEST["source"]))
if (empty($amount) || ! is_numeric($amount)) print '<input class="flat" size=8 type="text" name="newamount" value="'.$_REQUEST["newamount"].'">';
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
@ -213,9 +235,9 @@ if (empty($_REQUEST["source"]))
// Tag
$var=!$var;
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$newtag.'</b>';
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="newtag" value="'.$newtag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\n";
// EMail
@ -249,9 +271,9 @@ if ($_REQUEST["source"] == 'order')
$amount=$order->total_ttc;
if ($_REQUEST["amount"]) $amount=$_REQUEST["amount"];
$newtag='IR='.$order->ref.'.TPID='.$order->client->id.'.TP='.strtr($order->client->nom,"-"," ");
if (! empty($_REQUEST["tag"])) { $tag=$_REQUEST["tag"]; $newtag.='.TAG='.$_REQUEST["tag"]; }
$newtag=dol_string_unaccent($newtag);
$fulltag='IR='.$order->ref.'.TPID='.$order->client->id.'.TP='.strtr($order->client->nom,"-"," ");
if (! empty($_REQUEST["tag"])) { $tag=$_REQUEST["tag"]; $fulltag.='.TAG='.$_REQUEST["tag"]; }
$fulltag=dol_string_unaccent($fulltag);
// Creditor
$var=!$var;
@ -268,6 +290,7 @@ if ($_REQUEST["source"] == 'order')
$text='<b>'.$langs->trans("PaymentOrderRef",$order->ref).'</b>';
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.$_REQUEST["source"].'">';
print '<input type="hidden" name="ref" value="'.$order->ref.'">';
print '</td></tr>'."\n";
@ -279,6 +302,7 @@ if ($_REQUEST["source"] == 'order')
if (empty($amount) || ! is_numeric($amount)) print '<input class="flat" size=8 type="text" name="newamount" value="'.$_REQUEST["newamount"].'">';
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
@ -289,9 +313,9 @@ if ($_REQUEST["source"] == 'order')
// Tag
$var=!$var;
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$newtag.'</b>';
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="newtag" value="'.$newtag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\n";
// EMail
@ -327,9 +351,9 @@ if ($_REQUEST["source"] == 'invoice')
$amount=$invoice->total_ttc - $invoice->getSommePaiement();
if ($_REQUEST["amount"]) $amount=$_REQUEST["amount"];
$newtag='IR='.$invoice->ref.'.TPID='.$invoice->client->id.'.TP='.strtr($invoice->client->nom,"-"," ");
if (! empty($_REQUEST["tag"])) { $tag=$_REQUEST["tag"]; $newtag.='.TAG='.$_REQUEST["tag"]; }
$newtag=dol_string_unaccent($newtag);
$fulltag='IR='.$invoice->ref.'.TPID='.$invoice->client->id.'.TP='.strtr($invoice->client->nom,"-"," ");
if (! empty($_REQUEST["tag"])) { $tag=$_REQUEST["tag"]; $fulltag.='.TAG='.$_REQUEST["tag"]; }
$fulltag=dol_string_unaccent($fulltag);
// Creditor
$var=!$var;
@ -346,6 +370,7 @@ if ($_REQUEST["source"] == 'invoice')
$text='<b>'.$langs->trans("PaymentInvoiceRef",$invoice->ref).'</b>';
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.$_REQUEST["source"].'">';
print '<input type="hidden" name="ref" value="'.$invoice->ref.'">';
print '</td></tr>'."\n";
@ -357,6 +382,7 @@ if ($_REQUEST["source"] == 'invoice')
if (empty($amount) || ! is_numeric($amount)) print '<input class="flat" size=8 type="text" name="newamount" value="'.$_REQUEST["newamount"].'">';
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
@ -367,9 +393,9 @@ if ($_REQUEST["source"] == 'invoice')
// Tag
$var=!$var;
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$newtag.'</b>';
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="newtag" value="'.$newtag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\n";
// EMail
@ -448,9 +474,9 @@ if ($_REQUEST["source"] == 'contractline')
}
if ($_REQUEST["amount"]) $amount=$_REQUEST["amount"];
$newtag='CLR='.$contractline->ref.'.CR='.$contract->ref.'.TPID='.$contract->client->id.'.TP='.strtr($contract->client->nom,"-"," ");
if (! empty($_REQUEST["tag"])) { $tag=$_REQUEST["tag"]; $newtag.='.TAG='.$_REQUEST["tag"]; }
$newtag=dol_string_unaccent($newtag);
$fulltag='CLR='.$contractline->ref.'.CR='.$contract->ref.'.TPID='.$contract->client->id.'.TP='.strtr($contract->client->nom,"-"," ");
if (! empty($_REQUEST["tag"])) { $tag=$_REQUEST["tag"]; $fulltag.='.TAG='.$_REQUEST["tag"]; }
$fulltag=dol_string_unaccent($fulltag);
$qty=1;
if (isset($_REQUEST["qty"])) $qty=$_REQUEST["qty"];
@ -484,6 +510,7 @@ if ($_REQUEST["source"] == 'contractline')
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.$_REQUEST["source"].'">';
print '<input type="hidden" name="ref" value="'.$contractline->ref.'">';
print '</td></tr>'."\n";
@ -523,6 +550,7 @@ if ($_REQUEST["source"] == 'contractline')
if (empty($amount) || ! is_numeric($amount)) print '<input class="flat" size=8 type="text" name="newamount" value="'.$_REQUEST["newamount"].'">';
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
@ -533,9 +561,9 @@ if ($_REQUEST["source"] == 'contractline')
// Tag
$var=!$var;
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$newtag.'</b>';
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="newtag" value="'.$newtag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\n";
// EMail
@ -572,9 +600,9 @@ if ($_REQUEST["source"] == 'membersubscription')
$amount=$subscription->total_ttc;
if ($_REQUEST["amount"]) $amount=$_REQUEST["amount"];
$newtag='MID='.$member->id.'.M='.strtr($member->getFullName($langs),"-"," ");
if (! empty($_REQUEST["tag"])) { $tag=$_REQUEST["tag"]; $newtag.='.TAG='.$_REQUEST["tag"]; }
$newtag=dol_string_unaccent($newtag);
$fulltag='MID='.$member->id.'.M='.strtr($member->getFullName($langs),"-"," ");
if (! empty($_REQUEST["tag"])) { $tag=$_REQUEST["tag"]; $fulltag.='.TAG='.$_REQUEST["tag"]; }
$fulltag=dol_string_unaccent($fulltag);
// Creditor
$var=!$var;
@ -591,6 +619,7 @@ if ($_REQUEST["source"] == 'membersubscription')
$text='<b>'.$langs->trans("PaymentSubscription").'</b>';
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.$_REQUEST["source"].'">';
print '<input type="hidden" name="ref" value="'.$member->ref.'">';
print '</td></tr>'."\n";
@ -602,6 +631,7 @@ if ($_REQUEST["source"] == 'membersubscription')
if (empty($amount) || ! is_numeric($amount)) print '<input class="flat" size=8 type="text" name="newamount" value="'.$_REQUEST["newamount"].'">';
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
@ -612,9 +642,9 @@ if ($_REQUEST["source"] == 'membersubscription')
// Tag
$var=!$var;
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("PaymentCode");
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$newtag.'</b>';
print '</td><td class="CTableRow'.($var?'1':'2').'"><b>'.$fulltag.'</b>';
print '<input type="hidden" name="tag" value="'.$tag.'">';
print '<input type="hidden" name="newtag" value="'.$newtag.'">';
print '<input type="hidden" name="fulltag" value="'.$fulltag.'">';
print '</td></tr>'."\n";
// EMail
@ -631,9 +661,10 @@ if ($_REQUEST["source"] == 'membersubscription')
if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters");
if ($mesg) print '<tr><td align="center" colspan="2"><br><div class="warning">'.$mesg.'</div></td></tr>';
if ($mesg) print '<tr><td align="center" colspan="2"><br><div class="warning">'.$mesg.'</div></td></tr>'."\n";
print '</table>';
print '</table>'."\n";
print "\n";
if ($found && ! $error) // We are in a management option and no error
{
@ -645,11 +676,11 @@ else
dol_print_error_email();
}
print '</td></tr>';
print '</td></tr>'."\n";
print '</table>';
print '</form>';
print '</center>';
print '</table>'."\n";
print '</form>'."\n";
print '</center>'."\n";
print '<br>';

View File

@ -77,19 +77,10 @@ if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly')
// For payment with Credit card or Paypal
if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral')
{
$shipToName=GETPOST("shipToName");
$shipToStreet=GETPOST("shipToStreet");
$shipToCity=GETPOST("shipToCity");
$shipToState=GETPOST("shipToState");
$shipToCountryCode=GETPOST("shipToCountryCode");
$shipToZip=GETPOST("shipToZip");
$shipToStreet2=GETPOST("shipToStreet2");
$phoneNum=GETPOST("phoneNum");
dol_syslog("expresscheckout redirect with CallMarkExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum");
//$resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
$resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL,
$shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum);
$resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
//$resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL,
//$shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum);
}
// For direct payment with credit card
if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly')

View File

@ -60,17 +60,18 @@ $langs->load("paypal");
// tag (a free text, required if type is empty)
// currency (iso code)
if (empty($_REQUEST["currency"])) $currency=$conf->global->MAIN_MONNAIE;
else $currency=$_REQUEST["currency"];
$suffix=GETPOST("suffix");
$amount=GETPOST("amount");
if (! GETPOST("currency")) $currency=$conf->global->MAIN_MONNAIE;
else $currency=GETPOST("currency");
if (! GETPOST("action"))
{
if (empty($_REQUEST["amount"]) && empty($_REQUEST["source"]))
if (! GETPOST("amount") && ! GETPOST("source"))
{
dol_print_error('',$langs->trans('ErrorBadParameters')." - amount or source");
exit;
}
$amount=$_REQUEST["amount"];
if (is_numeric($amount) && empty($_REQUEST["tag"]) && empty($_REQUEST["source"]))
{
dol_print_error('',$langs->trans('ErrorBadParameters')." - tag or source");
@ -82,7 +83,6 @@ if (! GETPOST("action"))
exit;
}
}
$suffix=GETPOST("suffix");
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root);
$urlok=$urlwithouturlroot.DOL_URL_ROOT.'/public/paypal/paymentok.php?';
@ -109,10 +109,19 @@ if (!empty($FULLTAG))
*/
if (GETPOST("action") == 'dopayment')
{
$PAYPAL_API_PRICE=GETPOST("newamount");
$PAYPAL_API_PRICE=price2num(GETPOST("newamount"));
$EMAIL=GETPOST("EMAIL");
$ID=GETPOST("id");
$shipToName=GETPOST("shipToName");
$shipToStreet=GETPOST("shipToStreet");
$shipToCity=GETPOST("shipToCity");
$shipToState=GETPOST("shipToState");
$shipToCountryCode=GETPOST("shipToCountryCode");
$shipToZip=GETPOST("shipToZip");
$shipToStreet2=GETPOST("shipToStreet2");
$phoneNum=GETPOST("phoneNum");
$mesg='';
if (empty($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount"));
elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail"));
@ -122,16 +131,6 @@ if (GETPOST("action") == 'dopayment')
//var_dump($_POST);
if (empty($mesg))
{
/*
print_paypal_redirect($PAYPAL_API_PRICE, $conf->monnaie, $EMAIL, $urlok, $urlko, $TAG, $ID);
exit;
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("newpayment.php call paypal api and do redirect", LOG_DEBUG);
// Clean parameters
@ -169,7 +168,7 @@ if (GETPOST("action") == 'dopayment')
if ($CURRENCY == 'EUR') $PAYPAL_API_DEVISE="EUR";
if ($CURRENCY == 'USD') $PAYPAL_API_DEVISE="USD";
dol_syslog("Soumission Paypal", LOG_DEBUG);
dol_syslog("Submit Paypal form", LOG_DEBUG);
dol_syslog("PAYPAL_API_USER: $PAYPAL_API_USER", LOG_DEBUG);
//dol_syslog("PAYPAL_API_PASSWORD: $PAYPAL_API_PASSWORD", LOG_DEBUG); // No password into log files
dol_syslog("PAYPAL_API_SIGNATURE: $PAYPAL_API_SIGNATURE", LOG_DEBUG);
@ -178,6 +177,14 @@ if (GETPOST("action") == 'dopayment')
dol_syslog("PAYPAL_API_KO: $PAYPAL_API_KO", LOG_DEBUG);
dol_syslog("PAYPAL_API_PRICE: $PAYPAL_API_PRICE", LOG_DEBUG);
dol_syslog("PAYPAL_API_DEVISE: $PAYPAL_API_DEVISE", LOG_DEBUG);
dol_syslog("shipToName: $shipToName", LOG_DEBUG);
dol_syslog("shipToStreet: $shipToStreet", LOG_DEBUG);
dol_syslog("shipToCity: $shipToCity", LOG_DEBUG);
dol_syslog("shipToState: $shipToState", LOG_DEBUG);
dol_syslog("shipToCountryCode: $shipToCountryCode", LOG_DEBUG);
dol_syslog("shipToZip: $shipToZip", LOG_DEBUG);
dol_syslog("shipToStreet2: $shipToStreet2", LOG_DEBUG);
dol_syslog("phoneNum: $phoneNum", LOG_DEBUG);
header("Content-type: text/html; charset=".$conf->file->character_set_client);
@ -193,27 +200,9 @@ if (GETPOST("action") == 'dopayment')
// A redirect is added if API call successfull
require_once(DOL_DOCUMENT_ROOT."/public/paypal/expresscheckout.php");
// Formulaire pour module Paybox
// print '<form action="'.$URLPAYBOX.'" NAME="Submit" method="POST">'."\n";
//print "
//<form action='".DOL_URL_ROOT."/paypal/expresscheckout.php' METHOD='POST' NAME='Submit'>
//<input type='image' name='submit' src='https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif' border='0' align='top' alt='Check out with PayPal'/>
//</form>";
// print '</form>'."\n";
// print "\n";
// print '<script type="text/javascript" language="javascript">'."\n";
// print ' document.Submit.submit();'."\n";
// print '</script>'."\n";
// print "\n";
print '</body></html>'."\n";
print "\n";
exit;
}
}
@ -233,8 +222,9 @@ $paramcreditor='PAYPAL_CREDITOR_'.$suffix;
if (! empty($conf->global->$paramcreditor)) $creditor=$conf->global->$paramcreditor;
else if (! empty($conf->global->PAYPAL_CREDITOR)) $creditor=$conf->global->PAYPAL_CREDITOR;
print '<span id="dolpaymentspan"></span>'."\n";
print '<center>'."\n";
print '<form name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<form id="dolpaymentform" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
print '<input type="hidden" name="action" value="dopayment">'."\n";
print '<input type="hidden" name="amount" value="'.$_REQUEST["amount"].'">'."\n";
@ -249,7 +239,7 @@ print '<!-- urlok = '.$urlok.' -->'."\n";
print '<!-- urlko = '.$urlko.' -->'."\n";
print "\n";
print '<table style="font-size:14px;" summary="Logo" width="80%">'."\n";
print '<table id="dolpaymenttable" style="font-size:14px;" summary="Payment form" width="80%">'."\n";
// Show logo (search order: logo defined by PAYBOX_LOGO_suffix, then PAYBOX_LOGO, then small company logo, large company logo, theme logo, common logo)
$width=0;
@ -275,7 +265,7 @@ elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$lo
if ($urllogo)
{
print '<tr>';
print '<td align="center"><img title="'.$title.'" src="'.$urllogo.'"';
print '<td align="center"><img id="dolpaymentlogo" title="'.$title.'" src="'.$urllogo.'"';
if ($width) print ' width="'.$width.'"';
print '></td>';
print '</tr>'."\n";
@ -315,6 +305,7 @@ if (empty($_REQUEST["source"]))
if (empty($amount) || ! is_numeric($amount)) print '<input class="flat" size=8 type="text" name="newamount" value="'.$_REQUEST["newamount"].'">';
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
@ -335,6 +326,9 @@ if (empty($_REQUEST["source"]))
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("YourEMail");
print ' ('.$langs->trans("ToComplete").')';
print '</td><td class="CTableRow'.($var?'1':'2').'"><input class="flat" type="text" name="EMAIL" size="48" value="'.$_REQUEST["EMAIL"].'"></td></tr>'."\n";
// We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum
// as they don't exists (buyer is unknown, tag is free).
}
@ -380,6 +374,7 @@ if ($_REQUEST["source"] == 'order')
$text='<b>'.$langs->trans("PaymentOrderRef",$order->ref).'</b>';
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.$_REQUEST["source"].'">';
print '<input type="hidden" name="ref" value="'.$order->ref.'">';
print '</td></tr>'."\n";
@ -391,6 +386,7 @@ if ($_REQUEST["source"] == 'order')
if (empty($amount) || ! is_numeric($amount)) print '<input class="flat" size=8 type="text" name="newamount" value="'.$_REQUEST["newamount"].'">';
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
@ -414,8 +410,15 @@ if ($_REQUEST["source"] == 'order')
$email=(GETPOST("EMAIL")?GETPOST("EMAIL"):(isValidEmail($email)?$email:''));
print '</td><td class="CTableRow'.($var?'1':'2').'"><input class="flat" type="text" name="EMAIL" size="48" value="'.$email.'"></td></tr>'."\n";
// We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum
// as they don't exists (buyer is unknown, tag is free).
// Shipping address
print '<input type="hidden" name="shipToName" value="'.$shipToName.'">'."\n";
print '<input type="hidden" name="shipToStreet" value="'.$shipToStreet.'">'."\n";
print '<input type="hidden" name="shipToCity" value="'.$shipToCity.'">'."\n";
print '<input type="hidden" name="shipToState" value="'.$shipToState.'">'."\n";
print '<input type="hidden" name="shipToCountryCode" value="'.$shipToCountryCode.'">'."\n";
print '<input type="hidden" name="shipToZip" value="'.$shipToZip.'">'."\n";
print '<input type="hidden" name="shipToStreet2" value="'.$shipToStreet2.'">'."\n";
print '<input type="hidden" name="phoneNum" value="'.$phoneNum.'">'."\n";
}
@ -461,6 +464,7 @@ if ($_REQUEST["source"] == 'invoice')
$text='<b>'.$langs->trans("PaymentInvoiceRef",$invoice->ref).'</b>';
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.$_REQUEST["source"].'">';
print '<input type="hidden" name="ref" value="'.$invoice->ref.'">';
print '</td></tr>'."\n";
@ -472,6 +476,7 @@ if ($_REQUEST["source"] == 'invoice')
if (empty($amount) || ! is_numeric($amount)) print '<input class="flat" size=8 type="text" name="newamount" value="'.$_REQUEST["newamount"].'">';
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
@ -602,6 +607,7 @@ if ($_REQUEST["source"] == 'contractline')
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.$_REQUEST["source"].'">';
print '<input type="hidden" name="ref" value="'.$contractline->ref.'">';
print '</td></tr>'."\n";
@ -641,6 +647,7 @@ if ($_REQUEST["source"] == 'contractline')
if (empty($amount) || ! is_numeric($amount)) print '<input class="flat" size=8 type="text" name="newamount" value="'.$_REQUEST["newamount"].'">';
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
@ -710,6 +717,7 @@ if ($_REQUEST["source"] == 'membersubscription')
$text='<b>'.$langs->trans("PaymentSubscription").'</b>';
print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("Designation");
print '</td><td class="CTableRow'.($var?'1':'2').'">'.$text;
print '<input type="hidden" name="source" value="'.$_REQUEST["source"].'">';
print '<input type="hidden" name="ref" value="'.$member->ref.'">';
print '</td></tr>'."\n";
@ -721,6 +729,7 @@ if ($_REQUEST["source"] == 'membersubscription')
if (empty($amount) || ! is_numeric($amount)) print '<input class="flat" size=8 type="text" name="newamount" value="'.$_REQUEST["newamount"].'">';
else {
print '<b>'.price($amount).'</b>';
print '<input type="hidden" name="amount" value="'.$amount.'">';
print '<input type="hidden" name="newamount" value="'.$amount.'">';
}
// Currency
@ -779,7 +788,7 @@ print '</td></tr>'."\n";
print '</table>'."\n";
print '</form>'."\n";
print '</center>';
print '</center>'."\n";
print '<br>';

View File

@ -62,6 +62,10 @@ llxHeaderPaypal($langs->trans("PaymentForm"));
print $langs->trans("YourPaymentHasNotBeenRecorded");
//require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.php");
//$PAYPALTOKEN=GETPOST('paypaltoken');
//$resarray=GetShippingDetails($PAYPALTOKEN);
//var_dump($resarray);
html_print_paypal_footer($mysoc,$langs);

View File

@ -64,6 +64,10 @@ llxHeaderPaypal($langs->trans("PaymentForm"));
print $langs->trans("YourPaymentHasBeenRecorded");
//require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.php");
//$PAYPALTOKEN=GETPOST('paypaltoken');
//$resarray=GetShippingDetails($PAYPALTOKEN);
//var_dump($resarray);
html_print_paypal_footer($mysoc,$langs);