From 2d1892768bb15f21dd75772de3ebcade980e72d4 Mon Sep 17 00:00:00 2001 From: Steven Bal Date: Mon, 5 Aug 2024 15:50:36 +0200 Subject: [PATCH 1/2] :sparkles: [open-formulieren/open-forms#4380] Add paymentId to plugin --- stuf_zds_payments/plugin.py | 8 +++++++- stuf_zds_payments/registration_variables.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/stuf_zds_payments/plugin.py b/stuf_zds_payments/plugin.py index 914e411..ad0f581 100644 --- a/stuf_zds_payments/plugin.py +++ b/stuf_zds_payments/plugin.py @@ -30,6 +30,7 @@ def default_payment_status_update_mapping() -> list[dict[str, str]]: "form_variable": "payment_public_order_ids", "stuf_name": "payment_public_order_ids", }, + {"form_variable": "provider_payment_ids", "stuf_name": "provider_payment_ids"}, ] @@ -97,7 +98,12 @@ def get_extra_payment_variables( variables_registry=variables_registry, ) if variable.key - in ["payment_completed", "payment_amount", "payment_public_order_ids"] + in [ + "payment_completed", + "payment_amount", + "payment_public_order_ids", + "provider_payment_ids", + ] and variable.key in key_mapping } diff --git a/stuf_zds_payments/registration_variables.py b/stuf_zds_payments/registration_variables.py index 38390a3..f717842 100644 --- a/stuf_zds_payments/registration_variables.py +++ b/stuf_zds_payments/registration_variables.py @@ -4,6 +4,7 @@ from django.utils.translation import gettext_lazy as _ +from openforms.payments.constants import PaymentStatus from openforms.plugins.registry import BaseRegistry from openforms.variables.base import BaseStaticVariable from openforms.variables.constants import FormVariableDataTypes @@ -57,3 +58,19 @@ def get_initial_value(self, submission: Submission | None = None): if submission is None: return None return submission.payments.get_completed_public_order_ids() + + +@register("provider_payment_ids") +class ProviderPaymentIds(BaseStaticVariable): + name = _("Provider payment IDs") + data_type = FormVariableDataTypes.array + + def get_initial_value(self, submission: Submission | None = None): + if submission is None: + return None + + return list( + submission.payments.filter( + status__in=(PaymentStatus.registered, PaymentStatus.completed) + ).values_list("provider_payment_id", flat=True) + ) From fda42a554e9722a5260594de39ba034855ab6553 Mon Sep 17 00:00:00 2001 From: Steven Bal Date: Mon, 5 Aug 2024 15:50:52 +0200 Subject: [PATCH 2/2] :white_check_mark: [open-formulieren/open-forms#4380] Update tests with paymentId --- .github/workflows/ci.yml | 2 + ...test_register_submission_with_payment.yaml | 42 ++++++++++--------- ...trationTestCase.test_set_zaak_payment.yaml | 12 +++--- ...correct_payment_status_update_mapping.yaml | 6 +-- stuf_zds_payments/tests/test_plugin.py | 20 ++++++++- 5 files changed, 53 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3eecdf9..1974c2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,8 @@ jobs: with: repository: open-formulieren/open-forms path: open-forms + # TODO remove after this is merged + ref: feature/4380-ogone-payment-id - name: Checkout StUF-ZDS payments extension uses: actions/checkout@v4 diff --git a/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_register_submission_with_payment.yaml b/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_register_submission_with_payment.yaml index f73cd6d..9d2c522 100644 --- a/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_register_submission_with_payment.yaml +++ b/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_register_submission_with_payment.yaml @@ -7,7 +7,7 @@ interactions: \ xmlns:BG=\"http://www.egem.nl/StUF/sector/bg/0310\"\n xmlns:GML=\"http://www.opengis.net/gml\"\n>\n \ \n Lk01\n \ \n zender_organisatie-0\nzender_applicatie-0\nzender_administratie-0\nzender_gebruiker-0\n\n\n\n - \ ontvanger_organisatie-0\nontvanger_applicatie-0\nontvanger_administratie-0\nontvanger_gebruiker-0\n\n\n58f3d63c-37ab-4b65-844d-fdb9da043b17\n20240805124256\n\n + \ ontvanger_organisatie-0\nontvanger_applicatie-0\nontvanger_administratie-0\nontvanger_gebruiker-0\n\n\n0c9e9f06-43cc-43a5-af3f-f9d131a2573e\n20240806073116\n\n \ ZAK\n \n \ \n T\n V\n \ \n \n @@ -16,18 +16,20 @@ interactions: \ \n \n \ 52.36673378967122 4.893164274470299\n \ \n \n \n - \ \n 20240805\n 20240805\n + \ \n 20240806\n 20240806\n \ N.v.t.\n \n\n \ 1\n N\n - \ 20240805124256\n + \ 20240806073116\n \ \n\nen\n\nBuzzBazz\n\ntrue\n\n40.0\n\nfoo\n\nbar\n\n\n\n\n + naam=\"payment_public_order_ids.1\">bar\n\n123456\n\n654321\n\n\n\n\n \ \n \ \n \ \n bar\n - \ \n foo\n 20240805\n + \ \n foo\n 20240806\n \ \n \n \n \n \n \ \n \n 20001231\n\n \n \ \n \n \n - \ 20240805124256\n + \ 20240806073116\n \ \n \n \n \n \n \n \n \ baz\n \n \n \ foo\n \n \ \n Status - gezet door verzendende applicatie.\n 20240805\n + gezet door verzendende applicatie.\n 20240806\n \ \n \n \n\n \n\n" headers: Accept: @@ -56,7 +58,7 @@ interactions: Connection: - keep-alive Content-Length: - - '5155' + - '5309' Content-Type: - application/soap+xml SOAPAction: @@ -89,7 +91,7 @@ interactions: Content-Type: - text/xml Date: - - Mon, 05 Aug 2024 12:42:56 GMT + - Tue, 06 Aug 2024 07:31:16 GMT Server: - Werkzeug/3.0.3 Python/3.12.4 status: @@ -102,7 +104,7 @@ interactions: \ \n\n\n \ \n Di02\n \ \n zender_organisatie-0\nzender_applicatie-0\nzender_administratie-0\nzender_gebruiker-0\n\n\n\n - \ ontvanger_organisatie-0\nontvanger_applicatie-0\nontvanger_administratie-0\nontvanger_gebruiker-0\n\n\ne4bcac4d-5fab-4a01-a28a-76d168bd7180\n20240805124256\n\n + \ ontvanger_organisatie-0\nontvanger_applicatie-0\nontvanger_administratie-0\nontvanger_gebruiker-0\n\n\ne35e443a-41e9-4a2c-8114-ac8ffe599611\n20240806073116\n\n \ genereerDocumentidentificatie\n \n\n \ \n\n" headers: @@ -136,7 +138,7 @@ interactions: \ genereerDocumentidentificatie\n \ \n melding\n \ \n - \ b3c8b5a4d32fb168\n + \ e6375e10167ae943\n \ \n \n \ \n" headers: @@ -147,7 +149,7 @@ interactions: Content-Type: - text/xml Date: - - Mon, 05 Aug 2024 12:42:56 GMT + - Tue, 06 Aug 2024 07:31:16 GMT Server: - Werkzeug/3.0.3 Python/3.12.4 status: @@ -160,25 +162,25 @@ interactions: \ \n\n\n \n \ Lk01\n \n zender_organisatie-0\nzender_applicatie-0\nzender_administratie-0\nzender_gebruiker-0\n\n\n\n - \ ontvanger_organisatie-0\nontvanger_applicatie-0\nontvanger_administratie-0\nontvanger_gebruiker-0\n\n\n3cac727d-3782-4905-b516-8ecc109a2c6c\n20240805124256\n\n + \ ontvanger_organisatie-0\nontvanger_applicatie-0\nontvanger_administratie-0\nontvanger_gebruiker-0\n\n\n421ed8d7-873c-4281-9dee-18f9d900d520\n20240806073116\n\n \ EDC\n \n \ \n T\n I\n \ \n \n - \ b3c8b5a4d32fb168\n foo\n - \ 20240805\n 20240805\n + \ e6375e10167ae943\n foo\n + \ 20240806\n 20240806\n \ inzending\n Ingezonden formulier\n application/pdf\n \ nld\n definitief\n - \ 20240805\n GEHEIM\n + \ 20240806\n GEHEIM\n \ open-forms\n \n \n - \ 20240805\n 20240806\n \n \n - \ 20240805124256\n + \ 20240806073116\n \ \n \ \n \ abc123\n my-form\n - \ \n 20240805124256\n + \ \n 20240806073116\n \ \n \n\n \n\n" headers: Accept: @@ -221,7 +223,7 @@ interactions: Content-Type: - text/xml Date: - - Mon, 05 Aug 2024 12:42:56 GMT + - Tue, 06 Aug 2024 07:31:16 GMT Server: - Werkzeug/3.0.3 Python/3.12.4 status: diff --git a/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_set_zaak_payment.yaml b/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_set_zaak_payment.yaml index 78276b2..c2e24a2 100644 --- a/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_set_zaak_payment.yaml +++ b/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_set_zaak_payment.yaml @@ -6,16 +6,18 @@ interactions: \ \n\n\n \ \n Lk01\n \ \n zender_organisatie-0\nzender_applicatie-0\nzender_administratie-0\nzender_gebruiker-0\n\n\n\n - \ ontvanger_organisatie-0\nontvanger_applicatie-0\nontvanger_administratie-0\nontvanger_gebruiker-0\n\n\na62fad4a-01c0-46ad-98a7-49592c88b21e\n20240805124256\n\n + \ ontvanger_organisatie-0\nontvanger_applicatie-0\nontvanger_administratie-0\nontvanger_gebruiker-0\n\n\n6bde64fb-3026-46f4-9fe7-fbb1430fb3dc\n20240806073117\n\n \ ZAK\n \n \ \n W\n V\n \ \n \n \ 1234\n Geheel\n - \ 20240805\n\n \n\n20240806\n\n \n\nen\n\nBuzzBazz\n\ntrue\n\n40.0\n\nfoo\n\nbar\n\n\n\n\n + naam=\"payment_public_order_ids.1\">bar\n\n123456\n\n654321\n\n\n\n\n \ \n\n \n\n" headers: Accept: @@ -25,7 +27,7 @@ interactions: Connection: - keep-alive Content-Length: - - '2171' + - '2325' Content-Type: - application/soap+xml SOAPAction: @@ -58,7 +60,7 @@ interactions: Content-Type: - text/xml Date: - - Mon, 05 Aug 2024 12:42:56 GMT + - Tue, 06 Aug 2024 07:31:17 GMT Server: - Werkzeug/3.0.3 Python/3.12.4 status: diff --git a/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_set_zaak_payment_incorrect_payment_status_update_mapping.yaml b/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_set_zaak_payment_incorrect_payment_status_update_mapping.yaml index 9b9aa08..e1ee3d2 100644 --- a/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_set_zaak_payment_incorrect_payment_status_update_mapping.yaml +++ b/stuf_zds_payments/tests/data/vcr_cassettes/StufZDSPaymentsRegistrationTestCase/StufZDSPaymentsRegistrationTestCase.test_set_zaak_payment_incorrect_payment_status_update_mapping.yaml @@ -6,12 +6,12 @@ interactions: \ \n\n\n \ \n Lk01\n \ \n zender_organisatie-0\nzender_applicatie-0\nzender_administratie-0\nzender_gebruiker-0\n\n\n\n - \ ontvanger_organisatie-0\nontvanger_applicatie-0\nontvanger_administratie-0\nontvanger_gebruiker-0\n\n\n59dedae3-715d-429f-ada3-e66c3b3fe3a9\n20240805124256\n\n + \ ontvanger_organisatie-0\nontvanger_applicatie-0\nontvanger_administratie-0\nontvanger_gebruiker-0\n\n\n5702aa56-3b39-4480-a7ca-301017577ae6\n20240806073117\n\n \ ZAK\n \n \ \n W\n V\n \ \n \n \ 1234\n Geheel\n - \ 20240805\n\n \n\n20240806\n\n \n\nen\n\nBuzzBazz\n\n40.0\n\n\n\n\n \ \n\n \n\n" @@ -56,7 +56,7 @@ interactions: Content-Type: - text/xml Date: - - Mon, 05 Aug 2024 12:42:56 GMT + - Tue, 06 Aug 2024 07:31:17 GMT Server: - Werkzeug/3.0.3 Python/3.12.4 status: diff --git a/stuf_zds_payments/tests/test_plugin.py b/stuf_zds_payments/tests/test_plugin.py index 104d146..8c3aff9 100644 --- a/stuf_zds_payments/tests/test_plugin.py +++ b/stuf_zds_payments/tests/test_plugin.py @@ -113,12 +113,22 @@ def setUpTestData(cls): amount=Decimal("25.00"), public_order_id="foo", status=PaymentStatus.completed, + provider_payment_id="123456", ) SubmissionPaymentFactory.create( submission=cls.submission, amount=Decimal("15.00"), public_order_id="bar", - status=PaymentStatus.completed, + status=PaymentStatus.registered, + provider_payment_id="654321", + ) + # failed payment, should be ignored + SubmissionPaymentFactory.create( + submission=cls.submission, + amount=Decimal("15.00"), + public_order_id="baz", + status=PaymentStatus.failed, + provider_payment_id="6789", ) def test_set_zaak_payment(self): @@ -142,6 +152,10 @@ def test_set_zaak_payment(self): bar + 123456 + + 654321 + """ ) @@ -207,6 +221,10 @@ def test_register_submission_with_payment(self): bar + 123456 + + 654321 + """ )