Add try catch
This commit is contained in:
parent
c0c413b219
commit
f8c15a14cf
@ -471,18 +471,26 @@ 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');
|
||||||
|
|
||||||
$ch = \Stripe\Charge::retrieve($TRANSACTIONID); // contains the charge id
|
try {
|
||||||
$stripecu = $ch->customer; // value 'cus_....'
|
$ch = \Stripe\Charge::retrieve($TRANSACTIONID); // contains the charge id
|
||||||
|
$stripecu = $ch->customer; // value 'cus_....'
|
||||||
|
|
||||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_account (fk_soc, login, key_account, site, status, entity, date_creation, fk_user_creat)";
|
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_account (fk_soc, login, key_account, site, status, entity, date_creation, fk_user_creat)";
|
||||||
$sql .= " VALUES (".$object->fk_soc.", '', '".$db->escape($stripecu)."', 'stripe', " . $servicestatus . ", " . $conf->entity . ", '".$db->idate(dol_now())."', 0)";
|
$sql .= " VALUES (".$object->fk_soc.", '', '".$db->escape($stripecu)."', 'stripe', " . $servicestatus . ", " . $conf->entity . ", '".$db->idate(dol_now())."', 0)";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
|
$error++;
|
||||||
|
$errmsg='Failed to save customer stripe id in database ; '.$db->lasterror();
|
||||||
|
$postactionmessages[] = $errmsg;
|
||||||
|
$ispostactionok = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception $e) {
|
||||||
$error++;
|
$error++;
|
||||||
$errmsg='Failed to save customer stripe id in database ; '.$db->lasterror();
|
$errmsg='Failed to save customer stripe id in database ; '.$e->getMessage();
|
||||||
$postactionmessages[] = $errmsg;
|
$postactionmessages[] = $errmsg;
|
||||||
$ispostactionok = -1;
|
$ispostactionok = -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user