From bc8c7e0d4f68817095de0a1404f6b8f94ebdbfe7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Jun 2019 15:03:37 +0200 Subject: [PATCH] Code comment --- htdocs/societe/paymentmodes.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index e37d7caf91f..3b1a2dd0459 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -48,7 +48,7 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe', '', ''); $id=GETPOST("id", "int"); -$source=GETPOST("source", "alpha"); +$source=GETPOST("source", "alpha"); // source can be a source or a paymentmode $ribid=GETPOST("ribid", "int"); $action=GETPOST("action", 'alpha', 3); $cancel=GETPOST('cancel', 'alpha'); @@ -419,6 +419,15 @@ if (empty($reshook)) $companypaymentmode = new CompanyPaymentMode($db); if ($companypaymentmode->fetch($ribid?$ribid:$id)) { + /*if ($companypaymentmode->stripe_card_ref && preg_match('/pm_/', $companypaymentmode->stripe_card_ref)) + { + $payment_method = \Stripe\PaymentMethod::retrieve($companypaymentmode->stripe_card_ref); + if ($payment_method) + { + $payment_method->detach(); + } + }*/ + $result = $companypaymentmode->delete($user); if ($result > 0) { @@ -586,7 +595,7 @@ if (empty($reshook)) $db->rollback(); } } - if ($action == 'setlocalassourcedefault') + if ($action == 'setlocalassourcedefault') // Set as default when payment mode defined locally (and may be also remotely) { try { $companypaymentmode->setAsDefault($id); @@ -601,11 +610,12 @@ if (empty($reshook)) setEventMessages($e->getMessage(), null, 'errors'); } } - elseif ($action == 'setassourcedefault') + elseif ($action == 'setassourcedefault') // Set as default when payment mode defined remotely only { try { $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); - $cu->default_source = (string) $source; + $cu->default_source = (string) $source; // Old + $cu->invoice_settings->default_payment_method = (string) $source; // New $result = $cu->save(); $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;