Works on paypal module

New: possibility to use the price defined in paypal instead dolibarr price
This commit is contained in:
Regis Houssin 2011-05-25 06:49:39 +00:00
parent 8f8da6b4f0
commit ad05ce68a0
3 changed files with 19 additions and 16 deletions

View File

@ -34,6 +34,7 @@ PaypalCreateInvoiceEnabled=Enable the ability to create customer invoices
UseThePriceDefinedInPaypal=Use the price defined in Paypal instead of the one defined in Dolibarr
DefaultProductShippingCosts=Select the product to be used for adding shipping costs.
DefaultPaypalAccount=Select the bank account to be used as a Paypal account, this will deduct the Paypal fee when adding a payment.
ErrorProductWithRefNotSamePrice=The price set for the reference "<i>%s</i>" does not match the price Paypal
# Paypal transaction fields
PAYERID=Payer ID

View File

@ -34,6 +34,7 @@ PaypalCreateInvoiceEnabled=Activer la possibilité de créer des factures client
UseThePriceDefinedInPaypal=Utiliser le prix défini dans Paypal au lieu de celui défini dans Dolibarr
DefaultProductShippingCosts=Sélectionnez le produit qui sera utilisé pour l'ajout des frais de port.
DefaultPaypalAccount=Sélectionner le compte bancaire qui sera utilisé comme compte Paypal, ceci permettra de déduire les frais Paypal lors de l'ajout d'un paiement.
ErrorProductWithRefNotSamePrice=Le prix défini pour la référence "<i>%s</i>" ne correspond pas au prix Paypal
# Paypal transaction fields
PAYERID=ID du payeur

View File

@ -60,6 +60,8 @@ dol_syslog(join(',',$_GET));
if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transaction_id']) && ! empty($_GET['transaction_id']) )
{
$langs->load("paypal");
if ($_GET['action'] == 'add')
{
$soc = new Societe($db);
@ -176,27 +178,27 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
if ($ret > 0)
{
$qty=$_SESSION[$_GET['transaction_id']]["L_QTY".$i];
if ($_SESSION[$_GET['transaction_id']]["L_AMT".$i]) $amount_ht = ($_SESSION[$_GET['transaction_id']]["L_AMT".$i] - $_SESSION[$_GET['transaction_id']]["L_SHIPPINGAMT".$i]);
else $amount_ht = ($_SESSION[$_GET['transaction_id']]["AMT"] - $_SESSION[$_GET['transaction_id']]["SHIPAMOUNT"] - $_SESSION[$_GET['transaction_id']]["L_TAXAMT".$i]);
$unitprice_ht = ($amount_ht / $qty);
if ($conf->global->PAYPAL_USE_PRICE_DEFINED_IN_PAYPAL)
{
if ($_SESSION[$_GET['transaction_id']]["L_AMT".$i])
{
$amount_ht = ($_SESSION[$_GET['transaction_id']]["L_AMT".$i] - $_SESSION[$_GET['transaction_id']]["L_SHIPPINGAMT".$i]);
}
else
{
$amount_ht = ($_SESSION[$_GET['transaction_id']]["AMT"] - $_SESSION[$_GET['transaction_id']]["SHIPAMOUNT"] - $_SESSION[$_GET['transaction_id']]["L_TAXAMT".$i]);
}
$unitprice_ht = ($amount_ht / $qty);
$price=$unitprice_ht;
}
else
{
$unitprice_ht = $product->price;
$price=$product->price;
if ($price != $unitprice_ht)
{
$error++;
$return_arr['error'].= $langs->trans('ErrorProductWithRefNotSamePrice', $_SESSION[$_GET['transaction_id']]["L_NUMBER".$i]).'<br />';
break;
}
}
if ($subelement == 'commande') $fields = array($object_id,$product->description,$unitprice_ht,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,0,0,$product->price_base_type,0,'','',$product->product_type);
if ($subelement == 'facture') $fields = array($object_id,$product->description,$unitprice_ht,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,'','',0,0,0,$product->price_base_type,0,$product->product_type);
if ($subelement == 'commande') $fields = array($object_id,$product->description,$price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,0,0,$product->price_base_type,0,'','',$product->product_type);
if ($subelement == 'facture') $fields = array($object_id,$product->description,$price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,'','',0,0,0,$product->price_base_type,0,$product->product_type);
$result = $object->addline($fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5],$fields[6],$fields[7],$fields[8],$fields[9],$fields[10],$fields[11],$fields[12],$fields[13],$fields[14],$fields[15],$fields[16]);
@ -219,7 +221,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
}
// Add shipping costs
if ($shipamount > 0)
if (! $error && $shipamount > 0)
{
if ($conf->global->PAYPAL_PRODUCT_SHIPPING_COSTS)
{
@ -258,7 +260,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
}
// Add contact customer
if ($contact->id > 0)
if (! $error && $contact->id > 0)
{
$result=$object->add_contact($contact->id,'CUSTOMER','external');
if ($result < 0)
@ -292,7 +294,6 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
}
else if ($_GET['action'] == 'showdetails')
{
$langs->load('paypal');
$langs->load('orders');
$langs->load('bills');