/// <summary> /// Получить аккаунт /// </summary> /// <param name="login">логин</param> /// <param name="password">пароль</param> /// <returns>аккаунт</returns> protected AccountBase(string login, string password) { _provider = GetBillingProvider(); BillingResponce <string> resp = _provider.Login(login, password); _sessionKey = GetSessionKey(resp); _login = login; }
protected override string GetSessionKey(BillingResponce <string> resp) { throw new NotImplementedException(); }
protected override bool GetCanPayValue(BillingResponce <bool> resp) { throw new NotImplementedException(); }
protected override decimal GetDecrementBallanceValue(BillingResponce <decimal> resp) { throw new NotImplementedException(); }
private decimal GetBallance(string _sessionKey) { BillingResponce <decimal> resp = _provider.GetBallance(_sessionKey); return(this.GetBallanceValue(resp)); }
/// <summary> /// Проверить возможность провдения платежа /// </summary> /// <param name="amount">размер вероятного списания</param> /// <returns>да.нет</returns> public bool CanPay(decimal amount) { BillingResponce <bool> resp = _provider.CanPay(amount, _sessionKey); return(GetCanPayValue(resp)); }
/// <summary> /// Уменьшить баланс на величину /// </summary> /// <param name="amount">значение для снятия</param> /// <returns>новое значение баланса</returns> public decimal DecrementBallance(decimal amount) { BillingResponce <decimal> resp = _provider.DecrementBallance(amount, _sessionKey); return(GetDecrementBallanceValue(resp)); }
/// <summary> /// Метод анализа ответа конкретного провайдера биллинга и выдача ответа по входу в систему /// </summary> /// <param name="resp">ответ биллинга</param> /// <returns>сессионный ключ</returns> protected abstract string GetSessionKey(BillingResponce <string> resp);
protected abstract bool GetCanPayValue(BillingResponce <bool> resp);
protected abstract decimal GetDecrementBallanceValue(BillingResponce <decimal> resp);