This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from open-formulieren/feature/4380-implement-ex…
…tra-payment-attributes ✨ [open-formulieren/open-forms#4380] Extra StUF-ZDS payment attributes
- Loading branch information
Showing
16 changed files
with
937 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,40 +10,84 @@ on: | |
pull_request: | ||
workflow_dispatch: | ||
|
||
env: | ||
IMAGE_NAME: openformulieren/open-forms-ext-stuf-zds-payments | ||
|
||
jobs: | ||
tests: | ||
name: Run the Django test suite | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python: ['3.10', '3.11', '3.12'] | ||
django: ['4.2'] | ||
|
||
name: Run the test suite (Python ${{ matrix.python }}, Django ${{ matrix.django }}) | ||
services: | ||
postgres: | ||
image: postgres:14 | ||
env: | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
ports: | ||
- 5432:5432 | ||
# Needed because the postgres container does not provide a healthcheck | ||
options: | ||
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
--name postgres | ||
redis: | ||
image: redis:6 | ||
ports: | ||
- 6379:6379 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
- name: Checkout Open Forms | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: open-formulieren/open-forms | ||
path: open-forms | ||
|
||
- name: Checkout StUF-ZDS payments extension | ||
uses: actions/checkout@v4 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
path: extension | ||
|
||
- name: Install dependencies | ||
run: pip install tox tox-gh-actions | ||
- name: Set up backend environment | ||
uses: maykinmedia/[email protected] | ||
with: | ||
apt-packages: 'libxml2 libxmlsec1 libxmlsec1-openssl gettext postgresql-client gdal-bin' | ||
python-version: '3.12' | ||
optimize-postgres: 'yes' | ||
pg-service: 'postgres' | ||
setup-node: 'yes' | ||
nvmrc-custom-dir: 'open-forms' | ||
npm-ci-flags: '--legacy-peer-deps' | ||
working-directory: ${{ github.workspace }}/open-forms | ||
|
||
- name: Make symlink in OF to the extension | ||
run: | | ||
ln -s ${{ github.workspace }}/extension/stuf_zds_payments ${{ github.workspace }}/open-forms/src | ||
- name: Run tests | ||
run: tox | ||
run: | | ||
export OPEN_FORMS_EXTENSIONS=stuf_zds_payments | ||
python src/manage.py compilemessages | ||
coverage run --source=stuf_zds_payments src/manage.py test stuf_zds_payments | ||
coverage combine | ||
coverage xml -o coverage-extension.xml | ||
env: | ||
PYTHON_VERSION: ${{ matrix.python }} | ||
DJANGO: ${{ matrix.django }} | ||
DJANGO_SETTINGS_MODULE: openforms.conf.ci | ||
SECRET_KEY: dummy | ||
DB_USER: postgres | ||
DB_PASSWORD: '' | ||
working-directory: ${{ github.workspace }}/open-forms | ||
|
||
- name: Publish coverage report | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
root_dir: ${{ github.workspace }}/extension | ||
working-directory: ${{ github.workspace }}/open-forms | ||
files: ./coverage-extension.xml | ||
|
||
publish: | ||
name: Publish package to PyPI | ||
runs-on: ubuntu-latest | ||
needs: tests | ||
needs: | ||
- tests | ||
environment: release | ||
permissions: | ||
id-token: write | ||
|
@@ -54,13 +98,11 @@ jobs: | |
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
python-version: '3.12' | ||
|
||
- name: Build sdist and wheel | ||
run: | | ||
pip install build --upgrade | ||
python -m build | ||
pip install pip build --upgrade | ||
python -m build --sdist --wheel | ||
- name: Publish a Python distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
from django.apps import AppConfig | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class StufZdsPaymentsConfig(AppConfig): | ||
name = "stuf_zds_payments" | ||
label = "registration_stuf_zds_payments" | ||
verbose_name = _("StUF-ZDS (extra payments) registration plugin") | ||
|
||
def ready(self): | ||
from . import plugin # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from functools import partial | ||
|
||
from django.utils import timezone | ||
|
||
from openforms.logging import logevent | ||
from stuf.constants import EndpointType | ||
from stuf.models import StufService | ||
from stuf.service_client_factory import ServiceClientFactory, get_client_init_kwargs | ||
from stuf.stuf_zds.client import ( | ||
Client as _Client, | ||
NoServiceConfigured, | ||
PaymentStatus, | ||
ZaakOptions, | ||
fmt_soap_date, | ||
) | ||
from stuf.stuf_zds.models import StufZDSConfig | ||
|
||
|
||
class ZaakOptions(ZaakOptions): | ||
payment_status_update_mapping: list[dict] | ||
|
||
|
||
class Client(_Client): | ||
def set_zaak_payment( | ||
self, | ||
zaak_identificatie: str, | ||
partial: bool = False, | ||
extra: dict | None = None, | ||
) -> dict: | ||
data = { | ||
"betalings_indicatie": ( | ||
PaymentStatus.PARTIAL if partial else PaymentStatus.FULL | ||
), | ||
"laatste_betaaldatum": fmt_soap_date(timezone.now()), | ||
"extra": extra, | ||
} | ||
return self.partial_update_zaak(zaak_identificatie, data) | ||
|
||
def partial_update_zaak(self, zaak_identificatie: str, zaak_data: dict) -> None: | ||
context = { | ||
"zaak_identificatie": zaak_identificatie, | ||
**zaak_data, | ||
} | ||
|
||
self.execute_call( | ||
soap_action="updateZaak_Lk01", | ||
template="registrations/contrib/stuf_zds_payments/updateZaak.xml", | ||
context=context, | ||
endpoint_type=EndpointType.ontvang_asynchroon, | ||
) | ||
|
||
|
||
def get_client(options: ZaakOptions): | ||
config = StufZDSConfig.get_solo() | ||
if not (service := config.service): | ||
raise NoServiceConfigured("You must configure a service!") | ||
return StufZDSClient(service, options) | ||
|
||
|
||
def StufZDSClient(service: StufService, options: ZaakOptions) -> "Client": | ||
factory = ServiceClientFactory(service) | ||
init_kwargs = get_client_init_kwargs( | ||
service, | ||
request_log_hook=partial(logevent.stuf_zds_request, service), | ||
) | ||
|
||
return Client.configure_from( | ||
factory, | ||
options=options, | ||
failure_log_callback=partial(logevent.stuf_zds_failure_response, service), | ||
success_log_callback=partial(logevent.stuf_zds_success_response, service), | ||
**init_kwargs, | ||
) |
Oops, something went wrong.