NEW update / delete stripe account for supplier
This commit is contained in:
parent
134c116021
commit
cef4bdab7b
@ -600,6 +600,52 @@ if (empty($reshook))
|
|||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == 'setkey_account_supplier')
|
||||||
|
{
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$newsup = GETPOST('key_account_supplier', 'alpha');
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
if (empty($newsup)) {
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = ".$servicestatus." AND entity = ".$conf->entity;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha')));
|
||||||
|
|
||||||
|
$tokenstring['stripe_user_id'] = $stripesup->id;
|
||||||
|
$tokenstring['type'] = $stripesup->type;
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token";
|
||||||
|
$sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'";
|
||||||
|
$sql.= " WHERE fk_soc = ".$object->id." AND service = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified !
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
setEventMessages($e->getMessage(), null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
if (empty($num) && !empty($newsup))
|
||||||
|
{
|
||||||
|
//TODO CREATE ACCOUNT
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$stripesupplieracc = $newsup;
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'setlocalassourcedefault') // Set as default when payment mode defined locally (and may be also remotely)
|
if ($action == 'setlocalassourcedefault') // Set as default when payment mode defined locally (and may be also remotely)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -845,7 +891,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
|
|||||||
print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', 0, 2, 'socid');
|
print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', 0, 2, 'socid');
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid');
|
print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid');
|
||||||
if (! empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account')
|
if (! empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier')
|
||||||
{
|
{
|
||||||
$connect='';
|
$connect='';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user