Suggested link for online payment use the generic link

This commit is contained in:
Laurent Destailleur 2017-09-12 12:18:26 +02:00
parent cda8c6e41a
commit 627dd15b44
6 changed files with 163 additions and 44 deletions

View File

@ -1743,14 +1743,19 @@ else
// Show links to link elements
/*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
// Link for paypal payment
/*
if (! empty($conf->paypal->enabled) && $object->statut != 0) {
include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php';
print showPaypalPaymentUrl('invoice', $object->ref);
}
*/
// Shon online payment link
$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
if ($useonlinepayment)
{
print '<br>';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
print showOnlinePaymentUrl('membersubscription', $object->ref);
}
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element

View File

@ -789,14 +789,10 @@ if ($rowid > 0)
if ($object->statut > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription">'.$langs->trans("AddSubscription")."</a></div>";
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>';
print "<br>\n";
print '</div>';
print '<br>';
}
}
/*
* List of subscriptions
*/
@ -882,24 +878,21 @@ if ($rowid > 0)
{
dol_print_error($db);
}
// Link for paypal payment
if (! empty($conf->paypal->enabled))
{
include_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
print showPaypalPaymentUrl('membersubscription',$object->ref);
}
// Link for stripe payment
if (! empty($conf->stripe->enabled))
{
include_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php';
print showStripePaymentUrl('membersubscription',$object->ref);
}
}
// Shon online payment link
$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
if ($useonlinepayment)
{
print '<br>';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
print showOnlinePaymentUrl('membersubscription', $object->ref);
}
/*
* Add new subscription form
*/

View File

@ -402,14 +402,8 @@ if ($rowid && $action != 'edit')
// Show links to link elements
/*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
// Link for paypal payment
/*
if (! empty($conf->paypal->enabled) && $object->statut != 0) {
include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php';
print showPaypalPaymentUrl('invoice', $object->ref);
}
*/
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element

View File

@ -4307,16 +4307,15 @@ else if ($id > 0 || ! empty($ref))
$linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
// Link for paypal payment
if (! empty($conf->paypal->enabled) && $object->statut != 0) {
include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php';
print showPaypalPaymentUrl('invoice', $object->ref);
}
// Link for stripe payment
if (! empty($conf->stripe->enabled) && $object->statut != 0) {
include_once DOL_DOCUMENT_ROOT . '/stripe/lib/stripe.lib.php';
print showStripePaymentUrl('invoice', $object->ref);
// Show online payment link
$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
if ($object->statut != 0 && $useonlinepayment)
{
print '<br>';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
print showOnlinePaymentUrl('invoice', $object->ref);
}
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@ -44,7 +44,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
<td><?php echo $langs->trans("RepeatableInvoice"); ?></td>
<td><?php echo $objectlink->getNomUrl(1); ?></td>
<td align="center"></td>
<td align="center"><?php echo dol_print_date($objectlink->date,'day'); ?></td>
<td align="center"><?php echo dol_print_date($objectlink->date_when,'day'); ?></td>
<td align="right"><?php
if ($user->rights->facture->lire) {
$total = $total + $objectlink->total_ht;

View File

@ -88,6 +88,134 @@ function payment_supplier_prepare_head(Paiement $object) {
}
/**
* Return string with full Url
*
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...)
* @param string $ref Ref of object
* @return string Url string
*/
function showOnlinePaymentUrl($type,$ref)
{
global $conf, $langs;
$langs->load("PAYMENT");
$langs->load("paybox");
$servicename='Online';
$out.=img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'<br>';
$url=getOnlinePaymentUrl(0,$type,$ref);
$out.='<input type="text" id="onlinepaymenturl" class="quatrevingtpercent" value="'.$url.'">';
$out.=ajax_autoselect("onlinepaymenturl", 0);
return $out;
}
/**
* Return string with full Url
*
* @param int $mode 0=True url, 1=Url formated with colors
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...)
* @param string $ref Ref of object
* @param int $amount Amount
* @param string $freetag Free tag
* @return string Url string
*/
function getOnlinePaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_free_tag')
{
global $conf;
$ref=str_replace(' ','',$ref);
if ($type == 'free')
{
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':'');
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
}
}
if ($type == 'order')
{
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='order_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
else
{
$out.='&securekey='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + order_ref)";
if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2);
$out.=($mode?'</font>':'');
}
}
}
if ($type == 'invoice')
{
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='invoice_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
else
{
$out.='&securekey='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + invoice_ref)";
if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2);
$out.=($mode?'</font>':'');
}
}
}
if ($type == 'contractline')
{
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='contractline_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
else
{
$out.='&securekey='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + contractline_ref)";
if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2);
$out.=($mode?'</font>':'');
}
}
}
if ($type == 'membersubscription')
{
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.='member_ref';
if ($mode == 0) $out.=urlencode($ref);
$out.=($mode?'</font>':'');
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN))
{
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
else
{
$out.='&securekey='.($mode?'<font color="#666666">':'');
if ($mode == 1) $out.="hash('".$conf->global->PAYMENT_SECURITY_TOKEN."' + '".$type."' + member_ref)";
if ($mode == 0) $out.= dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $type . $ref, 2);
$out.=($mode?'</font>':'');
}
}
}
// For multicompany
$out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities
return $out;
}
/**
* Show footer of company in HTML pages