Пример #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
Пример #2
0
def test_service_methods(app):
    """Test service methods."""
    with app.app_context():
        bcol_service = BcolService()
        assert bcol_service.create_account(None, None) is None
        assert bcol_service.create_invoice(None, None, None) is None
        assert bcol_service.get_payment_system_url(None, None) is None
        assert bcol_service.get_payment_system_code() == 'BCOL'
        assert bcol_service.update_invoice(None, None) is None
        assert bcol_service.cancel_invoice(None, None) is None
        assert bcol_service.get_receipt(None, None, None) is None
Пример #3
0
    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
Пример #5
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_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
Пример #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
Пример #8
0
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests to assure the BCOL service layer.

Test-Suite to ensure that the BCOL Service layer is working as expected.
"""

from pay_api.models.fee_schedule import FeeSchedule
from pay_api.services.bcol_service import BcolService
from tests.utilities.base_test import (
    factory_invoice, factory_invoice_reference, factory_payment, factory_payment_account, factory_payment_line_item)


bcol_service = BcolService()


def test_create_account(session):
    """Test create_account."""
    account = bcol_service.create_account(None, None)
    assert account is not None


def test_get_payment_system_url(session):
    """Test get_payment_system_url."""
    url = bcol_service.get_payment_system_url(None, None, None)
    assert url is None


def test_get_payment_system_code(session):
Пример #9
0
# limitations under the License.
"""Resource for Invoice related endpoints."""

from http import HTTPStatus

from flask_restplus import Namespace, Resource

from pay_api.exceptions import BusinessException
from pay_api.services.bcol_service import BcolService
from pay_api.utils.trace import tracing as _tracing
from pay_api.utils.util import cors_preflight


API = Namespace('bcol profile', description='Payment System - BCOL Profiles')

BCOL_SERVICE = BcolService()


@cors_preflight(['GET', 'OPTIONS'])
@API.route('', methods=['GET', 'OPTIONS'])
class BcolProfile(Resource):
    """Endpoint resource to manage BCOL Accounts."""

    @staticmethod
    @API.response(200, 'OK')
    @_tracing.trace()
    def get(account_id: str, user_id: str):
        """Return the account details."""
        try:
            response, status = BCOL_SERVICE.query_profile(account_id, user_id), HTTPStatus.OK
        except BusinessException as exception: