Skip to content

Commit

Permalink
New: For paypal payment confirmation, send email ok only if payment is
Browse files Browse the repository at this point in the history
confirmed. Otherwise send ko email.
  • Loading branch information
eldy committed Jan 7, 2014
1 parent 267716b commit 58bc3b1
Showing 1 changed file with 50 additions and 27 deletions.
77 changes: 50 additions & 27 deletions htdocs/public/paypal/paymentok.php
Expand Up @@ -129,33 +129,6 @@
dol_syslog("Call paymentok with token=".$token." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_paypal');


// Send an email
//if (! empty($conf->global->MEMBER_PAYONLINE_SENDEMAIL) && preg_match('/MEM=/',$fulltag))
if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL))
{
//$sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL;
$sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
$from=$conf->global->MAILING_EMAIL_FROM;
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
);

$result=$mailfile->sendfile();
if ($result)
{
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal');
}
else
{
dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal');
}
}


// Validate record
if (! empty($paymentType))
{
Expand Down Expand Up @@ -193,6 +166,31 @@
$result=$interface->run_triggers('PAYPAL_PAYMENT_OK',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $errors=$interface->errors; }
// Fin appel triggers

// Send an email
if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL))
{
//$sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL;
$sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
$from=$conf->global->MAILING_EMAIL_FROM;
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
);

$result=$mailfile->sendfile();
if ($result)
{
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal');
}
else
{
dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal');
}
}
}
else
{
Expand All @@ -209,6 +207,31 @@
echo "Error Severity Code: " . $ErrorSeverityCode;

if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email;

// Send an email
if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL))
{
//$sendto=$conf->global->MEMBER_PAYONLINE_SENDEMAIL;
$sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
$from=$conf->global->MAILING_EMAIL_FROM;
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile(
'['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("ValidationOfPaypalPaymentFailed"),
$sendto,
$from,
$langs->transnoentitiesnoconv("PaypalConfirmPaymentPageWasCalledButFailed")."\ntag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt."\nErrorCode=".$ErrorCode."\nErrorLongMsg=".$ErrorLongMsg
);

$result=$mailfile->sendfile();
if ($result)
{
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_paypal');
}
else
{
dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_paypal');
}
}
}
}
else
Expand Down

0 comments on commit 58bc3b1

Please sign in to comment.