Skip to content

Commit

Permalink
20767 - More additional header changes (#1815)
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker25 authored Nov 7, 2024
1 parent d09271a commit 6dd34f6
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 58 deletions.
10 changes: 5 additions & 5 deletions jobs/ftp-poller/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jobs/ftp-poller/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jinja2 = "^3.1.3"
protobuf = "4.25.3"
launchdarkly-server-sdk = "^8.2.1"
sbc-common-components = {git = "https://github.com/bcgov/sbc-common-components.git", subdirectory = "python"}
pay-api = {git = "https://github.com/bcgov/sbc-pay.git", subdirectory = "pay-api", branch = "main"}
pay-api = {git = "https://github.com/seeker25/sbc-pay.git", branch = "20767_p3", subdirectory = "pay-api"}
wheel = "^0.43.0"


Expand Down
3 changes: 1 addition & 2 deletions jobs/payment-jobs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class _Config(object): # pylint: disable=too-few-public-methods
CFS_CLIENT_SECRET = os.getenv("CFS_CLIENT_SECRET")
CONNECT_TIMEOUT = int(os.getenv("CONNECT_TIMEOUT", 10))
GENERATE_RANDOM_INVOICE_NUMBER = os.getenv("CFS_GENERATE_RANDOM_INVOICE_NUMBER", "False")
PAY_CONNECTOR_AUTH = os.getenv("PAY_CONNECTOR_AUTH", "")

# legislative timezone for future effective dating
LEGISLATIVE_TIMEZONE = os.getenv("LEGISLATIVE_TIMEZONE", "America/Vancouver")
Expand Down Expand Up @@ -200,8 +201,6 @@ class _Config(object): # pylint: disable=too-few-public-methods
EFT_HOLDING_GL = os.getenv("EFT_HOLDING_GL", "")
EFT_TRANSFER_DESC = os.getenv("EFT_TRANSFER_DESC", "BCREGISTRIES {} {} EFT TRANSFER")
EFT_OVERDUE_NOTIFY_EMAILS = os.getenv("EFT_OVERDUE_NOTIFY_EMAILS", "")
# Reverse Proxy secret
PAY_CONNECTOR_SECRET = os.getenv("PAY_CONNECTOR_SECRET", "")


class DevConfig(_Config): # pylint: disable=too-few-public-methods
Expand Down
1 change: 1 addition & 0 deletions jobs/payment-jobs/devops/vaults.gcp.env
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ DW_USER="op://database/$APP_ENV/fin-warehouse/DB_READONLY_USER"
DW_PASSWORD="op://database/$APP_ENV/fin-warehouse/DB_READONLY_PASSWORD"
DW_HOST="op://database/$APP_ENV/fin-warehouse/DATABASE_HOST"
DW_PORT="op://database/$APP_ENV/fin-warehouse/DATABASE_PORT"
PAY_CONNECTOR_AUTH="op://relationship/$APP_ENV/pay-api/PAY_CONNECTOR_AUTH"
8 changes: 4 additions & 4 deletions jobs/payment-jobs/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jobs/payment-jobs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
pay-api = {git = "https://github.com/seeker25/sbc-pay.git", branch = "19182", subdirectory = "pay-api"}
pay-api = {git = "https://github.com/seeker25/sbc-pay.git", branch = "20767_p3", subdirectory = "pay-api"}
flask = "^3.0.2"
flask-sqlalchemy = "^3.1.1"
sqlalchemy = "^2.0.28"
Expand Down
4 changes: 3 additions & 1 deletion jobs/payment-jobs/tasks/cfs_bank_name_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def get_bank_info(
+ f"/cfs/parties/{party_number}/accs/{account_number}/sites/{site_number}/payment/"
)
access_token: str = CFSService.get_token().json().get("access_token")
payment_details = CFSService.get(site_payment_url, access_token, AuthHeaderType.BEARER, ContentType.JSON)
payment_details = CFSService.get(site_payment_url, access_token, AuthHeaderType.BEARER, ContentType.JSON,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")})
return payment_details.json()


Expand Down Expand Up @@ -161,6 +162,7 @@ def save_bank_details(
AuthHeaderType.BEARER,
ContentType.JSON,
payment_details,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")}
).json()
current_app.logger.debug("<<<<<<")
current_app.logger.debug(site_payment_response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _query_order_status(cls, invoice: Invoice):
access_token,
AuthHeaderType.BEARER,
ContentType.JSON,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
).json()
return payment_response

Expand Down
4 changes: 2 additions & 2 deletions jobs/payment-jobs/tasks/distribution_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def update_revenue_lines(cls, invoice: InvoiceModel, payment_url: str, access_to
AuthHeaderType.BEARER,
ContentType.JSON,
post_revenue_payload,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)

@classmethod
Expand Down Expand Up @@ -150,7 +150,7 @@ def get_payment_details(cls, payment_url: str, access_token: str):
access_token,
AuthHeaderType.BEARER,
ContentType.JSON,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
).json()
return payment_response

Expand Down
10 changes: 5 additions & 5 deletions pay-admin/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pay-admin/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ wtforms = "^3.1.2"
werkzeug = "^3.0.1"
itsdangerous = "^2.1.2"
jinja2 = "^3.1.3"
pay-api = {git = "https://github.com/bcgov/sbc-pay.git", branch = "main", subdirectory = "pay-api"}
pay-api = {git = "https://github.com/seeker25/sbc-pay.git", branch = "20767_p3", subdirectory = "pay-api"}
flask-session = {extras = ["filesystem"], version = "^0.8.0"}


Expand Down
1 change: 1 addition & 0 deletions pay-api/devops/vaults.gcp.env
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ ACCOUNT_SECRET_KEY="op://relationship/$APP_ENV/pay-api/ACCOUNT_SECRET_KEY"
OUTSTANDING_TRANSACTION_DAYS="op://relationship/$APP_ENV/pay-api/OUTSTANDING_TRANSACTION_DAYS"
ALLOW_LEGACY_ROUTING_SLIPS="op://relationship/$APP_ENV/pay-api/ALLOW_LEGACY_ROUTING_SLIPS"
VUE_APP_AUTH_WEB_URL="op://web-url/$APP_ENV/auth-web/AUTH_WEB_URL"
PAY_CONNECTOR_AUTH="op://relationship/$APP_ENV/pay-api/PAY_CONNECTOR_AUTH"
4 changes: 1 addition & 3 deletions pay-api/src/pay_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class _Config: # pylint: disable=too-few-public-methods
CFS_INVOICE_PREFIX = os.getenv("CFS_INVOICE_PREFIX", "REG")
CFS_RECEIPT_PREFIX = os.getenv("CFS_RECEIPT_PREFIX", "RCPT")
CFS_PARTY_PREFIX = os.getenv("CFS_PARTY_PREFIX", "BCR-")
PAY_CONNECTOR_AUTH = os.getenv("PAY_CONNECTOR_AUTH", "")

# EFT Config
EFT_INVOICE_PREFIX = os.getenv("EFT_INVOICE_PREFIX", "REG")
Expand Down Expand Up @@ -199,9 +200,6 @@ class _Config: # pylint: disable=too-few-public-methods
# Used for DEV/TEST/SANDBOX only. If True, will skip payment and return success and send queue message.
ALLOW_SKIP_PAYMENT = os.getenv("ALLOW_SKIP_PAYMENT", "False").lower() == "true"

# Reverse Proxy secret
PAY_CONNECTOR_SECRET = os.getenv("PAY_CONNECTOR_SECRET", "")

TESTING = False
DEBUG = True

Expand Down
46 changes: 23 additions & 23 deletions pay-api/src/pay_api/services/cfs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_site(cfs_account: CfsAccountModel) -> Dict[str, any]:
access_token,
AuthHeaderType.BEARER,
ContentType.JSON,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
return site_response.json()

Expand All @@ -125,7 +125,7 @@ def update_site_receipt_method(cfs_account: CfsAccountModel, receipt_method: str
ContentType.JSON,
pad_stop_payload,
is_put=True,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
return site_update_response.json()

Expand All @@ -152,7 +152,7 @@ def validate_bank_account(bank_details: Tuple[Dict[str, Any]]) -> Dict[str, str]
ContentType.JSON,
bank_details,
raise_for_error=False,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)

if bank_validation_response_obj.status_code in (
Expand Down Expand Up @@ -204,7 +204,7 @@ def _create_party(access_token: str = None, party_name: str = None):
AuthHeaderType.BEARER,
ContentType.JSON,
party,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
current_app.logger.debug(">Creating party Record")
return party_response.json()
Expand Down Expand Up @@ -234,7 +234,7 @@ def _create_paybc_account(access_token, party, is_fas: bool):
AuthHeaderType.BEARER,
ContentType.JSON,
account,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
current_app.logger.debug(">Creating CFS account")
return account_response.json()
Expand Down Expand Up @@ -279,7 +279,7 @@ def _create_site( # pylint: disable=too-many-arguments
AuthHeaderType.BEARER,
ContentType.JSON,
site,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
).json()
except HTTPError as e:
# If the site creation fails with 400, query and return site
Expand All @@ -290,7 +290,7 @@ def _create_site( # pylint: disable=too-many-arguments
access_token,
AuthHeaderType.BEARER,
ContentType.JSON,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
.json()
.get("items")[0]
Expand Down Expand Up @@ -336,7 +336,7 @@ def _save_bank_details( # pylint: disable=too-many-arguments
AuthHeaderType.BEARER,
ContentType.JSON,
payment_details,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
).json()

payment_details = {
Expand Down Expand Up @@ -365,7 +365,7 @@ def get_invoice(cls, cfs_account: CfsAccountModel, inv_number: str):
access_token,
AuthHeaderType.BEARER,
ContentType.JSON,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
return invoice_response.json()

Expand All @@ -392,7 +392,7 @@ def reverse_rs_receipt_in_cfs(cls, cfs_account, receipt_number, operation: Rever
AuthHeaderType.BEARER,
ContentType.JSON,
payload,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)

@classmethod
Expand Down Expand Up @@ -425,7 +425,7 @@ def _modify_rs_receipt_in_cfs(cls, cfs_account, invoice_number, receipt_number,
AuthHeaderType.BEARER,
ContentType.JSON,
payload,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)

@classmethod
Expand Down Expand Up @@ -465,7 +465,7 @@ def get_token(payment_system=PaymentSystem.PAYBC):
AuthHeaderType.BASIC,
ContentType.FORM_URL_ENCODED,
data,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
current_app.logger.debug(">Getting token")
return token_response
Expand Down Expand Up @@ -504,7 +504,7 @@ def create_account_invoice(
AuthHeaderType.BEARER,
ContentType.JSON,
invoice_payload,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
return invoice_response.json()

Expand Down Expand Up @@ -626,7 +626,7 @@ def reverse_invoice(inv_number: str):
AuthHeaderType.BEARER,
ContentType.JSON,
{},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)

@classmethod
Expand Down Expand Up @@ -658,7 +658,7 @@ def add_nsf_adjustment(cls, cfs_account: CfsAccountModel, inv_number: str, amoun
AuthHeaderType.BEARER,
ContentType.JSON,
adjustment,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)

current_app.logger.debug(">Created CFS Invoice NSF Adjustment")
Expand Down Expand Up @@ -709,7 +709,7 @@ def adjust_invoice(
AuthHeaderType.BEARER,
ContentType.JSON,
adjustment,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)

current_app.logger.debug(">Created Invoice Adjustment")
Expand Down Expand Up @@ -754,7 +754,7 @@ def create_cfs_receipt( # pylint: disable=too-many-arguments
AuthHeaderType.BEARER,
ContentType.JSON,
payload,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
).json()

@classmethod
Expand All @@ -774,7 +774,7 @@ def get_receipt(cls, cfs_account: CfsAccountModel, receipt_number: str) -> Dict[
access_token,
AuthHeaderType.BEARER,
ContentType.JSON,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)

current_app.logger.debug(">Received receipt response")
Expand All @@ -797,7 +797,7 @@ def get_cms(cls, cfs_account: CfsAccountModel, cms_number: str) -> Dict[str, any
access_token,
AuthHeaderType.BEARER,
ContentType.JSON,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)

current_app.logger.debug(">Received CMS response")
Expand Down Expand Up @@ -833,7 +833,7 @@ def create_cms(cls, line_items: List[PaymentLineItemModel], cfs_account: CfsAcco
AuthHeaderType.BEARER,
ContentType.JSON,
cms_payload,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)

current_app.logger.debug(">Received CMS response")
Expand Down Expand Up @@ -861,7 +861,7 @@ def adjust_receipt_to_zero(cls, cfs_account: CfsAccountModel, receipt_number: st
access_token,
AuthHeaderType.BEARER,
ContentType.JSON,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
current_app.logger.info(f"Balance on {receipt_number} - {receipt_response.json().get('unapplied_amount')}")
if (unapplied_amount := float(receipt_response.json().get("unapplied_amount", 0))) > 0:
Expand All @@ -876,14 +876,14 @@ def adjust_receipt_to_zero(cls, cfs_account: CfsAccountModel, receipt_number: st
AuthHeaderType.BEARER,
ContentType.JSON,
adjustment,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
receipt_response = cls.get(
receipt_url,
access_token,
AuthHeaderType.BEARER,
ContentType.JSON,
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_SECRET")},
additional_headers={"Pay-Connector": current_app.config.get("PAY_CONNECTOR_AUTH")},
)
current_app.logger.info(f"Balance on {receipt_number} - {receipt_response.json().get('unapplied_amount')}")

Expand Down
Loading

0 comments on commit 6dd34f6

Please sign in to comment.