Skip to content

Commit

Permalink
Remove unused code, add in check for system - service accounts have a…
Browse files Browse the repository at this point in the history
…pi_user role
  • Loading branch information
seeker25 committed Jan 7, 2025
1 parent 96913ad commit 01ff9a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
6 changes: 1 addition & 5 deletions pay-api/src/pay_api/services/payment_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

from .base_payment_system import PaymentSystemService
from .fee_schedule import FeeSchedule
from .flags import flags
from .invoice import Invoice
from .invoice_reference import InvoiceReference
from .payment import Payment
Expand Down Expand Up @@ -74,11 +73,8 @@ def create_invoice(
payment_account = cls._find_payment_account(authorization)
payment_method = _get_payment_method(payment_request, payment_account)

if payment_method == PaymentMethod.EFT.value and not flags.is_on("enable-eft-payment-method", default=False):
raise BusinessException(Error.INVALID_PAYMENT_METHOD)

user: UserContext = kwargs["user"]
if user.is_api_user() and not user.is_sandbox():
if user.is_api_user() and (not user.is_sandbox() and not user.is_system()):
if payment_method in [PaymentMethod.DIRECT_PAY.value, PaymentMethod.ONLINE_BANKING.value]:
raise BusinessException(Error.INVALID_PAYMENT_METHOD)

Expand Down
7 changes: 2 additions & 5 deletions pay-api/tests/unit/models/test_corp_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,11 @@ def test_corp_type_by_invalid_code(session):
def test_payment_methods(session):
"""Assert that payment methods are stored and retrieved correctly."""
business_corp = factory_corp_type(
"XX",
"Business",
product="BUSINESS",
payment_methods=['PAD', 'DIRECT_PAY', 'ONLINE_BANKING', 'DRAWDOWN']
"XX", "Business", product="BUSINESS", payment_methods=["PAD", "DIRECT_PAY", "ONLINE_BANKING", "DRAWDOWN"]
)
session.add(business_corp)
session.commit()

retrieved_corp = CorpType.find_by_code("XX")
assert retrieved_corp is not None
assert retrieved_corp.payment_methods == ['PAD', 'DIRECT_PAY', 'ONLINE_BANKING', 'DRAWDOWN']
assert retrieved_corp.payment_methods == ["PAD", "DIRECT_PAY", "ONLINE_BANKING", "DRAWDOWN"]
8 changes: 4 additions & 4 deletions pay-api/tests/unit/services/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def test_find_valid_payment_methods_by_product_code(session):
assert payment_methods is not None
assert isinstance(payment_methods, dict)

business_payment_methods = CodeService.find_valid_payment_methods_by_product_code('BUSINESS')
business_payment_methods = CodeService.find_valid_payment_methods_by_product_code("BUSINESS")
assert business_payment_methods is not None
assert 'BUSINESS' in business_payment_methods
assert isinstance(business_payment_methods['BUSINESS'], list)
assert "BUSINESS" in business_payment_methods
assert isinstance(business_payment_methods["BUSINESS"], list)

invalid_payment_methods = CodeService.find_valid_payment_methods_by_product_code('INVALID')
invalid_payment_methods = CodeService.find_valid_payment_methods_by_product_code("INVALID")
assert invalid_payment_methods == {}

0 comments on commit 01ff9a2

Please sign in to comment.