diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 6a3596f6e24..21af1f0a35c 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -637,6 +637,16 @@ if (empty($reshook)) elseif ($action == 'deletecard' && $source) { try { + if (preg_match('/pm_/', $source)) + { + $payment_method = \Stripe\PaymentMethod::retrieve($source); + 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);