コード例 #1
0
    def post():
        """Create a payment record in BCOL."""
        try:
            if _jwt.validate_roles([
                    Role.STAFF.value, Role.EDIT.value
            ]) or _jwt.validate_roles([Role.SYSTEM.value]):
                is_apply_charge = True
            elif _jwt.validate_roles([Role.ACCOUNT_HOLDER.value]):
                is_apply_charge = False
            else:
                abort(403)

            req_json = request.get_json()
            current_app.logger.debug(req_json)
            # Validate the input request
            valid_format = schema_utils.validate(req_json, 'payment_request')

            if not valid_format[0]:
                current_app.logger.info(
                    'Validation Error with incoming request %s',
                    schema_utils.serialize(valid_format[1]))
                return error_to_response(Error.INVALID_REQUEST,
                                         invalid_params=schema_utils.serialize(
                                             valid_format[1]))

            response, status = BcolPayment().create_payment(
                req_json, is_apply_charge), HTTPStatus.OK

        except BusinessException as exception:
            return exception.response()
        except PaymentException as exception:
            return exception.response()

        return response, status
コード例 #2
0
ファイル: bcol_profile.py プロジェクト: stevenc987/sbc-pay
    def post():
        """Return the account details."""
        try:
            req_json = request.get_json()
            # Validate the input request
            valid_format = schema_utils.validate(req_json, 'accounts_request')
            if not valid_format[0]:
                return error_to_response(Error.INVALID_REQUEST,
                                         invalid_params=schema_utils.serialize(
                                             valid_format[1]))

            response, status = BcolProfileService().query_profile(
                req_json.get('userId'),
                req_json.get('password')), HTTPStatus.OK
        except BusinessException as exception:
            return exception.response()
        return response, status