Fix error management
This commit is contained in:
parent
3112f2b1c5
commit
406375bfc4
@ -461,47 +461,51 @@ if ($action == 'charge' && ! empty($conf->stripe->enabled))
|
|||||||
$error++;
|
$error++;
|
||||||
dol_syslog('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, LOG_ERR, 0, '_stripe');
|
dol_syslog('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, LOG_ERR, 0, '_stripe');
|
||||||
setEventMessages('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, null, 'errors');
|
setEventMessages('Failed to get/create stripe customer for thirdparty id = '.$thirdparty_id.' and servicestatus = '.$servicestatus.': '.$stripe->error, null, 'errors');
|
||||||
|
$action='';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Stripe card from Token
|
// Create Stripe card from Token
|
||||||
if ($savesource) {
|
if (! $error)
|
||||||
$card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata));
|
|
||||||
} else {
|
|
||||||
$card = $stripeToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($card))
|
|
||||||
{
|
{
|
||||||
$error++;
|
if ($savesource) {
|
||||||
dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe');
|
$card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata));
|
||||||
setEventMessages('Failed to create card record', null, 'errors');
|
} else {
|
||||||
$action='';
|
$card = $stripeToken;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (! empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG;
|
|
||||||
if (! empty($dol_id)) $metadata["dol_id"] = $dol_id;
|
|
||||||
if (! empty($dol_type)) $metadata["dol_type"] = $dol_type;
|
|
||||||
|
|
||||||
dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe');
|
if (empty($card))
|
||||||
$charge = \Stripe\Charge::create(array(
|
{
|
||||||
'amount' => price2num($amountstripe, 'MU'),
|
$error++;
|
||||||
'currency' => $currency,
|
dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe');
|
||||||
'capture' => true, // Charge immediatly
|
setEventMessages('Failed to create card record', null, 'errors');
|
||||||
'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref,
|
$action='';
|
||||||
'metadata' => $metadata,
|
}
|
||||||
'customer' => $customer->id,
|
else
|
||||||
'source' => $card,
|
{
|
||||||
'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description)
|
if (! empty($FULLTAG)) $metadata["FULLTAG"] = $FULLTAG;
|
||||||
), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc"));
|
if (! empty($dol_id)) $metadata["dol_id"] = $dol_id;
|
||||||
// Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...)
|
if (! empty($dol_type)) $metadata["dol_type"] = $dol_type;
|
||||||
if (empty($charge))
|
|
||||||
{
|
dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe');
|
||||||
$error++;
|
$charge = \Stripe\Charge::create(array(
|
||||||
dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe');
|
'amount' => price2num($amountstripe, 'MU'),
|
||||||
setEventMessages('Failed to charge card', null, 'errors');
|
'currency' => $currency,
|
||||||
$action='';
|
'capture' => true, // Charge immediatly
|
||||||
}
|
'description' => 'Stripe payment: '.$FULLTAG.' ref='.$ref,
|
||||||
|
'metadata' => $metadata,
|
||||||
|
'customer' => $customer->id,
|
||||||
|
'source' => $card,
|
||||||
|
'statement_descriptor' => dol_trunc($FULLTAG, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description)
|
||||||
|
), array("idempotency_key" => "$FULLTAG", "stripe_account" => "$stripeacc"));
|
||||||
|
// Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...)
|
||||||
|
if (empty($charge))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe');
|
||||||
|
setEventMessages('Failed to charge card', null, 'errors');
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user