Esempio n. 1
0
    def create(**kwargs):
        """Create a subclass of PaymentSystemService based on input params."""
        current_app.logger.debug('<create')
        user: UserContext = kwargs['user']
        total_fees: int = kwargs.get('fees', None)
        payment_method = kwargs.get('payment_method', 'CC')
        account_info = kwargs.get('account_info', None)

        _instance: PaymentSystemService = None
        current_app.logger.debug('payment_method: {}'.format(payment_method))

        if not payment_method:
            raise BusinessException(Error.INVALID_CORP_OR_FILING_TYPE)

        if total_fees == 0:
            _instance = InternalPayService()
        elif Role.STAFF.value in user.roles:
            if account_info is not None and account_info.get(
                    'bcolAccountNumber') is not None:
                _instance = BcolService()
            else:
                _instance = InternalPayService()
        else:
            if payment_method == 'CC':
                _instance = PaybcService()
            elif payment_method == 'DRAWDOWN':
                _instance = BcolService()

        if not _instance:
            raise BusinessException(Error.INVALID_CORP_OR_FILING_TYPE)

        return _instance
Esempio n. 2
0
def test_internal_rs_back_active(session, public_user_mock):
    """12033 - Scenario 2.

    Routing slip is complete and a transaction is cancelled
    the balance is restored - Should move back to Active
    """
    payment_response = PaymentService.create_invoice(
        get_routing_slip_payment_request(), get_auth_staff())
    account_model = PaymentAccount.find_by_auth_account_id(get_auth_staff().get('account').get('id'))
    account_id = account_model.id
    assert account_id is not None
    assert payment_response.get('id') is not None

    rs_number = '123456789'
    rs = factory_routing_slip(number=rs_number, payment_account_id=account_id, remaining_amount=50.00)
    rs.save()

    # Create another invoice with a routing slip.
    invoice = PaymentService.create_invoice(get_routing_slip_payment_request(), get_auth_staff())
    account_model = PaymentAccount.find_by_auth_account_id(get_auth_staff().get('account').get('id'))

    assert account_id == account_model.id

    rs = RoutingSlipModel.find_by_number(rs_number)
    assert rs.remaining_amount == 0.0
    assert rs.status == RoutingSlipStatus.COMPLETE.name

    invoice = Invoice.find_by_id(invoice['id'])
    InternalPayService().process_cfs_refund(invoice)

    assert rs.status == RoutingSlipStatus.ACTIVE.name
    def create_from_payment_method(payment_method: str):
        """Create the payment system implementation from payment method."""
        _instance: PaymentSystemService = None
        if payment_method == PaymentMethod.DIRECT_PAY.value:
            _instance = DirectPayService()
        elif payment_method == PaymentMethod.CC.value:
            _instance = PaybcService()
        elif payment_method == PaymentMethod.DRAWDOWN.value:
            _instance = BcolService()
        elif payment_method == PaymentMethod.INTERNAL.value:
            _instance = InternalPayService()
        elif payment_method == PaymentMethod.ONLINE_BANKING.value:
            _instance = OnlineBankingService()
        elif payment_method == PaymentMethod.PAD.value:
            _instance = PadService()
        elif payment_method == PaymentMethod.EFT.value:
            _instance = EftService()
        elif payment_method == PaymentMethod.WIRE.value:
            _instance = WireService()
        elif payment_method == PaymentMethod.EJV.value:
            _instance = EjvPayService()

        if not _instance:
            raise BusinessException(Error.INVALID_CORP_OR_FILING_TYPE)
        return _instance
    def create(**kwargs):
        """Create a subclass of PaymentSystemService based on input params."""
        current_app.logger.debug('<create')
        user: UserContext = kwargs['user']
        total_fees: int = kwargs.get('fees', None)
        payment_method = kwargs.get('payment_method', 'CC')
        corp_type = kwargs.get('corp_type', None)

        _instance: PaymentSystemService = None
        current_app.logger.debug('payment_method: {}, corp_type : {}'.format(
            payment_method, corp_type))

        if not payment_method and not corp_type:
            raise BusinessException(Error.PAY003)

        if total_fees == 0 or (Role.STAFF.value in user.roles):
            _instance = InternalPayService()
        else:
            if payment_method == 'CC':
                _instance = PaybcService()
            elif payment_method == 'PREMIUM':
                _instance = BcolService()

        if not _instance:
            raise BusinessException(Error.PAY003)

        return _instance
    def create(**kwargs):
        """Create a subclass of PaymentSystemService based on input params."""
        current_app.logger.debug('<create')
        user: UserContext = kwargs['user']
        total_fees: int = kwargs.get('fees', None)
        payment_account: PaymentAccount = kwargs.get('payment_account', None)
        payment_method = kwargs.get(
            'payment_method', PaymentMethod.DIRECT_PAY.value
            if current_app.config.get('DIRECT_PAY_ENABLED') else
            PaymentMethod.CC.value)
        account_info = kwargs.get('account_info', None)
        has_bcol_account_number = account_info is not None and account_info.get(
            'bcolAccountNumber') is not None

        _instance: PaymentSystemService = None
        current_app.logger.debug('payment_method: {}'.format(payment_method))

        if not payment_method:
            raise BusinessException(Error.INVALID_CORP_OR_FILING_TYPE)

        if total_fees == 0:
            _instance = InternalPayService()
        elif Role.STAFF.value in user.roles:
            if has_bcol_account_number:
                _instance = BcolService()
            else:
                _instance = InternalPayService()
        else:
            # System accounts can create BCOL payments similar to staff by providing as payload
            if has_bcol_account_number and Role.SYSTEM.value in user.roles:
                _instance = BcolService()
            else:
                _instance = PaymentSystemFactory.create_from_payment_method(
                    payment_method)

        if not _instance:
            raise BusinessException(Error.INVALID_CORP_OR_FILING_TYPE)

        PaymentSystemFactory._validate_and_throw_error(_instance,
                                                       payment_account)

        return _instance
 def create_from_system_code(payment_system: str):
     """Create the payment system implementation from the payment system code."""
     _instance: PaymentSystemService = None
     if payment_system == PaymentSystem.PAYBC.value:
         _instance = PaybcService()
     elif payment_system == PaymentSystem.BCOL.value:
         _instance = BcolService()
     elif payment_system == PaymentSystem.INTERNAL.value:
         _instance = InternalPayService()
     if not _instance:
         raise BusinessException(Error.PAY003)
     return _instance
Esempio n. 7
0
 def create_from_system_code(payment_system: str, payment_method: str):
     """Create the payment system implementation from the payment system code and payment method."""
     _instance: PaymentSystemService = None
     if payment_system == PaymentSystem.PAYBC.value:
         if payment_method == PaymentMethod.DIRECT_PAY.value:
             _instance = DirectPayService()
         else:
             _instance = PaybcService()
     elif payment_system == PaymentSystem.BCOL.value:
         _instance = BcolService()
     elif payment_system == PaymentSystem.INTERNAL.value:
         _instance = InternalPayService()
     if not _instance:
         raise BusinessException(Error.INVALID_CORP_OR_FILING_TYPE)
     return _instance