Merge pull request #11448 from ptibogxiv/patch-196

Fix paymentmethod detach
This commit is contained in:
Laurent Destailleur 2019-07-04 12:12:18 +02:00 committed by GitHub
commit 1926d430d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -637,6 +637,16 @@ if (empty($reshook))
elseif ($action == 'deletecard' && $source)
{
try {
if (preg_match('/pm_/', $source))
{
$payment_method = \Stripe\PaymentMethod::retrieve($source, ["stripe_account" => $stripeacc]);
if ($payment_method)
{
$payment_method->detach();
}
}
else
{
$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus);
$card=$cu->sources->retrieve("$source");
if ($card)
@ -645,6 +655,7 @@ if (empty($reshook))
if (method_exists($card, 'detach')) $card->detach();
else $card->delete();
}
}
$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;
header('Location: '.$url);