Works on paypal module
This commit is contained in:
parent
4f1c3f774c
commit
0dc4f7db10
@ -18,18 +18,23 @@ PAYPAL_CSS_URL=Optionnal Url of CSS style sheet on payment page
|
|||||||
ThisIsTransactionId=This is id of transaction: <b>%s</b>
|
ThisIsTransactionId=This is id of transaction: <b>%s</b>
|
||||||
PaypalTransactionDesc=This options allows you to import Paypal payments in Dolibarr as orders, invoices, etc ...
|
PaypalTransactionDesc=This options allows you to import Paypal payments in Dolibarr as orders, invoices, etc ...
|
||||||
PaypalEnableThisTool=Enable this functionnality
|
PaypalEnableThisTool=Enable this functionnality
|
||||||
|
Unverified=Unverified
|
||||||
|
Unconfirmed=Unconfirmed
|
||||||
|
GrossAmount=Gross amount
|
||||||
|
FeeAmount=Fee amount
|
||||||
|
NetAmount=Net amount
|
||||||
|
CustomerDetails=Customer details
|
||||||
|
|
||||||
# Paypal transaction fields
|
# Paypal transaction fields
|
||||||
PAYERID=
|
PAYERID=Payer ID
|
||||||
PAYERSTATUS=
|
PAYERSTATUS=Payer status
|
||||||
ADDRESSSTATUS=
|
ADDRESSSTATUS=Address status
|
||||||
TRANSACTIONID=
|
TRANSACTIONID=Transaction ID
|
||||||
TRANSACTIONTYPE=
|
TRANSACTIONTYPE=Transaction type
|
||||||
PAYMENTTYPE=
|
PAYMENTTYPE=Payment type
|
||||||
AMT=
|
PAYMENTSTATUS=Payment status
|
||||||
FEEAMT=
|
SHIPAMOUNT=Ship amount
|
||||||
TAXAMT=
|
|
||||||
PAYMENTSTATUS=
|
|
||||||
PENDINGREASON=
|
PENDINGREASON=
|
||||||
REASONCODE=
|
REASONCODE=
|
||||||
SHIPPINGMETHOD=
|
SHIPPINGMETHOD=
|
||||||
|
|||||||
@ -18,18 +18,23 @@ PAYPAL_CSS_URL=Url optionnelle de la feuille de style CSS de la page de paiement
|
|||||||
ThisIsTransactionId=Voici l'identifiant de la transaction: <b>%s</b>
|
ThisIsTransactionId=Voici l'identifiant de la transaction: <b>%s</b>
|
||||||
PaypalTransactionDesc=Ces options permettent d'importer des paiements Paypal dans Dolibarr en tant que commandes, factures, etc...
|
PaypalTransactionDesc=Ces options permettent d'importer des paiements Paypal dans Dolibarr en tant que commandes, factures, etc...
|
||||||
PaypalEnableThisTool=Activer ces fonctionnalités
|
PaypalEnableThisTool=Activer ces fonctionnalités
|
||||||
|
Unverified=Non vérifié
|
||||||
|
Unconfirmed=Non confirmée
|
||||||
|
GrossAmount=Montant brut
|
||||||
|
FeeAmount=Frais Paypal
|
||||||
|
NetAmount=Montant net
|
||||||
|
CustomerDetails=Détail du client
|
||||||
|
|
||||||
# Paypal transaction fields
|
# Paypal transaction fields
|
||||||
PAYERID=
|
PAYERID=ID du payeur
|
||||||
PAYERSTATUS=
|
PAYERSTATUS=Statut du payeur
|
||||||
ADDRESSSTATUS=
|
ADDRESSSTATUS=Statut de l'adresse
|
||||||
TRANSACTIONID=
|
TRANSACTIONID=ID de transaction
|
||||||
TRANSACTIONTYPE=
|
TRANSACTIONTYPE=Type de transaction
|
||||||
PAYMENTTYPE=
|
PAYMENTTYPE=Type de paiement
|
||||||
AMT=
|
PAYMENTSTATUS=Statut du paiement
|
||||||
FEEAMT=
|
SHIPAMOUNT=Frais de port
|
||||||
TAXAMT=
|
|
||||||
PAYMENTSTATUS=
|
|
||||||
PENDINGREASON=
|
PENDINGREASON=
|
||||||
REASONCODE=
|
REASONCODE=
|
||||||
SHIPPINGMETHOD=
|
SHIPPINGMETHOD=
|
||||||
|
|||||||
@ -63,7 +63,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
if ($_GET['action'] == 'add')
|
if ($_GET['action'] == 'add')
|
||||||
{
|
{
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
|
|
||||||
// Create customer if not exists
|
// Create customer if not exists
|
||||||
$ret = $soc->fetchObjectFromRefExt($soc->table_element,$_SESSION[$_GET['transaction_id']]['PAYERID']);
|
$ret = $soc->fetchObjectFromRefExt($soc->table_element,$_SESSION[$_GET['transaction_id']]['PAYERID']);
|
||||||
if ($ret < 0)
|
if ($ret < 0)
|
||||||
@ -77,7 +77,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
}
|
}
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
|
||||||
$modCodeClient = new $module;
|
$modCodeClient = new $module;
|
||||||
|
|
||||||
// Create customer and return rowid
|
// Create customer and return rowid
|
||||||
$soc->ref_ext = $_SESSION[$_GET['transaction_id']]['PAYERID'];
|
$soc->ref_ext = $_SESSION[$_GET['transaction_id']]['PAYERID'];
|
||||||
$soc->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_SESSION[$_GET['transaction_id']]['FIRSTNAME'].' '.$_SESSION[$_GET['transaction_id']]['LASTNAME']):trim($_SESSION[$_GET['transaction_id']]['LASTNAME'].' '.$_SESSION[$_GET['transaction_id']]['FIRSTNAME']);
|
$soc->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_SESSION[$_GET['transaction_id']]['FIRSTNAME'].' '.$_SESSION[$_GET['transaction_id']]['LASTNAME']):trim($_SESSION[$_GET['transaction_id']]['LASTNAME'].' '.$_SESSION[$_GET['transaction_id']]['FIRSTNAME']);
|
||||||
@ -92,7 +92,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
$soc->tva_assuj = 1;
|
$soc->tva_assuj = 1;
|
||||||
$soc->client = 1;
|
$soc->client = 1;
|
||||||
$soc->particulier = 1;
|
$soc->particulier = 1;
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
$result = $soc->create($user);
|
$result = $soc->create($user);
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
@ -100,7 +100,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
if ($soc->particulier)
|
if ($soc->particulier)
|
||||||
{
|
{
|
||||||
$contact=new Contact($db);
|
$contact=new Contact($db);
|
||||||
|
|
||||||
$contact->civilite_id = $soc->civilite_id;
|
$contact->civilite_id = $soc->civilite_id;
|
||||||
$contact->name=$soc->nom_particulier;
|
$contact->name=$soc->nom_particulier;
|
||||||
$contact->firstname=$soc->prenom;
|
$contact->firstname=$soc->prenom;
|
||||||
@ -114,11 +114,11 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
$contact->status=1;
|
$contact->status=1;
|
||||||
$contact->email=$soc->email;
|
$contact->email=$soc->email;
|
||||||
$contact->priv=0;
|
$contact->priv=0;
|
||||||
|
|
||||||
$result=$contact->create($user);
|
$result=$contact->create($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
@ -131,12 +131,12 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
echo $langs->trans($soc->error);
|
echo $langs->trans($soc->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add element (order, bill, etc.)
|
// Add element (order, bill, etc.)
|
||||||
if ($soc->id > 0 && isset($_GET['element']) && ! empty($_GET['element']))
|
if ($soc->id > 0 && isset($_GET['element']) && ! empty($_GET['element']))
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Parse element/subelement (ex: project_task)
|
// Parse element/subelement (ex: project_task)
|
||||||
$element = $subelement = $_GET['element'];
|
$element = $subelement = $_GET['element'];
|
||||||
if (preg_match('/^([^_]+)_([^_]+)/i',$_GET['element'],$regs))
|
if (preg_match('/^([^_]+)_([^_]+)/i',$_GET['element'],$regs))
|
||||||
@ -151,31 +151,30 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
|
|
||||||
$classname = ucfirst($subelement);
|
$classname = ucfirst($subelement);
|
||||||
$object = new $classname($db);
|
$object = new $classname($db);
|
||||||
|
|
||||||
$object->socid=$soc->id;
|
$object->socid=$soc->id;
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$object->date = dol_now();
|
$object->date = dol_now();
|
||||||
$object->ref_ext = $_SESSION[$_GET['transaction_id']]['SHIPTOCITY'];
|
$object->ref_ext = $_SESSION[$_GET['transaction_id']]['SHIPTOCITY'];
|
||||||
|
|
||||||
$object_id = $object->create($user);
|
$object_id = $object->create($user);
|
||||||
if ($object_id > 0)
|
if ($object_id > 0)
|
||||||
{
|
{
|
||||||
$i=0;
|
$i=0;
|
||||||
|
|
||||||
// Add element lines
|
// Add element lines
|
||||||
while (isset($_SESSION[$_GET['transaction_id']]["L_NAME".$i]))
|
while (isset($_SESSION[$_GET['transaction_id']]["L_NAME".$i]))
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
|
|
||||||
$ret = $product->fetch('',$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i]);
|
$ret = $product->fetch('',$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i]);
|
||||||
|
|
||||||
if ($ret > 0)
|
if ($ret > 0)
|
||||||
{
|
{
|
||||||
$product_type=($product->product_type?$product->product_type:0);
|
$product_type=($product->product_type?$product->product_type:0);
|
||||||
|
|
||||||
$result = $object->addline(
|
$result = $object->addline(
|
||||||
$object_id,
|
$object_id,
|
||||||
$product->description,
|
$product->description,
|
||||||
@ -194,17 +193,17 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
'',
|
'',
|
||||||
$product_type
|
$product_type
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert default contacts
|
// Insert default contacts
|
||||||
/*
|
/*
|
||||||
if ($contact->id > 0)
|
if ($contact->id > 0)
|
||||||
@ -218,7 +217,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($object_id > 0 && ! $error)
|
if ($object_id > 0 && ! $error)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
@ -231,71 +230,82 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
|
|||||||
|
|
||||||
// Return element id
|
// Return element id
|
||||||
echo $object->getNomUrl(0,0,1);
|
echo $object->getNomUrl(0,0,1);
|
||||||
|
/*
|
||||||
/*
|
|
||||||
foreach ($_SESSION[$_GET['transaction_id']] as $key => $value)
|
foreach ($_SESSION[$_GET['transaction_id']] as $key => $value)
|
||||||
{
|
{
|
||||||
echo $key.': '.$value.'<br />';
|
echo $key.': '.$value.'<br />';
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
else if ($_GET['action'] == 'showdetails')
|
else if ($_GET['action'] == 'showdetails')
|
||||||
{
|
{
|
||||||
|
$langs->load('paypal');
|
||||||
|
|
||||||
// For paypal request optimization
|
// For paypal request optimization
|
||||||
if (! isset($_SESSION[$_GET['transaction_id']]) ) $_SESSION[$_GET['transaction_id']] = GetTransactionDetails($_GET['transaction_id']);
|
if (! isset($_SESSION[$_GET['transaction_id']]) ) $_SESSION[$_GET['transaction_id']] = GetTransactionDetails($_GET['transaction_id']);
|
||||||
|
|
||||||
$var=true;
|
$var=true;
|
||||||
|
|
||||||
echo '<table style="noboardernopading" width="100%">';
|
echo '<table style="noboardernopading" width="100%">';
|
||||||
echo '<tr class="liste_titre">';
|
echo '<tr class="liste_titre">';
|
||||||
echo '<td colspan="2">'.$langs->trans('ThirdParty').'</td>';
|
echo '<td colspan="2">'.$langs->trans('ThirdParty').'</td>';
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
echo '<tr '.$bc[$var].'><td>'.$langs->trans('LastName').': </td><td>'.$_SESSION[$_GET['transaction_id']]['LASTNAME'].'</td></tr>';
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('LastName').'</td><td>'.$_SESSION[$_GET['transaction_id']]['LASTNAME'].'</td></tr>';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
echo '<tr '.$bc[$var].'><td>'.$langs->trans('FirstName').': </td><td>'.$_SESSION[$_GET['transaction_id']]['FIRSTNAME'].'</td></tr>';
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('FirstName').'</td><td>'.$_SESSION[$_GET['transaction_id']]['FIRSTNAME'].'</td></tr>';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Address').': </td><td>'.$_SESSION[$_GET['transaction_id']]['SHIPTOSTREET'].'</td></tr>';
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Address').'</td><td>'.$_SESSION[$_GET['transaction_id']]['SHIPTOSTREET'].'</td></tr>';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').': </td><td>'.$_SESSION[$_GET['transaction_id']]['SHIPTOZIP'].' '.$_SESSION[$_GET['transaction_id']]['SHIPTOCITY'].'</td></tr>';
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Zip').' / '.$langs->trans('Town').'</td><td>'.$_SESSION[$_GET['transaction_id']]['SHIPTOZIP'].' '.$_SESSION[$_GET['transaction_id']]['SHIPTOCITY'].'</td></tr>';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Country').': </td><td>'.$_SESSION[$_GET['transaction_id']]['SHIPTOCOUNTRYNAME'].'</td></tr>';
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Country').'</td><td>'.$_SESSION[$_GET['transaction_id']]['SHIPTOCOUNTRYNAME'].'</td></tr>';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Email').': </td><td>'.$_SESSION[$_GET['transaction_id']]['EMAIL'].'</td>';
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Email').'</td><td>'.$_SESSION[$_GET['transaction_id']]['EMAIL'].'</td>';
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Date').': </td><td>'.dol_print_date(dol_stringtotime($_SESSION[$_GET['transaction_id']]['ORDERTIME']),'dayhour').'</td>';
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('Date').'</td><td>'.dol_print_date(dol_stringtotime($_SESSION[$_GET['transaction_id']]['ORDERTIME']),'dayhour').'</td>';
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('PAYERSTATUS').'</td><td>'.$langs->trans(ucfirst($_SESSION[$_GET['transaction_id']]['PAYERSTATUS'])).'</td>';
|
||||||
|
$var=!$var;
|
||||||
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('ADDRESSSTATUS').'</td><td>'.$langs->trans(ucfirst($_SESSION[$_GET['transaction_id']]['ADDRESSSTATUS'])).'</td>';
|
||||||
|
|
||||||
|
$shipamount=($_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']?$_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']:$_SESSION[$_GET['transaction_id']]['SHIPAMOUNT']);
|
||||||
|
$var=!$var;
|
||||||
|
echo '<tr '.$bc[$var].'><td>'.$langs->trans('SHIPAMOUNT').'</td><td>'.price($shipamount).' '.$_SESSION[$_GET['transaction_id']]['CURRENCYCODE'].'</td>';
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
|
|
||||||
echo '<table style="noboardernopading" width="100%">';
|
echo '<table style="noboardernopading" width="100%">';
|
||||||
|
|
||||||
echo '<tr class="liste_titre">';
|
echo '<tr class="liste_titre">';
|
||||||
echo '<td>'.$langs->trans('Ref').'</td>';
|
echo '<td>'.$langs->trans('Ref').'</td>';
|
||||||
echo '<td>'.$langs->trans('Label').'</td>';
|
echo '<td>'.$langs->trans('Label').'</td>';
|
||||||
echo '<td>'.$langs->trans('Qty').'</td>';
|
echo '<td>'.$langs->trans('Qty').'</td>';
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
|
|
||||||
while (isset($_SESSION[$_GET['transaction_id']]["L_NAME".$i]))
|
while (isset($_SESSION[$_GET['transaction_id']]["L_NAME".$i]))
|
||||||
{
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
echo '<tr '.$bc[$var].'>';
|
echo '<tr '.$bc[$var].'>';
|
||||||
echo '<td>'.$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i].'</td>';
|
echo '<td>'.$_SESSION[$_GET['transaction_id']]["L_NUMBER".$i].'</td>';
|
||||||
echo '<td>'.$_SESSION[$_GET['transaction_id']]["L_NAME".$i].'</td>';
|
echo '<td>'.$_SESSION[$_GET['transaction_id']]["L_NAME".$i].'</td>';
|
||||||
echo '<td>'.$_SESSION[$_GET['transaction_id']]["L_QTY".$i].'</td>';
|
echo '<td>'.$_SESSION[$_GET['transaction_id']]["L_QTY".$i].'</td>';
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
|
|
||||||
|
|
||||||
foreach ($_SESSION[$_GET['transaction_id']] as $key => $value)
|
foreach ($_SESSION[$_GET['transaction_id']] as $key => $value)
|
||||||
{
|
{
|
||||||
echo $key.': '.$value.'<br />';
|
echo $key.': '.$value.'<br />';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user