-
Notifications
You must be signed in to change notification settings - Fork 78
14853 - Create Task When New Product Add by GOVM/GOVN #3584
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
Changes from 12 commits
04ab0f3
00ba8a6
f1014ca
f864dcf
583f58a
65e4148
0ec93c6
5ae59c3
493d87b
9de4a60
6b2d473
7377904
d8593f3
66703a1
ad375d1
feddb8b
7ce9a6c
4171d5b
a3e6e1b
6b8865f
199eac3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright © 2026 Province of British Columbia | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # 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. | ||
| """Pay API utility functions.""" | ||
|
|
||
| from flask import current_app | ||
|
|
||
| from auth_api.exceptions.errors import Error | ||
| from auth_api.services.rest_service import RestService | ||
|
|
||
|
|
||
| def get_account_fees_dict(org): | ||
| """Fetch all account fees from pay-api and return a dict mapping product codes to fee existence.""" | ||
| pay_url = current_app.config.get("PAY_API_URL") | ||
| account_fees_dict = {} | ||
seeker25 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| try: | ||
| token = RestService.get_service_account_token() | ||
| response = RestService.get(endpoint=f"{pay_url}/accounts/{org.id}/fees", token=token, retry_on_failure=True) | ||
|
|
||
| if response and response.status_code == 200: | ||
| response_data = response.json() | ||
| account_fees = response_data.get("accountFees", []) | ||
|
|
||
| for fee in account_fees: | ||
| product_code = fee.get("product") | ||
| if product_code: | ||
| account_fees_dict[product_code] = True | ||
|
Comment on lines
+31
to
+42
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this logic is unit tested? should it be?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
| except Exception as e: # NOQA # pylint: disable=broad-except | ||
| # Log the error but don't fail the subscription creation | ||
| # Return empty dict so subscription can proceed without fee-based review logic | ||
| current_app.logger.error(f"{Error.ACCOUNT_FEES_FETCH_FAILED.message} for org {org.id}: {e}") | ||
|
|
||
| return account_fees_dict | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.