Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @eve-git @shaangill025 @stevenc987 @mengdong19 @ozamani9gh @rarmitag @flutistar @EPortman
* @stevenc987 @mengdong19 @ozamani9gh @rarmitag @hfekete @davemck513
4 changes: 4 additions & 0 deletions .github/workflows/bad-designation-notifier-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ on:
- "false"
- "true"

permissions:
id-token: write
contents: write

jobs:
namex-bad-designation-notifier-cd:
uses: bcgov/bcregistry-sre/.github/workflows/backend-job-cd.yaml@main
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/bad-designation-notifier-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ defaults:
shell: bash
working-directory: ./jobs/bad-designation-notifier

permissions:
id-token: write
contents: write

jobs:
namex-bad-designation-notifier-ci:
uses: bcgov/bcregistry-sre/.github/workflows/backend-ci.yaml@main
with:
app_name: "namex-bad-designation-notifier"
working_directory: "./jobs/bad-designation-notifier"
codecov_flag: "namexbaddesignationnotifier"
skip_isort: "true"
skip_black: "true"
codecov_flag: "namex-bad-designation-notifier"
2 changes: 1 addition & 1 deletion .github/workflows/notebook-report-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: bcgov/bcregistry-sre/.github/workflows/backend-job-cd.yaml@main
with:
target: ${{ inputs.target }}
app_name: "notebook-report"
app_name: "namex-notebook-report"
working_directory: "./jobs/notebook-report"
redeploy: ${{ inputs.redeploy }}
secrets:
Expand Down
5 changes: 4 additions & 1 deletion api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ class TestConfig(Config): # pylint: disable=too-few-public-methods
DB_NAME = os.getenv('DATABASE_TEST_NAME', 'unittesting')
DB_HOST = os.getenv('DATABASE_TEST_HOST', 'localhost')
DB_PORT = os.getenv('DATABASE_TEST_PORT', '54345')
SQLALCHEMY_DATABASE_URI = f'postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}'
if os.getenv('TEST_USE_LOCAL_DB', False):
SQLALCHEMY_DATABASE_URI = f'postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}'
else:
SQLALCHEMY_DATABASE_URI = f'postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}'

# Ensure SQLAlchemy is properly configured for Flask-Marshmallow compatibility
SQLALCHEMY_TRACK_MODIFICATIONS = False
Expand Down
3 changes: 2 additions & 1 deletion api/devops/gcp/clouddeploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ serialPipeline:
cloudsql-instances: "a083gt-prod:northamerica-northeast1:namex-db-prod"
resources-cpu: 4000m
resources-memory: 8Gi
container-concurrency: "8"
max-scale: "60"
container-concurrency: "20"
63 changes: 38 additions & 25 deletions api/namex/services/payment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import dataclasses
from dataclasses import dataclass, field
from typing import Optional, Union
from decimal import Decimal

from pydantic.dataclasses import dataclass as pydantic_dataclass
from pydantic import Field
from datetime import date

from .abstract import Serializable
Expand Down Expand Up @@ -118,7 +122,21 @@ class PaymentRequest(Serializable):
details: list = field(default_factory=PaymentDetailItem)


@dataclass
class PydanticConfig:
"""Pydantic config to ignore extra fields."""
extra = 'ignore'
underscore_attrs_are_private = False


@pydantic_dataclass(config=PydanticConfig)
class PaymentRefundInvoice:
refundId: int
refundAmount: Decimal
message: str
isPartialRefund: bool


@pydantic_dataclass(config=PydanticConfig)
class PaymentInvoice(Serializable):
id: int
serviceFees: float
Expand All @@ -140,25 +158,20 @@ class PaymentInvoice(Serializable):
routingSlip: str = ''
datNumber: str = ''
folioNumber: str = ''
lineItems: list = field(default_factory=list)
receipts: list = field(default_factory=list)
references: list = field(default_factory=list)
details: list = field(default_factory=list)
_links: list = field(default_factory=list)
paymentAccount: dict = field(default_factory=dict)

def __init__(self, **kwargs):
"""Set the attributes only if the field is defined."""
self.lineItems = []
self.receipts = []
self.references = []
self.details = []
self._links = []
self.paymentAccount = {}
names = {f.name for f in dataclasses.fields(self)}
for k, v in kwargs.items():
if k in names:
setattr(self, k, v)
lineItems: list = Field(default_factory=list)
receipts: list = Field(default_factory=list)
references: list = Field(default_factory=list)
details: list = Field(default_factory=list)
links: list = Field(default_factory=list)
paymentAccount: dict = Field(default_factory=dict)

@property
def _links(self) -> list:
return self.links

@_links.setter
def _links(self, value: list) -> None:
self.links = value


@dataclass
Expand All @@ -180,11 +193,11 @@ class Receipt(Serializable):
receiptNumber: str = ''


@dataclass
@pydantic_dataclass(config=PydanticConfig)
class ReceiptResponse(Serializable):
bcOnlineAccountNumber: str = None
filingIdentifier: str = None
invoice: PaymentInvoice = field(default=PaymentInvoice)
bcOnlineAccountNumber: Optional[str] = None
filingIdentifier: Optional[str] = None
invoice: Optional[Union[PaymentInvoice, dict]] = None
invoiceNumber: str = ''
paymentMethod: str = ''
receiptNumber: str = ''
Expand Down
10 changes: 7 additions & 3 deletions api/namex/services/payment/payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from .client import SBCPaymentClient
from .exceptions import SBCPaymentException
from .models import PaymentInvoice
from .models import PaymentInvoice, PaymentRefundInvoice


def get_payment(payment_identifier):
Expand Down Expand Up @@ -38,8 +38,12 @@ def refund_payment(payment_identifier, model=None):
data = model
api_instance = SBCPaymentClient()
api_response = api_instance.refund_payment(payment_identifier, data)
current_app.logger.debug(api_response)
return PaymentInvoice(**api_response) if api_response else None
current_app.logger.debug(
'services refund_payment response',
payment_identifier=payment_identifier,
api_response=api_response,
)
return PaymentRefundInvoice(**api_response) if api_response else None

except Exception as err:
raise SBCPaymentException(err)
Expand Down
3 changes: 2 additions & 1 deletion api/namex/services/solr/solr_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def _get_name_without_designation(cls, name):

@classmethod
def get_possible_conflicts(cls, name, start=0, rows=100):
q_name = cls._name_pre_processing(name)
# q_name = cls._name_pre_processing(name)
q_name = name.lower().strip()
q_name = cls._get_name_without_designation(q_name)

candidates = SolrClient.get_possible_conflicts(q_name, start, rows)
Expand Down
1 change: 0 additions & 1 deletion api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def client_ctx(app):
with app.test_client() as c:
yield c


@pytest.fixture(scope='session')
def db(app, request):
"""
Expand Down
20 changes: 20 additions & 0 deletions api/tests/python/end_points/payments/test_payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,26 @@ def mock_publish(topic: str, payload: bytes):
'total': 31.5,
},
)

# Mock the get_payment API call that happens during payment completion
mocker.patch.object(
SBCPaymentClient,
'get_payment',
return_value={
'id': 1,
'serviceFees': 1.5,
'paid': 31.5,
'refund': 0.0,
'total': 31.5,
'isPaymentActionRequired': False,
'statusCode': 'CREATED',
'businessIdentifier': 'NR L000001',
'createdOn': '2021-01-14T23:52:05.531317+00:00',
'lineItems': [{'filingTypeCode': 'NM620', 'priority': False, 'waiveFees': False}],
'references': [],
},
)

payment = execute_payment(client, jwt, create_payment_request, action)
assert payment['action'] == action
if complete_payment:
Expand Down
Loading
Loading