It is better to let the caller decide which mode (live or not) to take

This commit is contained in:
Laurent Destailleur 2018-03-13 09:37:59 +01:00 committed by GitHub
parent 9408a98c52
commit 490acd96dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -93,25 +93,18 @@ class Stripe extends CommonObject
* getStripeCustomerAccount
*
* @param int $id Id of third party
* @return string Stripe customer ref 'cu_xxxxxxxxxxxxx'
* @param int $status Status
* @return string Stripe customer ref 'cu_xxxxxxxxxxxxx'
*/
public function getStripeCustomerAccount($id)
public function getStripeCustomerAccount($id, $status=0)
{
global $conf;
if (empty($conf->global->STRIPECONNECT_LIVE)) {
$mode = 0;
} else {
if (empty($conf->global->STRIPE_LIVE)) {
$mode = 0;
} else {
$mode = $conf->global->STRIPE_LIVE;
}
}
$sql = "SELECT sa.key_account as key_account, sa.entity";
$sql.= " FROM " . MAIN_DB_PREFIX . "llx_societe_account as sa";
$sql.= " WHERE sa.fk_soc = " . $id;
$sql.= " AND sa.entity IN (".getEntity('societe').")";
$sql.= " AND sa.site = 'stripe' AND sa.status = ".$mode;
$sql.= " AND sa.site = 'stripe' AND sa.status = ".((int) $status);
dol_syslog(get_class($this) . "::fetch", LOG_DEBUG);
$result = $this->db->query($sql);