Class MPSTransactionManager

java.lang.Object
ru.bitel.bgbilling.modules.mps.server.bean.protocol.MPSTransactionManager
Direct Known Subclasses:
BiSysTransactionManager, CitiPayTransactionManager, ClickTransactionManager, ComepayTransactionManager, CPTransactionManager, EasyPayTransactionManager, ElecsnetAbstractTransactionManager, EmpayTransactionManager, EPortTransactionManager, FreecashTransactionManager, GenericOSMPTransactionManager, KaspiTransactionManager, MbankTransactionManager, OptimaPlusTransactionManager, OSMPTransactionManager, Payfon24TransactionManager, PaynetTransactionManager, PegasTransactionManager, QuickPayTransactionManager, RapidaOldTransactionManager, RapidaTransactionManager, SberbankTransactionManager, SbrfTransactionManager, SfourAlternativeTransactionManager, UepcTransactionManager, UnikassaTransactionManager, VtbTransactionManager, XPlatTransactionManager

public abstract class MPSTransactionManager extends Object
  • Field Details

  • Constructor Details

    • MPSTransactionManager

      protected MPSTransactionManager()
  • Method Details

    • findContract

      protected final Contract findContract(Connection con, int moduleId, Conf.MPSSystem system, String number, int type) throws MPSException
      Throws:
      MPSException
    • getContractTitle

      protected final String getContractTitle(HashMap<Integer,String> contractTitles, PreparedStatement getContractTitlePS, int contractId)
    • processRequest

      public static byte[] processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Setup setup, Connection con, int moduleId, String mpsId, AtomicReference<Conf.MPSSystem> mpsSystem) throws ru.bitel.bgbilling.modules.mps.server.RequestProcessException
      В зависимости от запроса нужным менеджером обрабатывает запрос
      Throws:
      ru.bitel.bgbilling.modules.mps.server.RequestProcessException
    • getInstance

      public static MPSTransactionManager getInstance(String mpsId, Setup setup, int moduleId)
    • processRequest

      protected abstract byte[] processRequest(Connection con, int moduleId, String mpsId, Conf conf, Conf.MPSSystem system, javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse response)
      Обработка запроса от системы
    • parseRequest

      protected abstract MPSRequest parseRequest(Connection con, int moduleId, String mpsId, Conf.MPSSystem system, javax.servlet.http.HttpServletRequest request) throws MPSException
      Парсинг запроса от системы
      Throws:
      MPSException
    • processError

      protected abstract void processError(MPSException ex, MPSResponse response)
      Обработка ошибки
    • checkValid

      protected void checkValid(Conf.MPSSystem system, MPSRequest mpsRequest, Connection con) throws MPSException
      Проверка на валидность запроса
      Throws:
      MPSException
    • preProcess

      protected void preProcess(Conf.MPSSystem system, MPSRequest mpsRequest, Connection con) throws MPSException
      Throws:
      MPSException
    • onPayment

      protected void onPayment(Conf.MPSSystem system, Payment payment)
    • checkTime

      protected final void checkTime(MPSRequest mpsRequest) throws MPSException
      Throws:
      MPSException
    • parseBigInteger

      protected BigInteger parseBigInteger(String value)
    • getTable

      protected final String getTable(Connection con, int moduleId, Date time) throws SQLException
      Throws:
      SQLException
    • createTemporaryTable

      protected final void createTemporaryTable(Connection con, String tableName) throws SQLException
      Throws:
      SQLException
    • addTransaction

      public final Transaction addTransaction(Connection con, int moduleId, String mpsId, Conf.MPSSystem system, int contractId, Date time, BigDecimal sum, String transId, String rawNumber, int type, String paymentComment) throws Exception
      Добавление платежа.
      Parameters:
      con - соединение с БД
      moduleId - код модуля MPS
      mpsId - код платежной системы в конфигурации модуля MPS
      system - набор настроек платежной системы
      contractId - код договора
      time - дата/время платежа
      sum - сумма платежа, пришедшая в запросе от платежной системы
      transId - код транзакции на стороне платежной системы
      rawNumber - идентификатор абонента, который присылает paynet в запросе
      type - тип поиска.
      paymentComment - комментарий платежа
      Returns:
      платеж mps, добавленный в БД.
      Throws:
      Exception
    • addTransaction

      public final Transaction addTransaction(int id, Connection con, int moduleId, String mpsId, Conf.MPSSystem system, int contractId, Date time, BigDecimal sum, String transId, String rawNumber, int type, String paymentComment) throws Exception
      Добавление платежа.
      Parameters:
      id -
      con - соединение с БД
      moduleId - код модуля MPS
      mpsId - код платежной системы в конфигурации модуля MPS
      system - набор настроек платежной системы
      contractId - код договора
      time - дата/время платежа
      sum - сумма платежа, пришедшая в запросе от платежной системы
      transId - код транзакции на стороне платежной системы
      rawNumber - идентификатор абонента, который присылает paynet в запросе
      type - тип поиска.
      paymentComment - комментарий платежа
      Returns:
      платеж mps, добавленный в БД.
      Throws:
      Exception
    • addTransaction

      public Transaction addTransaction(int id, Connection con, int moduleId, String mpsId, Conf.MPSSystem system, int contractId, Date time, BigDecimal scriptSum, BigDecimal sum, String transId, String rawNumber, int type, String paymentComment) throws Exception
      Добавление платежа.
      Parameters:
      id -
      con - соединение с БД
      moduleId - код модуля MPS
      mpsId - код платежной системы в конфигурации модуля MPS
      system - набор настроек платежной системы
      contractId - код договора
      time - дата/время платежа
      scriptSum - сумма платежа, полученная в скрипте по событию MPSBeforePaymentEvent.
      sum - сумма платежа, пришедшая в запросе от платежной системы
      transId - код транзакции на стороне платежной системы
      rawNumber - идентификатор абонента, который присылает paynet в запросе
      type - тип поиска.
      paymentComment - комментарий платежа
      Returns:
      платеж mps, добавленный в БД.
      Throws:
      Exception
    • prepareTransaction

      protected final Transaction prepareTransaction(Connection con, int moduleId, String mpsId, int contractId, Date time, BigDecimal sum, long transId, String rawNumber, int type) throws Exception
      Описание параметров метода смотри у метода #prepareTransaction(Connection, int, int, int, Date, BigDecimal, String, String, int)
      Throws:
      Exception
    • prepareTransaction

      protected final Transaction prepareTransaction(Connection con, int moduleId, String mpsId, int cid, Date time, BigDecimal sum, BigInteger transId, String rawNumber, int type) throws Exception
      Описание параметров метода смотри у метода #prepareTransaction(Connection, int, int, int, Date, BigDecimal, String, String, int)
      Throws:
      Exception
    • prepareTransaction

      protected final Transaction prepareTransaction(Connection con, int moduleId, String mpsId, int cid, Date time, BigDecimal sum, String transId, String rawNumber, int type) throws Exception
      Подготовка к проведению платежа. Метод добавляет платеж в таблицу mps_payment со статусом TransactionStatus.PAYMENT_NOT_PAYED. Баланс договора не меняется.
      Parameters:
      con - экземпляр соединения с БД.
      moduleId - код модуля mps.
      mpsId - код платежной системы, по которой проводится платеж. Настраивается в конфигурации модуля mps.
      cid - код договора, на который принимается платеж.
      time - время совершения платежа, приходящее от платежной системы.
      sum - сумма платежа, пришедшая в запросе от платежной системы.
      transId - код транзакции на стороне платежной системы.
      rawNumber - идентификатор абонента, пришедший в запросе от платежной системы.
      type - тип поиска
      Returns:
      платеж в виде сущности Transaction со статусом #PAYMENT_NOT_PAYED.
      Throws:
      Exception
    • executePreparedTransaction

      protected final Transaction executePreparedTransaction(Connection con, int mid, Conf.MPSSystem system, Transaction result, String paymentComment) throws Exception
      Завершение процедуры платежа - установка статуса TransactionStatus.PAYMENT_PAYED, добавление платежа и обновление баланса договора.
      Parameters:
      con - экземпляр соединения с БД
      mid - код модуля MPS
      system - конфигурация платежной системы
      result - экземпляр платежа, добавленный методом #prepareTransaction(Connection, int, int, int, Date, BigDecimal, String, String, int)
      paymentComment - комментарий платежа
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException - См. #prepareTransaction(Connection, int, int, int, Date, BigDecimal, String, String, int)
      Exception
    • executePreparedTransaction

      protected final Transaction executePreparedTransaction(Connection con, int mid, Conf.MPSSystem system, Transaction result, String paymentComment, BigDecimal sum) throws ru.bitel.bgbilling.common.BGException
      Завершение процедуры платежа - установка статуса TransactionStatus.PAYMENT_PAYED, добавление платежа и обновление баланса договора.
      Parameters:
      con - экземпляр соединения с БД
      mid - код модуля MPS
      system - конфигурация платежной системы
      result - экземпляр платежа, добавленный методом #prepareTransaction(Connection, int, int, int, Date, BigDecimal, String, String, int)
      paymentComment - комментарий платежа
      sum - оригинальная сумма платежа, пришедшая в запросе от платежной системы.
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException - См. #prepareTransaction(Connection, int, int, int, Date, BigDecimal, String, String, int)
    • executePreparedTransaction

      protected final Transaction executePreparedTransaction(Connection con, int mid, Conf.MPSSystem system, Transaction result, String paymentComment, BigDecimal scriptSum, BigDecimal sum) throws ru.bitel.bgbilling.common.BGException
      Завершение процедуры платежа - установка статуса TransactionStatus.PAYMENT_PAYED, добавление платежа и обновление баланса договора.
      Parameters:
      con - экземпляр соединения с БД
      mid - код модуля MPS
      system - конфигурация платежной системы
      result - экземпляр платежа, добавленный методом #prepareTransaction(Connection, int, int, int, Date, BigDecimal, String, String, int)
      paymentComment - комментарий платежа
      scriptSum - сумма платежа, которая могла быть изменена скриптом на событие MPSBeforePaymentEvent
      sum - оригинальная сумма платежа, пришедшая в запросе от платежной системы.
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException - См. #prepareTransaction(Connection, int, int, int, Date, BigDecimal, String, String, int)
    • cancelPreparedTransaction

      protected final void cancelPreparedTransaction(Connection con, int moduleId, String mpsId, Conf.MPSSystem system, Transaction transaction) throws Exception
      Отмена платежа, ранее подготовленного методом #prepareTransaction(Connection, int, int, int, Date, BigDecimal, String, String, int). Выставляется статус TransactionStatus.PAYMENT_CANCELED. Метод срабатывает только тогда, когда статус платежа не TransactionStatus.PAYMENT_CANCELED.
      Parameters:
      con - экземлпяр соединения с БД
      moduleId - код модуля MPS
      mpsId - код платежной системы в конфигурации модуля MPS
      system - набор настроек платежной системы
      transaction - экземпляр платежа, добавленный методом #prepareTransaction(Connection, int, int, int, Date, BigDecimal, String, String, int)
      Throws:
      Exception
    • getTransactionByTransId

      public final Transaction getTransactionByTransId(Connection con, int moduleId, String mpsId, long transId, Date time) throws Exception
      Получение MPSPayment по транзакции
      Parameters:
      transId -
      Returns:
      Throws:
      Exception
    • getTransactionByTransId

      public final Transaction getTransactionByTransId(Connection con, int moduleId, String mpsId, BigInteger transId, Date time) throws Exception
      Throws:
      Exception
    • getTransactionByTransId

      public final Transaction getTransactionByTransId(Connection con, int mid, String mpsId, String transId, Date time) throws Exception
      Получение MPSPayment по транзакции
      Parameters:
      transId -
      Returns:
      Throws:
      Exception
    • cancelTransaction

      public void cancelTransaction(Connection con, int moduleId, String mpsId, Conf.MPSSystem system, Transaction transaction) throws Exception
      Отмена платежа если он еще не отменен
      Throws:
      Exception
    • clearCanceledTransaction

      protected void clearCanceledTransaction(Connection con, int mid, int mpsId, Transaction transaction) throws Exception
      Throws:
      Exception
    • searchTransactionList

      public void searchTransactionList(SearchResult<Transaction> searchResult, String systemId, int contractId, String status, Connection con, int moduleId)
      Получение списка Transaction за период
    • getTransactionListForDay

      public final List<Transaction> getTransactionListForDay(Connection con, int mid, int mpsId, Calendar date) throws Exception
      Получение списка платежей за один день
      Parameters:
      date -
      Returns:
      Throws:
      Exception
    • getTransactionList

      public List<Transaction> getTransactionList(Connection con, int moduleId, int contractId, int yy, int mm)
      Получение списка платежей для договора за месяц (для web) upd 15.09 получение списка платежей всех систем
      Parameters:
      contractId -
      yy -
      mm - is 0 based!
      Returns:
    • getTransactionList

      public List<Transaction> getTransactionList(Setup setup, Connection con, int moduleId, String mpsId, Calendar from, Calendar until, boolean onlyPayed)
    • getTransactionList

      public List<Transaction> getTransactionList(Connection con, int mid, String mpsId, Conf conf, Calendar from, Calendar until, boolean onlyPayed)
      Получение списка платежей за период (Период в пределах одного месяца)
      Parameters:
      from -
      until -
      Returns:
    • getTransactionList

      public List<Transaction> getTransactionList(Connection con, int moduleId, String mpsId, Calendar from, Calendar to, int paymentTypeId, String status) throws ru.bitel.bgbilling.common.BGException
      Получение списка платежей за произвольный период с возможностью фильтрации по типу платежа (такая возможность используется, например, в платежной системе Paynet)
      Parameters:
      con - экземпляр соединения с БД
      moduleId - код модуля MPS
      mpsId - код платежной системы, определяемый в конфигурации модуля MPS
      from - начало периода, с которого выгружаютя платежи
      to - конец период, по который выгружаются платежи
      paymentTypeId - код типа платежа
      status - статус платежа
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getTransactionList

      public List<Transaction> getTransactionList(Connection con, int moduleId, int contractId, String mpsId, String status, Page page) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getTransactionFromRS

      protected final Transaction getTransactionFromRS(ResultSet rs) throws SQLException
      Получение MPSPayment из ResultSet
      Parameters:
      rs -
      Returns:
      Throws:
      SQLException
    • actionCheck

      protected Contract actionCheck(MPSRequest request) throws MPSException
      action - проверка (поиск) договора, возвращает найденный Contract
      Parameters:
      request -
      Returns:
      Throws:
      MPSException
    • processRegister

      public static ProcessRegister processRegister(String mpsId, String file, String fileName, Calendar from, Calendar until, Setup setup, Connection con, int moduleId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getTransactionListFromFileByConfig

      protected final List<Transaction> getTransactionListFromFileByConfig(Conf.MPSSystem system, String fileString)
    • getTransactionListFromFileByPattern

      protected final List<Transaction> getTransactionListFromFileByPattern(Pattern pattern, Map<String,Integer> patternOrder, String timeFormat, boolean osmpPrefix, String fileString)
    • processRegister

      protected ProcessRegister processRegister(MPSTransactionManager paymentManager, Connection con, int moduleId, String mpsId, Conf conf, String fileString, Calendar from, Calendar until) throws ru.bitel.bgbilling.common.BGException
      Обработка реестра за период.
      Parameters:
      fileString - реестр
      from -
      until -
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException
    • reviseCancelTransactions

      public void reviseCancelTransactions(Connection con, int moduleId, String mpsId, Document payments) throws ru.bitel.bgbilling.common.BGException
      Отмена платежей которых небыло в реестре
      Parameters:
      payments -
      Throws:
      ru.bitel.bgbilling.common.BGException
    • reviseAddTransactions

      public void reviseAddTransactions(Connection con, int mid, String mpsId, Setup setup, Document payments)
      Добавление платежей которые нашлись в реестре но не было в базе
      Parameters:
      payments -
    • reviseRestoreTransactions

      public void reviseRestoreTransactions(Connection con, int mid, String mpsId, Setup setup, Document payments) throws ru.bitel.bgbilling.common.BGException
      Восстановление платежей, которые в базе были отменены, но в реестре есть
      Parameters:
      payments -
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getTransactionListFromFile

      protected abstract List<Transaction> getTransactionListFromFile(Conf.MPSSystem system, String file)
    • getUserLogin

      public int getUserLogin(Connection con, int mid, int cid)
    • getUserLoginFormatted

      public String getUserLoginFormatted(Setup setup, Connection con, int mid, int cid)
    • setUserLogin

      public void setUserLogin(Setup setup, Connection con, int moduleId, int contractId, String _login) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • setEncoding

      public void setEncoding(String encoding)
    • getEncoding

      public String getEncoding()
    • getDefaultEncoding

      public String getDefaultEncoding()
    • getResponse

      protected abstract byte[] getResponse(Connection con, Conf.MPSSystem system, MPSResponse response)
    • processResponseEvent

      protected void processResponseEvent(MPSResponse response, Element responseElement)
      Создание и отправка синхронного события ДО ответа платёжной системе. Должно обрабатываться в динамическом коде скриптом-обработчиком. для внесения доп.информации, например "fields" - полей
      Parameters:
      response - - ответ платёжной системе
    • getComment

      protected final String getComment(Conf.MPSSystem system, Conf conf, Connection con, Contract contract)
    • systemAccountAdd

      protected void systemAccountAdd(Connection con, Conf.MPSSystem system, Date time, BigDecimal sum) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • systemAccountDelete

      protected void systemAccountDelete(Connection con, int mid, Conf.MPSSystem system, Date time, BigDecimal sum) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • setResponseParameters

      protected void setResponseParameters(MPSResponse response, Element responseElement)
    • getResponseAttributes

      protected Map<String,String> getResponseAttributes(Connection con, Conf.MPSSystem system, MPSResponse response)
    • xmlSerialize

      protected byte[] xmlSerialize(Document doc)