diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang
index e4589bf6312..b6b6d59d4a0 100644
--- a/htdocs/langs/en_US/paypal.lang
+++ b/htdocs/langs/en_US/paypal.lang
@@ -20,4 +20,6 @@ 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
\ No newline at end of file
+ReturnURLAfterPayment=Return URL after payment
+ValidationOfPaypalPaymentFailed=Validation of Paypal payment failed
+PaypalConfirmPaymentPageWasCalledButFailed=Payment confirmation page for Paypal was called by Paypal but confirmation failed
diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php
index a43387ffe00..fce2fdf4aa9 100644
--- a/htdocs/public/paypal/paymentok.php
+++ b/htdocs/public/paypal/paymentok.php
@@ -220,26 +220,29 @@ if ($PAYPALTOKEN)
$ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
$ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]);
- echo "DoExpressCheckoutPayment API call failed. ";
- echo "Detailed Error Message: " . $ErrorLongMsg;
- echo "Short Error Message: " . $ErrorShortMsg;
- echo "Error Code: " . $ErrorCode;
- echo "Error Severity Code: " . $ErrorSeverityCode;
+ echo "DoExpressCheckoutPayment API call failed.
\n";
+ echo "Detailed Error Message: " . $ErrorLongMsg."
\n";
+ echo "Short Error Message: " . $ErrorShortMsg."
\n";
+ echo "Error Code: " . $ErrorCode."
\n";
+ echo "Error Severity Code: " . $ErrorSeverityCode."
\n";
- if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email;
+ if ($mysoc->email) echo "\nPlease, send a screenshot of this page to ".$mysoc->email."
\n";
// Send an email
if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL))
{
$sendto=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
$from=$conf->global->MAILING_EMAIL_FROM;
+ $topic='['.$conf->global->MAIN_APPLICATION_TITLE.'] '.$langs->transnoentitiesnoconv("ValidationOfPaypalPaymentFailed");
+ $content="";
+ $content.=$langs->transnoentitiesnoconv("PaypalConfirmPaymentPageWasCalledButFailed");
+ $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("ValidationOfPaypalPaymentFailed"),
- $sendto,
- $from,
- $langs->transnoentitiesnoconv("PaypalConfirmPaymentPageWasCalledButFailed")."\ntag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt."\nErrorCode=".$ErrorCode."\nErrorLongMsg=".$ErrorLongMsg
- );
+ $mailfile = new CMailFile($topic, $sendto, $from, $content);
$result=$mailfile->sendfile();
if ($result)