Add log for IPN file

This commit is contained in:
Laurent Destailleur 2023-03-03 18:46:29 +01:00
parent 792ff708ff
commit 7de2219e07

View File

@ -100,9 +100,17 @@ if (!empty($conf->global->STRIPE_USER_ACCOUNT_FOR_ACTIONS)) {
*/
$payload = @file_get_contents("php://input");
$sig_header = $_SERVER["HTTP_STRIPE_SIGNATURE"];
$sig_header = empty($_SERVER["HTTP_STRIPE_SIGNATURE"]) ? $_SERVER["HTTP_STRIPE_SIGNATURE"] : '';
$event = null;
$fh = fopen(DOL_DATA_ROOT.'/dolibarr_stripe.log', 'w+');
if ($fh) {
fwrite($fh, 'HTTP_STRIPE_SIGNATURE='.$sig_header."\n");
fwrite($fh, $payload);
fclose($fh);
dolChmod(DOL_DATA_ROOT.'/dolibarr_stripe.log');
}
$error = 0;
try {
@ -112,6 +120,8 @@ try {
httponly_accessforbidden('Invalid payload', 400);
} catch (\Stripe\Error\SignatureVerification $e) {
httponly_accessforbidden('Invalid signature', 400);
} catch (Exception $e) {
httponly_accessforbidden('Error '.$e->getMessage(), 400);
}
// Do something with $event