Mutualize/share code of all payments modes

This commit is contained in:
Laurent Destailleur 2017-09-15 13:43:16 +02:00
parent e254554461
commit 1a78e2a055
7 changed files with 287 additions and 266 deletions

View File

@ -189,8 +189,9 @@ if (empty($reshook))
while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB)
{
// Here code is common with same loop ino mailing-send.php
$res=1;
$now=dol_now();
$obj = $db->fetch_object($resql);
@ -222,6 +223,27 @@ if (empty($reshook))
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>',
'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>'
);
$onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++;
if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++;
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{
$substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
}
/* For backward compatibility */
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
{
$substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);

View File

@ -1131,6 +1131,35 @@ class FormMail extends Form
'__UNSUBSCRIBE__' => 'TagUnsubscribe'
//,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing
);
$onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++;
if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++;
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{
$vars['__SECUREKEYPAYMENT__']=$conf->global->PAYMENT_SECURITY_TOKEN;
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
{
if ($conf->adherent->enabled) $vars['__SECUREKEYPAYMENT_MEMBER__']='SecureKeyPAYMENTUniquePerMember';
if ($conf->facture->enabled) $vars['__SECUREKEYPAYMENT_INVOICE__']='SecureKeyPAYMENTUniquePerInvoice';
if ($conf->commande->enabled) $vars['__SECUREKEYPAYMENT_ORDER__']='SecureKeyPAYMENTUniquePerOrder';
if ($conf->contrat->enabled) $vars['__SECUREKEYPAYMENT_CONTRACTLINE__']='SecureKeyPAYMENTUniquePerContractLine';
}
}
else
{
/* No need to show into tooltip help, option is not enabled
$vars['__SECUREKEYPAYMENT__']='';
$vars['__SECUREKEYPAYMENT_MEMBER__']='';
$vars['__SECUREKEYPAYMENT_INVOICE__']='';
$vars['__SECUREKEYPAYMENT_ORDER__']='';
$vars['__SECUREKEYPAYMENT_CONTRACTLINE__']='';
*/
}
// Old vars removed from doc
/*
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
{
$vars['__SECUREKEYPAYPAL__']='SecureKeyPaypal';
@ -1146,7 +1175,7 @@ class FormMail extends Form
{
$vars['__SECUREKEYPAYPAL__']='';
$vars['__SECUREKEYPAYPAL_MEMBER__']='';
}
}*/
}
$parameters=array('mode'=>$mode);

View File

@ -0,0 +1,135 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@destailleur.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 3 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, see <http://www.gnu.org/licenses/>.
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
print '<!-- BEGIN PHP TEMPLATE ONLINEPAYMENTLINKS -->';
// Url list
print '<u>'.$langs->trans("FollowingUrlAreAvailableToMakePayments").':</u><br><br>';
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':<br>';
print '<strong>'.getOnlinePaymentUrl(1,'free')."</strong><br><br>\n";
if (! empty($conf->commande->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':<br>';
print '<strong>'.getOnlinePaymentUrl(1,'order')."</strong><br>\n";
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
{
$langs->load("orders");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Order")).': ';
print '<input type="text class="flat" id="generate_order_ref" name="generate_order_ref" value="'.GETPOST('generate_order_ref','alpha').'" size="10">';
print '<input type="submit" class="none button" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_order_ref','alpha'))
{
print '<br> -> <strong>';
$url=getOnlinePaymentUrl(0,'order',GETPOST('generate_order_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
if (! empty($conf->facture->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':<br>';
print '<strong>'.getOnlinePaymentUrl(1,'invoice')."</strong><br>\n";
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
{
$langs->load("bills");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Invoice")).': ';
print '<input type="text class="flat" id="generate_invoice_ref" name="generate_invoice_ref" value="'.GETPOST('generate_invoice_ref','alpha').'" size="10">';
print '<input type="submit" class="none button" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_invoice_ref','alpha'))
{
print '<br> -> <strong>';
$url=getOnlinePaymentUrl(0,'invoice',GETPOST('generate_invoice_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
if (! empty($conf->contrat->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':<br>';
print '<strong>'.getOnlinePaymentUrl(1,'contractline')."</strong><br>\n";
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
{
$langs->load("contract");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Contract")).': ';
print '<input type="text class="flat" id="generate_contract_ref" name="generate_contract_ref" value="'.GETPOST('generate_contract_ref','alpha').'" size="10">';
print '<input type="submit" class="none button" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_contract_ref'))
{
print '<br> -> <strong>';
$url=getOnlinePaymentUrl(0,'contractline',GETPOST('generate_contract_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
if (! empty($conf->adherent->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':<br>';
print '<strong>'.getOnlinePaymentUrl(1,'membersubscription')."</strong><br>\n";
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
{
$langs->load("members");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Member")).': ';
print '<input type="text class="flat" id="generate_member_ref" name="generate_member_ref" value="'.GETPOST('generate_member_ref','alpha').'" size="10">';
print '<input type="submit" class="none reposition button" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_member_ref'))
{
print '<br> -> <strong>';
$url=getOnlinePaymentUrl(0,'membersubscription',GETPOST('generate_member_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
if (! empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#generate_token").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
generic: true
},
function(token) {
$("#PAYMENT_SECURITY_TOKEN").val(token);
});
});
});';
print '</script>';
}
print info_admin($langs->trans("YouCanAddTagOnUrl"));
print '<!-- END PHP TEMPLATE ONLINEPAYMENTLINKS -->';

View File

@ -32,6 +32,7 @@ $servicename='PayBox';
$langs->load("admin");
$langs->load("other");
$langs->load("paybox");
$langs->load("paypal");
if (!$user->admin)
accessforbidden();
@ -65,6 +66,11 @@ if ($action == 'setvalue' && $user->admin)
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL",GETPOST('ONLINE_PAYMENT_SENDEMAIL'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
// Payment token for URL
$result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN",GETPOST('PAYMENT_SECURITY_TOKEN','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE",GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
if (! $error)
{
@ -210,6 +216,19 @@ print '<input size="32" type="email" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$c
print ' &nbsp; '.$langs->trans("Example").': myemail@myserver.com';
print '</td></tr>';
// Payment token for URL
print '<tr class="oddeven"><td>';
print $langs->trans("SecurityToken").'</td><td>';
print '<input size="48" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">';
if (! empty($conf->use_javascript_ajax))
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
print '</td></tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("SecurityTokenIsUnique").'</td><td>';
print $form->selectyesno("PAYMENT_SECURITY_TOKEN_UNIQUE",(empty($conf->global->PAYMENT_SECURITY_TOKEN)?0:$conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE),1);
print '</td></tr>';
print '</table>';
dol_fiche_end();
@ -220,33 +239,7 @@ print '</form>';
print '<br><br>';
print '<u>'.$langs->trans("FollowingUrlAreAvailableToMakePayments").':</u><br><br>';
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':<br>';
print '<b>'.DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?amount=<i>9.99</i>&tag=<i>your_free_tag</i></b>'."<br>\n";
if (! empty($conf->commande->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':<br>';
print '<b>'.DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?source=order&ref=<i>order_ref</i></b>'."<br>\n";
}
if (! empty($conf->facture->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':<br>';
print '<b>'.DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?source=invoice&ref=<i>invoice_ref</i></b>'."<br>\n";
// print $langs->trans("SetupPayBoxToHavePaymentCreatedAutomatically",$langs->transnoentitiesnoconv("FeatureNotYetAvailable"))."<br>\n";
}
if (! empty($conf->contrat->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':<br>';
print '<b>'.DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?source=contractline&ref=<i>contractline_ref</i></b>'."<br>\n";
}
if (! empty($conf->adherent->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':<br>';
print '<b>'.DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?source=membersubscription&ref=<i>member_ref</i></b>'."<br>\n";
}
print info_admin($langs->trans("YouCanAddTagOnUrl"));
include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
llxFooter();
$db->close();

View File

@ -26,6 +26,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
@ -58,10 +59,6 @@ if ($action == 'setvalue' && $user->admin)
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL",GETPOST('ONLINE_PAYMENT_CSS_URL','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYPAL_SECURITY_TOKEN",GETPOST('PAYPAL_SECURITY_TOKEN','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYPAL_SECURITY_TOKEN_UNIQUE",GETPOST('PAYPAL_SECURITY_TOKEN_UNIQUE','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYPAL_ADD_PAYMENT_URL",GETPOST('PAYPAL_ADD_PAYMENT_URL','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM",GETPOST('ONLINE_PAYMENT_MESSAGE_FORM'),'chaine',0,'',$conf->entity);
@ -72,6 +69,11 @@ if ($action == 'setvalue' && $user->admin)
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL",GETPOST('ONLINE_PAYMENT_SENDEMAIL'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
// Payment token for URL
$result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN",GETPOST('PAYMENT_SECURITY_TOKEN','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE",GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
if (! $error)
{
@ -254,19 +256,18 @@ print '<td>'.$langs->trans("UrlGenerationParameters").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
// Payment token for URL
print '<tr class="oddeven"><td>';
print $langs->trans("SecurityToken").'</td><td>';
print '<input size="48" type="text" id="PAYPAL_SECURITY_TOKEN" name="PAYPAL_SECURITY_TOKEN" value="'.$conf->global->PAYPAL_SECURITY_TOKEN.'">';
print '<input size="48" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">';
if (! empty($conf->use_javascript_ajax))
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
print '</td></tr>';
print '</td></tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("SecurityTokenIsUnique").'</td><td>';
print $form->selectyesno("PAYPAL_SECURITY_TOKEN_UNIQUE",(empty($conf->global->PAYPAL_SECURITY_TOKEN)?0:$conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE),1);
print '</td></tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("SecurityTokenIsUnique").'</td><td>';
print $form->selectyesno("PAYMENT_SECURITY_TOKEN_UNIQUE",(empty($conf->global->PAYMENT_SECURITY_TOKEN)?0:$conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE),1);
print '</td></tr>';
print '</table>';
@ -281,7 +282,7 @@ print '<br><br>';
// Help doc
print '<u>'.$langs->trans("InformationToFindParameters","Paypal").'</u>:<br>';
if (! empty($conf->use_javascript_ajax))
print '<a href="#" id="apidoca">'.$langs->trans("ClickHere").'...</a>';
print '<a href="#" class="reposition" id="apidoca">'.$langs->trans("ClickHere").'...</a>';
$realpaypalurl='www.paypal.com';
$sandboxpaypalurl='developer.paypal.com';
@ -299,128 +300,24 @@ print 'Your API authentication information can be found with following steps. We
';
print '</div>';
print '<br><br>';
$token='';
// Url list
print '<u>'.$langs->trans("FollowingUrlAreAvailableToMakePayments").':</u><br><br>';
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':<br>';
print '<strong>'.getPaypalPaymentUrl(1,'free')."</strong><br><br>\n";
if (! empty($conf->commande->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':<br>';
print '<strong>'.getPaypalPaymentUrl(1,'order')."</strong><br>\n";
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE))
{
$langs->load("orders");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Order")).': ';
print '<input type="text class="flat" id="generate_order_ref" name="generate_order_ref" value="'.GETPOST('generate_order_ref','alpha').'" size="10">';
print '<input type="submit" class="none" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_order_ref','alpha'))
{
print '<br> -> <strong>';
$url=getPaypalPaymentUrl(0,'order',GETPOST('generate_order_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
if (! empty($conf->facture->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':<br>';
print '<strong>'.getPaypalPaymentUrl(1,'invoice')."</strong><br>\n";
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE))
{
$langs->load("bills");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Invoice")).': ';
print '<input type="text class="flat" id="generate_invoice_ref" name="generate_invoice_ref" value="'.GETPOST('generate_invoice_ref','alpha').'" size="10">';
print '<input type="submit" class="none" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_invoice_ref','alpha'))
{
print '<br> -> <strong>';
$url=getPaypalPaymentUrl(0,'invoice',GETPOST('generate_invoice_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
if (! empty($conf->contrat->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':<br>';
print '<strong>'.getPaypalPaymentUrl(1,'contractline')."</strong><br>\n";
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE))
{
$langs->load("contract");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Contract")).': ';
print '<input type="text class="flat" id="generate_contract_ref" name="generate_contract_ref" value="'.GETPOST('generate_contract_ref','alpha').'" size="10">';
print '<input type="submit" class="none" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_contract_ref'))
{
print '<br> -> <strong>';
$url=getPaypalPaymentUrl(0,'contractline',GETPOST('generate_contract_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
if (! empty($conf->adherent->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':<br>';
print '<strong>'.getPaypalPaymentUrl(1,'membersubscription')."</strong><br>\n";
if (! empty($conf->global->PAYPAL_SECURITY_TOKEN) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE))
{
$langs->load("members");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Member")).': ';
print '<input type="text class="flat" id="generate_member_ref" name="generate_member_ref" value="'.GETPOST('generate_member_ref','alpha').'" size="10">';
print '<input type="submit" class="none" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_member_ref'))
{
print '<br> -> <strong>';
$url=getPaypalPaymentUrl(0,'membersubscription',GETPOST('generate_member_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
print info_admin($langs->trans("YouCanAddTagOnUrl"));
if (! empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#apidoca").hide();
$("#apidoc").hide();
$("#apidoca").click(function() {
$("#apidoc").show();
$("#apidoca").hide();
});
$("#generate_token").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
generic: true
},
function(token) {
$("#PAYPAL_SECURITY_TOKEN").val(token);
});
});
});';
})
});';
print '</script>';
}
print '<br><br>';
$token='';
include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
llxFooter();
$db->close();

View File

@ -67,6 +67,11 @@ if ($action == 'setvalue' && $user->admin)
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL",GETPOST('ONLINE_PAYMENT_SENDEMAIL'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
// Payment token for URL
$result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN",GETPOST('PAYMENT_SECURITY_TOKEN','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE",GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
if (! $error)
{
@ -220,6 +225,19 @@ print '<input size="32" type="email" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$c
print ' &nbsp; '.$langs->trans("Example").': myemail@myserver.com';
print '</td></tr>';
// Payment token for URL
print '<tr class="oddeven"><td>';
print $langs->trans("SecurityToken").'</td><td>';
print '<input size="48" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">';
if (! empty($conf->use_javascript_ajax))
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
print '</td></tr>';
print '<tr class="oddeven"><td>';
print $langs->trans("SecurityTokenIsUnique").'</td><td>';
print $form->selectyesno("PAYMENT_SECURITY_TOKEN_UNIQUE",(empty($conf->global->PAYMENT_SECURITY_TOKEN)?0:$conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE),1);
print '</td></tr>';
print '</table>';
dol_fiche_end();
@ -233,121 +251,17 @@ print '<br><br>';
$token='';
// Url list
print '<u>'.$langs->trans("FollowingUrlAreAvailableToMakePayments").':</u><br><br>';
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':<br>';
print '<strong>'.getStripePaymentUrl(1,'free')."</strong><br><br>\n";
if (! empty($conf->commande->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder",$servicename).':<br>';
print '<strong>'.getStripePaymentUrl(1,'order')."</strong><br>\n";
if (! empty($conf->global->STRIPE_SECURITY_TOKEN) && ! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE))
{
$langs->load("orders");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Order")).': ';
print '<input type="text class="flat" id="generate_order_ref" name="generate_order_ref" value="'.GETPOST('generate_order_ref','alpha').'" size="10">';
print '<input type="submit" class="none" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_order_ref','alpha'))
{
print '<br> -> <strong>';
$url=getStripePaymentUrl(0,'order',GETPOST('generate_order_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
if (! empty($conf->facture->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice",$servicename).':<br>';
print '<strong>'.getStripePaymentUrl(1,'invoice')."</strong><br>\n";
if (! empty($conf->global->STRIPE_SECURITY_TOKEN) && ! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE))
{
$langs->load("bills");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Invoice")).': ';
print '<input type="text class="flat" id="generate_invoice_ref" name="generate_invoice_ref" value="'.GETPOST('generate_invoice_ref','alpha').'" size="10">';
print '<input type="submit" class="none" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_invoice_ref','alpha'))
{
print '<br> -> <strong>';
$url=getPaypalPaymentUrl(0,'invoice',GETPOST('generate_invoice_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
if (! empty($conf->contrat->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine",$servicename).':<br>';
print '<strong>'.getStripePaymentUrl(1,'contractline')."</strong><br>\n";
if (! empty($conf->global->STRIPE_SECURITY_TOKEN) && ! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE))
{
$langs->load("contract");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Contract")).': ';
print '<input type="text class="flat" id="generate_contract_ref" name="generate_contract_ref" value="'.GETPOST('generate_contract_ref','alpha').'" size="10">';
print '<input type="submit" class="none" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_contract_ref'))
{
print '<br> -> <strong>';
$url=getPaypalPaymentUrl(0,'contractline',GETPOST('generate_contract_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
if (! empty($conf->adherent->enabled))
{
print img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription",$servicename).':<br>';
print '<strong>'.getStripePaymentUrl(1,'membersubscription')."</strong><br>\n";
if (! empty($conf->global->STRIPE_SECURITY_TOKEN) && ! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE))
{
$langs->load("members");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print $langs->trans("EnterRefToBuildUrl",$langs->transnoentitiesnoconv("Member")).': ';
print '<input type="text class="flat" id="generate_member_ref" name="generate_member_ref" value="'.GETPOST('generate_member_ref','alpha').'" size="10">';
print '<input type="submit" class="none" value="'.$langs->trans("GetSecuredUrl").'">';
if (GETPOST('generate_member_ref'))
{
print '<br> -> <strong>';
$url=getPaypalPaymentUrl(0,'membersubscription',GETPOST('generate_member_ref','alpha'));
print $url;
print "</strong><br>\n";
}
print '</form>';
}
print '<br>';
}
print info_admin($langs->trans("YouCanAddTagOnUrl"));
include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php';
if (! empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
$("#apidoca").hide();
$("#apidoc").hide();
$("#apidoca").click(function() {
$("#apidoc").show();
$("#apidoca").hide();
});
$("#generate_token").click(function() {
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
action: \'getrandompassword\',
generic: true
},
function(token) {
$("#STRIPE_SECURITY_TOKEN").val(token);
});
});
});';
print '</script>';
}

View File

@ -64,7 +64,7 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
if ($conf->global->MAILING_LIMIT_SENDBYCLI == '-1')
{
}
$user = new User($db);
@ -98,7 +98,7 @@ if ($resql)
$emailing = new Mailing($db);
$emailing->fetch($obj->rowid);
$id = $emailing->id;
$subject = $emailing->sujet;
$message = $emailing->body;
@ -120,7 +120,7 @@ if ($resql)
{
$sql2.= " LIMIT ".$conf->global->MAILING_LIMIT_SENDBYCLI;
}
$resql2=$db->query($sql2);
if ($resql2)
{
@ -145,6 +145,7 @@ if ($resql)
$i = 0;
while ($i < $num2)
{
// Here code is common with same loop ino card.php
$res=1;
$now=dol_now();
@ -178,13 +179,43 @@ if ($resql)
'__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj2->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>',
'__UNSUBSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj2->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>'
);
$onlinepaymentenabled = 0;
if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++;
if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++;
if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++;
if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{
$substitutionarray['__SECUREKEYPAYMENT__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_MEMBER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_ORDER__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_INVOICE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
}
/* For backward compatibility */
if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
{
$substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $obj->source_id, 2);
}
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'order' . $obj->source_id, 2);
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2);
if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2);
}
complete_substitutions_array($substitutionarray,$langs);
$newsubject=make_substitutions($subject,$substitutionarray);
$newmessage=make_substitutions($message,$substitutionarray);
@ -252,7 +283,7 @@ if ($resql)
if ($result < 0) $error++;
// End call triggers
*/
$sqlok ="UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sqlok.=" SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj2->rowid;
$resqlok=$db->query($sqlok);