From 126479b5a9408bc3c6c55fa640e276fc44d36c4e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 2 Jul 2019 21:46:00 +0200 Subject: [PATCH] Fix paymentmethod detach --- htdocs/societe/paymentmodes.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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);