Skip to content

Commit

Permalink
small tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 committed Dec 23, 2024
1 parent 916908f commit bfd544e
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions pay-api/src/pay_api/resources/v1/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ def post_account():
if is_sandbox and not _jwt.validate_roles([Role.CREATE_SANDBOX_ACCOUNT.value]):
abort(HTTPStatus.FORBIDDEN)

if is_sandbox and [PaymentMethod.ONLINE_BANKING.value, PaymentMethod.DIRECT_PAY.value] in request_json.get(
"paymentInfo", {}
).get("methodOfPayment", None):
if is_sandbox and request_json.get("paymentInfo", {}).get("methodOfPayment", []) in [
PaymentMethod.ONLINE_BANKING.value,
PaymentMethod.DIRECT_PAY.value,
]:
current_app.logger.info('Overriding methodOfPayment to "PAD" for sandbox request')
request_json["paymentInfo"]["methodOfPayment"] = PaymentMethod.PAD.value

Expand Down Expand Up @@ -275,11 +276,17 @@ def post_search_purchase_history(account_number: str):

any_org_transactions = request.args.get("viewAll", None) == "true"
if any_org_transactions:
check_auth(business_identifier=None, account_id=account_number,
all_of_roles=[Role.EDITOR.value, Role.VIEW_ALL_TRANSACTIONS.value])
check_auth(
business_identifier=None,
account_id=account_number,
all_of_roles=[Role.EDITOR.value, Role.VIEW_ALL_TRANSACTIONS.value],
)
else:
check_auth(business_identifier=None, account_id=account_number,
one_of_roles=[Role.EDITOR.value, Role.VIEW_ACCOUNT_TRANSACTIONS.value])
check_auth(
business_identifier=None,
account_id=account_number,
one_of_roles=[Role.EDITOR.value, Role.VIEW_ACCOUNT_TRANSACTIONS.value],
)

account_to_search = None if any_org_transactions else account_number
page: int = int(request.args.get("page", "1"))
Expand Down Expand Up @@ -314,8 +321,11 @@ def post_account_purchase_report(account_number: str):
report_name = f"{report_name}.csv"

# Check if user is authorized to perform this action
check_auth(business_identifier=None, account_id=account_number,
one_of_roles=[EDIT_ROLE, Role.VIEW_ACCOUNT_TRANSACTIONS.value])
check_auth(
business_identifier=None,
account_id=account_number,
one_of_roles=[EDIT_ROLE, Role.VIEW_ACCOUNT_TRANSACTIONS.value],
)
try:
report = Payment.create_payment_report(account_number, request_json, response_content_type, report_name)
response = Response(report, 201)
Expand Down

0 comments on commit bfd544e

Please sign in to comment.