Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

25033 - Override Sandbox DIRECT_PAY / ONLINE_BANKING to PAD payment method #1868

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions pay-api/src/pay_api/resources/v1/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pay_api.utils.auth import jwt as _jwt
from pay_api.utils.constants import EDIT_ROLE, VIEW_ROLE
from pay_api.utils.endpoints_enums import EndpointEnum
from pay_api.utils.enums import CfsAccountStatus, ContentType, Role
from pay_api.utils.enums import CfsAccountStatus, ContentType, PaymentMethod, Role
from pay_api.utils.errors import Error

bp = Blueprint("ACCOUNTS", __name__, url_prefix=f"{EndpointEnum.API_V1.value}/accounts")
Expand All @@ -47,6 +47,13 @@ def post_account():
if is_sandbox and not _jwt.validate_roles([Role.CREATE_SANDBOX_ACCOUNT.value]):
abort(HTTPStatus.FORBIDDEN)

if is_sandbox and request_json.get("paymentInfo", {}).get("methodOfPayment", []) in [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove when our sandbox supports ONLINE_BANKING AND DIRECT_PAY

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

# Validate the input request
valid_format, errors = schema_utils.validate(request_json, "account_info")

Expand Down Expand Up @@ -269,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 @@ -308,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