forked from Wavyzz/dolibarr
Works on enhancement of paypal module
New: add triggers for post treatment New: possibility to add payment link to email
This commit is contained in:
@@ -477,7 +477,6 @@ class FormMail
|
||||
|
||||
if ($conf->paypal->enabled && $conf->global->PAYPAL_ADD_PAYMENT_URL)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/security.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php");
|
||||
|
||||
$langs->load('paypal');
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file /paypal/inc/triggers/interface_modPaypal_PaypalWorkflow.class.php
|
||||
* \ingroup paypal
|
||||
* \brief Trigger file for paypal workflow
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \class InterfacePaypalWorkflow
|
||||
* \brief Classe des fonctions triggers des actions personalisees du module paypal
|
||||
*/
|
||||
|
||||
class InterfacePaypalWorkflow
|
||||
{
|
||||
var $db;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param DB Database handler
|
||||
*/
|
||||
function InterfacePaypalWorkflow($DB)
|
||||
{
|
||||
$this->db = $DB ;
|
||||
|
||||
$this->name = preg_replace('/^Interface/i','',get_class($this));
|
||||
$this->family = "paypal";
|
||||
$this->description = "Triggers of this module allows to manage paypal workflow";
|
||||
$this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version
|
||||
$this->picto = 'paypal@paypal';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoi nom du lot de triggers
|
||||
* \return string Nom du lot de triggers
|
||||
*/
|
||||
function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi descriptif du lot de triggers
|
||||
* \return string Descriptif du lot de triggers
|
||||
*/
|
||||
function getDesc()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi version du lot de triggers
|
||||
* \return string Version du lot de triggers
|
||||
*/
|
||||
function getVersion()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
if ($this->version == 'development') return $langs->trans("Development");
|
||||
elseif ($this->version == 'experimental') return $langs->trans("Experimental");
|
||||
elseif ($this->version == 'dolibarr') return DOL_VERSION;
|
||||
elseif ($this->version) return $this->version;
|
||||
else return $langs->trans("Unknown");
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Fonction appelee lors du declenchement d'un evenement Dolibarr.
|
||||
* D'autres fonctions run_trigger peuvent etre presentes dans includes/triggers
|
||||
* \param action Code de l'evenement
|
||||
* \param object Objet concerne
|
||||
* \param user Objet user
|
||||
* \param lang Objet lang
|
||||
* \param conf Objet conf
|
||||
* \return int <0 if fatal error, 0 si nothing done, >0 if ok
|
||||
*/
|
||||
function run_trigger($action,$object,$user,$langs,$conf)
|
||||
{
|
||||
// Mettre ici le code a executer en reaction de l'action
|
||||
// Les donnees de l'action sont stockees dans $object
|
||||
|
||||
if ($action == 'PAYMENT_PAYMENT_OK')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". source=".$object['source']." ref=".$object['ref']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -11,4 +11,7 @@ PAYPAL_API_PASSWORD=API password
|
||||
PAYPAL_API_SIGNATURE=API signature
|
||||
PAYPAL_API_INTEGRAL_OR_PAYPALONLY=Offer payment "integral" (Credit card+Paypal) or "Paypal" only
|
||||
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>
|
||||
PAYPAL_ADD_PAYMENT_URL=Add the url of Paypal payment when you send a document by mail
|
||||
PredefinedMailContentSendOrderWithPaypalLink=You will find here the order __ORDERREF__\n\nYou can click on the secure link below to make your payment via PayPal\n\n%s\n\nSincerely\n\n
|
||||
PredefinedMailContentSendInvoiceWithPaypalLink=You will find here the invoice __FACREF__\n\nYou can click on the secure link below to make your payment via PayPal\n\n%s\n\nSincerely\n\n
|
||||
@@ -11,4 +11,7 @@ PAYPAL_API_PASSWORD=Mot de passe utilisateur API
|
||||
PAYPAL_API_SIGNATURE=Signature API
|
||||
PAYPAL_API_INTEGRAL_OR_PAYPALONLY=Proposer le paiement intégral (Carte+Paypal) ou Paypal seul
|
||||
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>
|
||||
PAYPAL_ADD_PAYMENT_URL=Ajouter l'url de paiement Paypal lors de l'envoi d'un document par mail
|
||||
PredefinedMailContentSendOrderWithPaypalLink=Veuillez trouver ci-joint la commande __ORDERREF__\n\nVous pouvez cliquer sur le lien sécurisé ci-dessous pour effectuer votre paiement via Paypal\n\n%s\n\nCordialement\n\n
|
||||
PredefinedMailContentSendInvoiceWithPaypalLink=Veuillez trouver ci-joint la facture __FACREF__\n\nVous pouvez cliquer sur le lien sécurisé ci-dessous pour effectuer votre paiement via Paypal\n\n%s\n\nCordialement\n\n
|
||||
@@ -52,6 +52,7 @@ if ($_POST["action"] == 'setvalue' && $user->admin)
|
||||
$result=dolibarr_set_const($db, "PAYPAL_API_INTEGRAL_OR_PAYPALONLY",$_POST["PAYPAL_API_INTEGRAL_OR_PAYPALONLY"],'chaine',0,'',$conf->entity);
|
||||
$result=dolibarr_set_const($db, "PAYPAL_CSS_URL",$_POST["PAYPAL_CSS_URL"],'chaine',0,'',$conf->entity);
|
||||
$result=dolibarr_set_const($db, "PAYPAL_SECURITY_TOKEN",$_POST["PAYPAL_SECURITY_TOKEN"],'chaine',0,'',$conf->entity);
|
||||
$result=dolibarr_set_const($db, "PAYPAL_ADD_PAYMENT_URL",$_POST["PAYPAL_ADD_PAYMENT_URL"],'chaine',0,'',$conf->entity);
|
||||
$result=dolibarr_set_const($db, "PAYPAL_MESSAGE_OK",$_POST["PAYPAL_MESSAGE_OK"],'chaine',0,'',$conf->entity);
|
||||
$result=dolibarr_set_const($db, "PAYPAL_MESSAGE_KO",$_POST["PAYPAL_MESSAGE_KO"],'chaine',0,'',$conf->entity);
|
||||
|
||||
@@ -179,6 +180,12 @@ print $langs->trans("SecurityToken").'</td><td>';
|
||||
print '<input size="64" type="text" name="PAYPAL_SECURITY_TOKEN" value="'.$conf->global->PAYPAL_SECURITY_TOKEN.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print $langs->trans("PAYPAL_ADD_PAYMENT_URL").'</td><td>';
|
||||
print $form->selectyesno("PAYPAL_ADD_PAYMENT_URL",$conf->global->PAYPAL_ADD_PAYMENT_URL,1);
|
||||
print '</td></tr>';
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print $langs->trans("MessageOK").'</td><td>';
|
||||
|
||||
@@ -157,6 +157,8 @@ function getPaymentUrl($source='',$ref='',$amount=0,$freetag='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/security.lib.php");
|
||||
|
||||
if (! empty($source) && ! empty($ref))
|
||||
{
|
||||
$token='';
|
||||
|
||||
@@ -96,6 +96,8 @@ llxHeaderPaypal($langs->trans("PaymentForm"));
|
||||
print '<span id="dolpaymentspan"></span>'."\n";
|
||||
print '<div id="dolpaymentdiv" align="center">'."\n";
|
||||
|
||||
$source=GETPOST('source');
|
||||
$ref=GETPOST('ref');
|
||||
$PAYPALTOKEN=GETPOST('TOKEN');
|
||||
if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token');
|
||||
$PAYPALPAYERID=GETPOST('PAYERID');
|
||||
@@ -129,6 +131,14 @@ if ($PAYPALTOKEN)
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING")
|
||||
{
|
||||
$object=array();
|
||||
|
||||
$object['source']=$source;
|
||||
$object['ref']=$ref;
|
||||
$object['payerID']=$payerID;
|
||||
$object['fulltag']=$fulltag;
|
||||
$object['resArray']=$resArray;
|
||||
|
||||
// resArray was built from a string like that
|
||||
// TOKEN=EC%2d1NJ057703V9359028&TIMESTAMP=2010%2d11%2d01T11%3a40%3a13Z&CORRELATIONID=1efa8c6a36bd8&ACK=Success&VERSION=56&BUILD=1553277&TRANSACTIONID=9B994597K9921420R&TRANSACTIONTYPE=expresscheckout&PAYMENTTYPE=instant&ORDERTIME=2010%2d11%2d01T11%3a40%3a12Z&AMT=155%2e57&FEEAMT=5%2e54&TAXAMT=0%2e00&CURRENCYCODE=EUR&PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None
|
||||
$PAYMENTSTATUS=urldecode($resArray["PAYMENTSTATUS"]); // Should contains 'Completed'
|
||||
@@ -138,6 +148,13 @@ if ($PAYPALTOKEN)
|
||||
print $langs->trans("YourPaymentHasBeenRecorded")."<br>\n";
|
||||
print $langs->trans("ThisIsTransactionId",$TRANSACTIONID)."<br>\n";
|
||||
if (! empty($conf->global->PAYPAL_MESSAGE_OK)) print $conf->global->PAYPAL_MESSAGE_OK;
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('PAYPAL_PAYMENT_OK',$object,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user