NEW Add more complete error messages in log on stripe payments
This commit is contained in:
parent
ebd3a04f7f
commit
83cf0dabae
@ -422,6 +422,7 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
|
|||||||
dol_syslog("POST vatnumber = ".$vatnumber, LOG_DEBUG, 0, '_stripe');
|
dol_syslog("POST vatnumber = ".$vatnumber, LOG_DEBUG, 0, '_stripe');
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
$errormessage = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$metadata = array(
|
$metadata = array(
|
||||||
@ -555,60 +556,71 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
|
|||||||
print('Message is:' . $err['message'] . "\n");
|
print('Message is:' . $err['message'] . "\n");
|
||||||
|
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe');
|
$errormessage="ErrorCard ".$e->getMessage()." err=".var_export($err, true);
|
||||||
|
dol_syslog($errormessage, LOG_WARNING, 0, '_stripe');
|
||||||
setEventMessages($e->getMessage(), null, 'errors');
|
setEventMessages($e->getMessage(), null, 'errors');
|
||||||
$action='';
|
$action='';
|
||||||
} catch (\Stripe\Error\RateLimit $e) {
|
} catch (\Stripe\Error\RateLimit $e) {
|
||||||
// Too many requests made to the API too quickly
|
// Too many requests made to the API too quickly
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe');
|
$errormessage="ErrorRateLimit ".$e->getMessage();
|
||||||
|
dol_syslog($errormessage, LOG_WARNING, 0, '_stripe');
|
||||||
setEventMessages($e->getMessage(), null, 'errors');
|
setEventMessages($e->getMessage(), null, 'errors');
|
||||||
$action='';
|
$action='';
|
||||||
} catch (\Stripe\Error\InvalidRequest $e) {
|
} catch (\Stripe\Error\InvalidRequest $e) {
|
||||||
// Invalid parameters were supplied to Stripe's API
|
// Invalid parameters were supplied to Stripe's API
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe');
|
$errormessage="ErrorInvalidRequest ".$e->getMessage();
|
||||||
|
dol_syslog($errormessage, LOG_WARNING, 0, '_stripe');
|
||||||
setEventMessages($e->getMessage(), null, 'errors');
|
setEventMessages($e->getMessage(), null, 'errors');
|
||||||
$action='';
|
$action='';
|
||||||
} catch (\Stripe\Error\Authentication $e) {
|
} catch (\Stripe\Error\Authentication $e) {
|
||||||
// Authentication with Stripe's API failed
|
// Authentication with Stripe's API failed
|
||||||
// (maybe you changed API keys recently)
|
// (maybe you changed API keys recently)
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe');
|
$errormessage="ErrorAuthentication ".$e->getMessage();
|
||||||
|
dol_syslog($errormessage, LOG_WARNING, 0, '_stripe');
|
||||||
setEventMessages($e->getMessage(), null, 'errors');
|
setEventMessages($e->getMessage(), null, 'errors');
|
||||||
$action='';
|
$action='';
|
||||||
} catch (\Stripe\Error\ApiConnection $e) {
|
} catch (\Stripe\Error\ApiConnection $e) {
|
||||||
// Network communication with Stripe failed
|
// Network communication with Stripe failed
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe');
|
$errormessage="ErrorApiConnection ".$e->getMessage();
|
||||||
|
dol_syslog($errormessage, LOG_WARNING, 0, '_stripe');
|
||||||
setEventMessages($e->getMessage(), null, 'errors');
|
setEventMessages($e->getMessage(), null, 'errors');
|
||||||
$action='';
|
$action='';
|
||||||
} catch (\Stripe\Error\Base $e) {
|
} catch (\Stripe\Error\Base $e) {
|
||||||
// Display a very generic error to the user, and maybe send
|
// Display a very generic error to the user, and maybe send
|
||||||
// yourself an email
|
// yourself an email
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe');
|
$errormessage="ErrorBase ".$e->getMessage();
|
||||||
|
dol_syslog($errormessage, LOG_WARNING, 0, '_stripe');
|
||||||
setEventMessages($e->getMessage(), null, 'errors');
|
setEventMessages($e->getMessage(), null, 'errors');
|
||||||
$action='';
|
$action='';
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Something else happened, completely unrelated to Stripe
|
// Something else happened, completely unrelated to Stripe
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe');
|
$errormessage="ErrorException ".$e->getMessage();
|
||||||
|
dol_syslog($errormessage, LOG_WARNING, 0, '_stripe');
|
||||||
setEventMessages($e->getMessage(), null, 'errors');
|
setEventMessages($e->getMessage(), null, 'errors');
|
||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$remoteip = getUserRemoteIP();
|
||||||
|
|
||||||
$_SESSION["onlinetoken"] = $stripeToken;
|
$_SESSION["onlinetoken"] = $stripeToken;
|
||||||
$_SESSION["FinalPaymentAmt"] = $amount;
|
$_SESSION["FinalPaymentAmt"] = $amount;
|
||||||
$_SESSION["currencyCodeType"] = $currency;
|
$_SESSION["currencyCodeType"] = $currency;
|
||||||
$_SESSION["paymentType"] = '';
|
$_SESSION["paymentType"] = '';
|
||||||
$_SESSION['ipaddress'] = getUserRemoteIP(); // Payer ip
|
$_SESSION['ipaddress'] = ($remoteip?$remoteip:'unknown'); // Payer ip
|
||||||
$_SESSION['payerID'] = is_object($customer)?$customer->id:'';
|
$_SESSION['payerID'] = is_object($customer)?$customer->id:'';
|
||||||
$_SESSION['TRANSACTIONID'] = is_object($charge)?$charge->id:'';
|
$_SESSION['TRANSACTIONID'] = is_object($charge)?$charge->id:'';
|
||||||
|
$_SESSION['errormessage'] = $errormessage;
|
||||||
|
|
||||||
dol_syslog("Action charge stripe result=".$error." ip=".$_SESSION['ipaddress'], LOG_DEBUG, 0, '_stripe');
|
dol_syslog("Action charge stripe ip=".$remoteip, LOG_DEBUG, 0, '_stripe');
|
||||||
dol_syslog("onlinetoken=".$_SESSION["onlinetoken"]." FinalPaymentAmt=".$_SESSION["FinalPaymentAmt"]." currencyCodeType=".$_SESSION["currencyCodeType"]." payerID=".$_SESSION['payerID']." TRANSACTIONID=".$_SESSION['TRANSACTIONID'], LOG_DEBUG, 0, '_stripe');
|
dol_syslog("onlinetoken=".$_SESSION["onlinetoken"]." FinalPaymentAmt=".$_SESSION["FinalPaymentAmt"]." currencyCodeType=".$_SESSION["currencyCodeType"]." payerID=".$_SESSION['payerID']." TRANSACTIONID=".$_SESSION['TRANSACTIONID'], LOG_DEBUG, 0, '_stripe');
|
||||||
dol_syslog("FULLTAG=".$FULLTAG, LOG_DEBUG, 0, '_stripe');
|
dol_syslog("FULLTAG=".$FULLTAG, LOG_DEBUG, 0, '_stripe');
|
||||||
|
dol_syslog("error=".$error." errormessage=".$errormessage, LOG_DEBUG, 0, '_stripe');
|
||||||
dol_syslog("Now call the redirect to paymentok or paymentko", LOG_DEBUG, 0, '_stripe');
|
dol_syslog("Now call the redirect to paymentok or paymentko", LOG_DEBUG, 0, '_stripe');
|
||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
|
|||||||
@ -107,7 +107,7 @@ $object = new stdClass(); // For triggers
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dol_syslog("Callback url when an online payment is canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment');
|
dol_syslog("Callback url when an online payment is refused or canceled. query_string=".(empty($_SERVER["QUERY_STRING"])?'':$_SERVER["QUERY_STRING"])." script_uri=".(empty($_SERVER["SCRIPT_URI"])?'':$_SERVER["SCRIPT_URI"]), LOG_DEBUG, 0, '_payment');
|
||||||
|
|
||||||
$tracepost = "";
|
$tracepost = "";
|
||||||
foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n";
|
foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n";
|
||||||
@ -126,6 +126,7 @@ if (! empty($_SESSION['ipaddress'])) // To avoid to make action twice
|
|||||||
$FinalPaymentAmt = $_SESSION['FinalPaymentAmt'];
|
$FinalPaymentAmt = $_SESSION['FinalPaymentAmt'];
|
||||||
// From env
|
// From env
|
||||||
$ipaddress = $_SESSION['ipaddress'];
|
$ipaddress = $_SESSION['ipaddress'];
|
||||||
|
$errormessage = $_SESSION['errormessage'];
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
@ -173,8 +174,9 @@ if (! empty($_SESSION['ipaddress'])) // To avoid to make action twice
|
|||||||
$content.='<u>'.$companylangs->transnoentitiesnoconv("TechnicalInformation").":</u><br>\n";
|
$content.='<u>'.$companylangs->transnoentitiesnoconv("TechnicalInformation").":</u><br>\n";
|
||||||
$content.=$companylangs->transnoentitiesnoconv("OnlinePaymentSystem").': <strong>'.$paymentmethod."</strong><br>\n";
|
$content.=$companylangs->transnoentitiesnoconv("OnlinePaymentSystem").': <strong>'.$paymentmethod."</strong><br>\n";
|
||||||
$content.=$companylangs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."<br>\n";
|
$content.=$companylangs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."<br>\n";
|
||||||
|
$content.=$companylangs->transnoentitiesnoconv("Error").': '.$errormessage."<br>\n";
|
||||||
$content.="<br>\n";
|
$content.="<br>\n";
|
||||||
$content.="tag=".$fulltag."\ntoken=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt;
|
$content.="tag=".$fulltag." token=".$onlinetoken." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt;
|
||||||
|
|
||||||
$ishtml=dol_textishtml($content); // May contain urls
|
$ishtml=dol_textishtml($content); // May contain urls
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user