Fix stripe error management

This commit is contained in:
Laurent Destailleur 2019-07-29 01:12:03 +02:00
parent a63a6a5853
commit 9ca4d65965
2 changed files with 9 additions and 2 deletions

View File

@ -430,7 +430,7 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
'dol_version' => DOL_VERSION, 'dol_version' => DOL_VERSION,
'dol_entity' => $conf->entity, 'dol_entity' => $conf->entity,
'dol_company' => $mysoc->name, // Usefull when using multicompany 'dol_company' => $mysoc->name, // Usefull when using multicompany
'dol_tax_num' => $taxinfo, 'dol_tax_num' => $vatnumber,
'ipaddress'=> getUserRemoteIP() 'ipaddress'=> getUserRemoteIP()
); );
@ -456,6 +456,12 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
$stripe = new Stripe($db); $stripe = new Stripe($db);
$stripeacc = $stripe->getStripeAccount($service); $stripeacc = $stripe->getStripeAccount($service);
$customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
if (empty($customer))
{
$error++;
dol_syslog('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, LOG_ERROR, 0, '_stripe');
setEventMessages('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, null, 'errors');
}
// Create Stripe card from Token // Create Stripe card from Token
if ($savesource) { if ($savesource) {

View File

@ -177,6 +177,7 @@ class Stripe extends CommonObject
} }
catch(Exception $e) catch(Exception $e)
{ {
// For exemple, we may have error: 'No such customer: cus_XXXXX; a similar object exists in live mode, but a test mode key was used to make this request.'
$this->error = $e->getMessage(); $this->error = $e->getMessage();
} }
} }