New: Paypal return for subscription show more information and direct
link into email. Qual: Better management of error when creating subscription of member not linked to a third party.
This commit is contained in:
parent
688ce704ec
commit
d595b96c8e
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -330,54 +330,73 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $
|
||||
|
||||
$invoice=new Facture($db);
|
||||
$customer=new Societe($db);
|
||||
$result=$customer->fetch($object->fk_soc);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$errmsg=$customer->error;
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Create draft invoice
|
||||
$invoice->type= Facture::TYPE_STANDARD;
|
||||
$invoice->cond_reglement_id=$customer->cond_reglement_id;
|
||||
if (empty($invoice->cond_reglement_id))
|
||||
if (! $error)
|
||||
{
|
||||
$paymenttermstatic=new PaymentTerm($db);
|
||||
$invoice->cond_reglement_id=$paymenttermstatic->getDefaultId();
|
||||
if (empty($invoice->cond_reglement_id))
|
||||
{
|
||||
$error++;
|
||||
$errmsg='ErrorNoPaymentTermRECEPFound';
|
||||
}
|
||||
if (! ($object->fk_soc > 0))
|
||||
{
|
||||
$langs->load("errors");
|
||||
$errmsg=$langs->trans("ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst");
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
$invoice->socid=$object->fk_soc;
|
||||
$invoice->date=$datecotisation;
|
||||
|
||||
$result=$invoice->create($user);
|
||||
if ($result <= 0)
|
||||
if (! $error)
|
||||
{
|
||||
$errmsg=$invoice->error;
|
||||
$error++;
|
||||
$result=$customer->fetch($object->fk_soc);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$errmsg=$customer->error;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
// Add line to draft invoice
|
||||
$idprodsubscription=0;
|
||||
$vattouse=0;
|
||||
if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry')
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription);
|
||||
// Create draft invoice
|
||||
$invoice->type= Facture::TYPE_STANDARD;
|
||||
$invoice->cond_reglement_id=$customer->cond_reglement_id;
|
||||
if (empty($invoice->cond_reglement_id))
|
||||
{
|
||||
$paymenttermstatic=new PaymentTerm($db);
|
||||
$invoice->cond_reglement_id=$paymenttermstatic->getDefaultId();
|
||||
if (empty($invoice->cond_reglement_id))
|
||||
{
|
||||
$error++;
|
||||
$errmsg='ErrorNoPaymentTermRECEPFound';
|
||||
}
|
||||
}
|
||||
$invoice->socid=$object->fk_soc;
|
||||
$invoice->date=$datecotisation;
|
||||
|
||||
$result=$invoice->create($user);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$errmsg=$invoice->error;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
//print xx".$vattouse." - ".$mysoc." - ".$customer;exit;
|
||||
$result=$invoice->addline($label,0,1,$vattouse,0,0,$idprodsubscription,0,$datecotisation,$datesubend,0,0,'','TTC',$cotisation,1);
|
||||
if ($result <= 0)
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$errmsg=$invoice->error;
|
||||
$error++;
|
||||
// Add line to draft invoice
|
||||
$idprodsubscription=0;
|
||||
$vattouse=0;
|
||||
if (isset($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) && $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS == 'defaultforfoundationcountry')
|
||||
{
|
||||
$vattouse=get_default_tva($mysoc, $mysoc, $idprodsubscription);
|
||||
}
|
||||
//print xx".$vattouse." - ".$mysoc." - ".$customer;exit;
|
||||
$result=$invoice->addline($label,0,1,$vattouse,0,0,$idprodsubscription,0,$datecotisation,$datesubend,0,0,'','TTC',$cotisation,1);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$errmsg=$invoice->error;
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Validate invoice
|
||||
$result=$invoice->validate($user);
|
||||
}
|
||||
|
||||
// Validate invoice
|
||||
$result=$invoice->validate($user);
|
||||
|
||||
|
||||
// Add payment onto invoice
|
||||
if ($option == 'bankviainvoice' && $accountid)
|
||||
{
|
||||
@ -486,8 +505,8 @@ if ($rowid)
|
||||
|
||||
dol_fiche_head($head, 'subscription', $langs->trans("Member"), 0, 'user');
|
||||
|
||||
$rowspan=9;
|
||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1;
|
||||
$rowspan=10;
|
||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
|
||||
if (! empty($conf->societe->enabled)) $rowspan++;
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
@ -764,9 +783,9 @@ if ($rowid)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled) && $object->fk_soc) $bankviainvoice=1;
|
||||
if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $bankviainvoice=1;
|
||||
else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && ! empty($conf->banque->enabled)) $bankdirect=1;
|
||||
else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled) && $object->fk_soc) $invoiceonly=1;
|
||||
else if (! empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && ! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) $invoiceonly=1;
|
||||
}
|
||||
|
||||
print "\n\n<!-- Form add subscription -->\n";
|
||||
@ -917,12 +936,14 @@ if ($rowid)
|
||||
if (! empty($conf->societe->enabled) && ! empty($conf->facture->enabled))
|
||||
{
|
||||
print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.(! empty($invoiceonly)?' checked="checked"':'');
|
||||
if (empty($object->fk_soc)) print ' disabled="disabled"';
|
||||
//if (empty($object->fk_soc)) print ' disabled="disabled"';
|
||||
print '> '.$langs->trans("MoreActionInvoiceOnly");
|
||||
if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
|
||||
else
|
||||
{
|
||||
print ' ('.$langs->trans("NoThirdPartyAssociatedToMember");
|
||||
print ' (';
|
||||
if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
|
||||
print $langs->trans("NoThirdPartyAssociatedToMember");
|
||||
print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">';
|
||||
print $langs->trans("CreateDolibarrThirdParty");
|
||||
print '</a>)';
|
||||
@ -934,12 +955,14 @@ if ($rowid)
|
||||
if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled))
|
||||
{
|
||||
print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(! empty($bankviainvoice)?' checked="checked"':'');
|
||||
if (empty($object->fk_soc)) print ' disabled="disabled"';
|
||||
//if (empty($object->fk_soc)) print ' disabled="disabled"';
|
||||
print '> '.$langs->trans("MoreActionBankViaInvoice");
|
||||
if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
|
||||
else
|
||||
{
|
||||
print ' ('.$langs->trans("NoThirdPartyAssociatedToMember");
|
||||
print ' (';
|
||||
if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
|
||||
print $langs->trans("NoThirdPartyAssociatedToMember");
|
||||
print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=create_thirdparty">';
|
||||
print $langs->trans("CreateDolibarrThirdParty");
|
||||
print '</a>)';
|
||||
|
||||
@ -4490,6 +4490,34 @@ function printCommonFooter($zone='private')
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a string with 2 keys into key array.
|
||||
* For example: "A=1;B=2;C=2" is exploded into array('A'=>1,'B'=>2,'C'=>3)
|
||||
*
|
||||
* @param string $string String to explode
|
||||
* @param string $delimiter Delimiter between each couple of data
|
||||
* @param string $kv Delimiter between key and value
|
||||
* @return array Array of data exploded
|
||||
*/
|
||||
function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=')
|
||||
{
|
||||
if ($a = explode($delimiter, $string))
|
||||
{
|
||||
foreach ($a as $s) { // each part
|
||||
if ($s) {
|
||||
if ($pos = strpos($s, $kv)) { // key/value delimiter
|
||||
$ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv)));
|
||||
} else { // key delimiter not found
|
||||
$ka[] = trim($s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ka;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an array with RGB value into hex RGB value
|
||||
*
|
||||
|
||||
@ -134,6 +134,7 @@ ErrorOpenIDSetupNotComplete=You setup Dolibarr config file to allow OpenID authe
|
||||
ErrorWarehouseMustDiffers=Source and target warehouses must differs
|
||||
ErrorBadFormat=Bad format!
|
||||
ErrorPaymentDateLowerThanInvoiceDate=Payment date (%s) cant' be before invoice date (%s) for invoice %s.
|
||||
ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst=Error, this member is not yet linked to any thirdparty. Link member to an existing third party or create a new thirdparty before creating subscription with invoice.
|
||||
# Warnings
|
||||
WarningMandatorySetupNotComplete=Mandatory setup parameters are not yet defined
|
||||
WarningSafeModeOnCheckExecDir=Warning, PHP option <b>safe_mode</b> is on so command must be stored inside a directory declared by php parameter <b>safe_mode_exec_dir</b>.
|
||||
|
||||
@ -94,6 +94,7 @@ InformationLastAccessInError=Information for last database access in error
|
||||
DolibarrHasDetectedError=Dolibarr has detected a technical error
|
||||
InformationToHelpDiagnose=This is information that can help diagnostic
|
||||
MoreInformation=More information
|
||||
TechnicalInformation=Technical information
|
||||
NotePublic=Note (public)
|
||||
NotePrivate=Note (private)
|
||||
PrecisionUnitIsLimitedToXDecimals=Dolibarr was setup to limit precision of unit prices to <b>%s</b> decimals.
|
||||
|
||||
@ -20,3 +20,4 @@ YouAreCurrentlyInSandboxMode=You are currently in the "sandbox" mode
|
||||
NewPaypalPaymentReceived=New Paypal payment received
|
||||
NewPaypalPaymentFailed=New Paypal payment tried but failed
|
||||
PAYPAL_PAYONLINE_SENDEMAIL=EMail to warn after a payment (success or not)
|
||||
ReturnURLAfterPayment=Return URL after payment
|
||||
@ -21,7 +21,7 @@
|
||||
* \file htdocs/public/paypal/paymentok.php
|
||||
* \ingroup paypal
|
||||
* \brief File to show page after a successful payment
|
||||
* This page is called by paypal with url provided to payal competed with parameter TOKEN=xxx
|
||||
* This page is called by paypal with url provided to payal completed with parameter TOKEN=xxx
|
||||
* This token can be used to get more informations.
|
||||
* \author Laurent Destailleur
|
||||
*/
|
||||
@ -154,6 +154,7 @@ if ($PAYPALTOKEN)
|
||||
// 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'
|
||||
$TRANSACTIONID=urldecode($resArray["TRANSACTIONID"]);
|
||||
$TAXAMT=urldecode($resArray["TAXAMT"]);
|
||||
$NOTE=urldecode($resArray["NOTE"]);
|
||||
|
||||
print $langs->trans("YourPaymentHasBeenRecorded")."<br>\n";
|
||||
@ -172,13 +173,33 @@ if ($PAYPALTOKEN)
|
||||
{
|
||||
$sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
|
||||
$from=$conf->global->MAILING_EMAIL_FROM;
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
$urlback=$_SERVER["REQUEST_URI"];
|
||||
$topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentReceived");
|
||||
$tmptag=dolExplodeIntoArray($tag,'.','=');
|
||||
$content="";
|
||||
if (! empty($tmptag['MEM']))
|
||||
{
|
||||
$url=$urlwithroot."/adherents/card_subscriptions.php?rowid=".$tmptag['MEM'];
|
||||
$content.=$langs->trans("PaymentSubscription")."\n";
|
||||
$content.=$langs->trans("MemberId").': '.$tmptag['MEM']."\n";
|
||||
$content.=$langs->trans("Link").': <a href="'.$url.'">'.$url.'</a>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$content.=$langs->transnoentitiesnoconv("NewPaypalPaymentReceived")."\n";
|
||||
}
|
||||
$content.="\n";
|
||||
$content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n";
|
||||
$content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n";
|
||||
$content.="tag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
$mailfile = new CMailFile(
|
||||
'['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("NewPaypalPaymentReceived"),
|
||||
$sendto,
|
||||
$from,
|
||||
$langs->transnoentitiesnoconv("NewPaypalPaymentReceived")."\ntag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt
|
||||
);
|
||||
$mailfile = new CMailFile($topic, $sendto, $from, $content);
|
||||
|
||||
$result=$mailfile->sendfile();
|
||||
if ($result)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user