Add try catch

This commit is contained in:
Laurent Destailleur 2019-12-31 19:11:36 +01:00
parent c0c413b219
commit f8c15a14cf

View File

@ -471,8 +471,9 @@ if ($ispaymentok)
if (! $customer && $TRANSACTIONID) // Not linked to a stripe customer, we make the link if (! $customer && $TRANSACTIONID) // Not linked to a stripe customer, we make the link
{ {
dol_syslog("No stripe profile found, so we add it", LOG_DEBUG, 0, '_payment'); dol_syslog("No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0, '_payment');
try {
$ch = \Stripe\Charge::retrieve($TRANSACTIONID); // contains the charge id $ch = \Stripe\Charge::retrieve($TRANSACTIONID); // contains the charge id
$stripecu = $ch->customer; // value 'cus_....' $stripecu = $ch->customer; // value 'cus_....'
@ -487,6 +488,13 @@ if ($ispaymentok)
$ispostactionok = -1; $ispostactionok = -1;
} }
} }
catch(Exception $e) {
$error++;
$errmsg='Failed to save customer stripe id in database ; '.$e->getMessage();
$postactionmessages[] = $errmsg;
$ispostactionok = -1;
}
}
} }
} }