Code comment

This commit is contained in:
Laurent Destailleur 2019-06-14 15:03:37 +02:00
parent 3585a5161c
commit bc8c7e0d4f

View File

@ -48,7 +48,7 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', '', ''); $result = restrictedArea($user, 'societe', '', '');
$id=GETPOST("id", "int"); $id=GETPOST("id", "int");
$source=GETPOST("source", "alpha"); $source=GETPOST("source", "alpha"); // source can be a source or a paymentmode
$ribid=GETPOST("ribid", "int"); $ribid=GETPOST("ribid", "int");
$action=GETPOST("action", 'alpha', 3); $action=GETPOST("action", 'alpha', 3);
$cancel=GETPOST('cancel', 'alpha'); $cancel=GETPOST('cancel', 'alpha');
@ -419,6 +419,15 @@ if (empty($reshook))
$companypaymentmode = new CompanyPaymentMode($db); $companypaymentmode = new CompanyPaymentMode($db);
if ($companypaymentmode->fetch($ribid?$ribid:$id)) 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); $result = $companypaymentmode->delete($user);
if ($result > 0) if ($result > 0)
{ {
@ -586,7 +595,7 @@ if (empty($reshook))
$db->rollback(); $db->rollback();
} }
} }
if ($action == 'setlocalassourcedefault') if ($action == 'setlocalassourcedefault') // Set as default when payment mode defined locally (and may be also remotely)
{ {
try { try {
$companypaymentmode->setAsDefault($id); $companypaymentmode->setAsDefault($id);
@ -601,11 +610,12 @@ if (empty($reshook))
setEventMessages($e->getMessage(), null, 'errors'); setEventMessages($e->getMessage(), null, 'errors');
} }
} }
elseif ($action == 'setassourcedefault') elseif ($action == 'setassourcedefault') // Set as default when payment mode defined remotely only
{ {
try { try {
$cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); $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(); $result = $cu->save();
$url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id;