Skip to content

[IMP] my_compassion_payment_payu_gpo: ask the first and last name on the card apart - #442

Merged
NoeBerdoz merged 4 commits into
18.0from
18.0-payu-cardholder-first-last-name
Nov 4, 2026
Merged

NoeBerdoz merged 4 commits into
18.0from
18.0-payu-cardholder-first-last-name

Conversation

@davidwul

Copy link
Copy Markdown
Contributor

Requested by PayU to validate our production account: they want two separate fields for the cardholder's first name and last name, instead of a single "Name on card" field (follows #436 and #441).

  • Sponsorship fast checkout: "First name" / "Last name" under the e-mail, required by the PayU buttons only.
  • Donation email step: the same two fields, required when PayU is the only provider.
  • The two names are kept apart in the session (by sponsorship / order) and prefill the PayU card form, where they can still be corrected. Sessions from before this change, which hold a single full name, are split.
  • Full sponsorship form (no fast checkout): the card form is prefilled with the sponsor's first and last name, unless the sponsor still has the placeholder name.
  • A payer with the placeholder name gets the first and last name typed on the card, exactly as typed. They are no longer split again from the full name.
  • views/payment_templates.xml is removed: payment_payu_gpo now prefills its card form itself.

Depends on CompassionCH/compassion-accounting#298. Merge and deploy both together: -u payment_payu_gpo,my_compassion_payment_payu_gpo. With only one of the two modules updated, the view inheritance fails.

Tests: run locally on both modules, 151 tests, 0 failed. There are 2 errors in TestCardSubmission; they happen only locally, because an image is missing from the local filestore.

🤖 Generated with Claude Code

…the card apart

PayU asked for two fields to validate the production account. The fast
checkout and the donation email step ask the first and last name instead of
the name on card, kept apart until the card form, which payment_payu_gpo now
prefills itself. Without them, the sponsorship card form is prefilled with
the sponsor's first and last name. A placeholder payer gets the names as
typed, not split again.

@NoeBerdoz NoeBerdoz left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Thanks David. The flow is well thought through. The names are asked where the donor already types the e-mail, they are kept per sponsorship or order in the session, they prefill the card form where they can still be corrected, and only a placeholder donor is renamed. Old sessions with a single full name are handled too.

What we tested

Browser E2E on a copy of the migrated database, with CompassionCH/compassion-accounting#298, the Polish MyCompassion website and PayU's sandbox:

Scenario Result
Donation email step, visitor, PayU only Fields shown and required; the server refuses missing or blank names; card form prefilled; the placeholder donor renamed as typed after payment
Sponsorship fast checkout Same, through a 3-D Secure challenge; the sponsor renamed as typed, contract active
Full sponsorship form Prefilled from a sponsor with a real name, empty for a placeholder sponsor (no "(pending)")
Logged-in donor paying with another name The donor's name is kept
Swiss MyCompassion (no PayU) No name fields, payment works
Polish Labels, hint and server messages translated (the JS message of CompassionCH/compassion-accounting#298 is not; see there)

Tests: 151 pass with CompassionCH/compassion-accounting#298. TestCardholderName needs an available child in the database (assertTrue(self.child, ...) in setUp), so on a fresh database or in CI its 13 tests fail. Creating the child in setUp would make them self-contained.

Open points

Levels: Must fix (money or security) · Before go-live (before real donors use it) · Should fix · Suggestion

  1. Before go-live: Deployed without CompassionCH/compassion-accounting#298, this PR upgrades cleanly and then breaks the post-processing of every online payment, on all providers (thread on payment_transaction.py:116). Merge CompassionCH/compassion-accounting#298 first or together; a pre-migration check makes the wrong order fail loudly.
  2. Should fix: On the fast checkout, blank names (and a page opened before the deploy) end on the generic error page (thread on new_sponsorship_wizard.py).
  3. Suggestion: Monthly charges and BLIK still split the full name (thread on payment_transaction.py:111).
  4. Suggestion: A test for the guard that keeps a real donor's name (thread on test_recurring_card.py).

Small thing: a logged-in donor's donation card form comes empty, while the sponsorship one is prefilled from the sponsor's name. Not wrong, just inconsistent.

Verdict

Requesting changes for point 1 only: the guard is a few lines, and a wrong merge order would stop every payment in the Swiss database. The rest can follow.

Assisted-by: claude-opus-5-5, xhigh, claude-code
Assisted-by: gpt-6-astra, high, codex
Assisted-by: claude-opus-5-5, medium, claude-code

- The upgrade stops when payment_payu_gpo has no first and last names
  (compassion-accounting#298): without them, the post-processing of every
  online payment would fail.
- The browser refuses names made of spaces; a page opened before the deploy
  posts the full name, which is split.
- Without names typed (monthly charges, BLIK), PayU gets the payer's own
  first and last name; a signed-in donor's card form is prefilled with them.
- Tests: a real name is never replaced by the card's, the child is created.

Assisted-by: claude-opus-5-5, medium, claude-code
@davidwul

davidwul commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review, addressed in d0e5f5f:

  1. Pre-migration 18.0.1.3.0: the upgrade stops when payment_payu_gpo has no first and last names. Merge and deploy together with [IMP] payment_payu_gpo: ask the first and last name on the card apart compassion-accounting#298.
  2. pattern=".*\S.*" on the four name inputs. update() splits the legacy cardholder_name posted by a page opened before the deploy.
  3. Without names typed (monthly charges, BLIK), _payu_gpo_buyer_names sends the partner's own first and last name.
  4. New test: a real name is never replaced by the card's. TestCardholderName now creates its child.
  • A signed-in donor's donation card form is prefilled with their names, like a sponsor's.

Both PRs together locally: 158 tests, 0 failed. There are 2 errors in TestCardSubmission, caused by the local filestore (missing image on the provider copy).

@NoeBerdoz NoeBerdoz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second review

Thanks David, most of the first review is fixed in d0e5f5f, with tests: the old full name on the fast checkout, the partner's own names for monthly charges and BLIK, the guard that keeps a real donor's name, TestCardholderName creating its own child, and the signed-in donor's prefill (checked in the browser; it has no test). The pre-migration stops the wrong merge order, as intended.

What we tested

In the browser on PayU's sandbox, on a copy of the migrated database, with CompassionCH/compassion-accounting#298:

Scenario Result
Donation email step, names made of spaces Refused by the browser; nothing reaches the server
Fast checkout, names made of spaces Fails: still the error page (thread on the wizard view)
Fast checkout posting only the old full name Split ("Anna Maria" / "Wiśniewska"), prefilled on the card form, paid; PayU's buyer as split
Signed-in donor, donation card form Prefilled with the donor's own names
Names for a payment without the card form (shell) The partner's own first and last name, e.g. "E2E" / "PayU arrears ch", where the old split gave "E2E PayU arrears" / "ch"
Donation and sponsorship with Polish names PayU's buyer names exactly as typed

Upgrade probes on fresh databases: origin/18.0 accounting with this PR stops with your message; both new heads go through.

Open points

Levels: Must fix (money or security) · Before go-live (before real donors use it) · Should fix · Suggestion

  1. Before go-live: The pre-migration checks a column, so -u theme_compassion_2025,my_compassion passes it without upgrading payment_payu_gpo, and every PayU card payment is then refused (thread on pre-migration.py).
  2. Should fix: On the fast checkout, names made of spaces still end on the error page: the browser never checks the pattern there (thread on the wizard view).
  3. Should fix: TestCardSubmission.test_one_card_reaches_payu_per_order now fails with 0 != 1. Its _send_card sends no names, and the card route of CompassionCH/compassion-accounting#298 refuses the request before PayU. In your run, setUp stopped earlier on the missing filestore image, which hid it. Passing names, as the payment form does, makes the two modules' 156 tests pass:
                return PayuGpoController().payu_gpo_card_payment(
                    tx.reference,
                    payment_utils.generate_access_token(tx.reference),
                    "TOK_CARD",
                    cardholder_firstname="Anna",
                    cardholder_lastname="Nowak",
                )

On a first install of this module, Odoo runs no migration, so the guard cannot help there: merging both PRs together is still what keeps the code in step.

Verdict

Still requesting changes, for point 1: one more check in the pre-migration. Points 2 and 3 are small.

Assisted-by: claude-opus-5-5, xhigh, claude-code
Assisted-by: gpt-6-astra, high, codex
Assisted-by: claude-opus-5-5, medium, claude-code

…last names

- The pre-migration checks the version of payment_payu_gpo, not its column:
  upgrading my_compassion creates the column without upgrading the card form.
- The fast checkout trims the names before its own check: it is submitted by
  script, so the browser's pattern never applied there.
- TestCardSubmission sends the names, as the payment form does, and creates
  its provider instead of copying it (no image needed).
- Test: a website with a terms URL still shows the name message.

Assisted-by: claude-opus-5-5, medium, claude-code
@davidwul

davidwul commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, second review addressed in 2f36fd0:

  1. The pre-migration checks latest_version of payment_payu_gpo (>= 18.0.1.1.0), not the column. Checked from a shell: it passes with the new accounting head, and stops with your message when the version is set back to 18.0.1.0.0.
  2. _onStepClick trims both names before the widget checks them. The pattern and its test are removed from the fast checkout and kept on the donation step.
  3. TestCardSubmission sends both names. It now creates its provider instead of copying it, so it no longer needs the provider image (that missing image is what hid the failure locally).

Locally, with #443 and CompassionCH/compassion-accounting#298, after -u theme_compassion_2025,my_compassion,payment_payu_gpo (which also upgraded this module): 158 tests, 0 failed, 0 errors.

About the English refusal on the card form: on the local PL website, whose default language is Polish, the card route answers in Polish ("Wpisz imię i nazwisko widniejące na karcie.") when the request carries the frontend_lang=pl_PL cookie the site sets. Your test website's default language was English.

@davidwul
davidwul requested a review from NoeBerdoz November 2, 2026 18:28

@NoeBerdoz NoeBerdoz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third review

Thanks David, the three points of the second review are fixed in 2f36fd0: the pre-migration checks the version of payment_payu_gpo, the fast checkout trims the names before its check, and TestCardSubmission sends both names with a provider of its own. The new test_name_message_next_to_a_terms_url is skipped without #443 and runs with it, as you said.

What we tested

On fresh databases, with CompassionCH/compassion-accounting#298, no browser this time:

  • Upgrade. Installed from 18.0 (this module at 18.0.1.2.0, payment_payu_gpo at 18.0.1.0.0). -u theme_compassion_2025,my_compassion stops with your message, with 18.0's accounting and with CompassionCH/compassion-accounting#298. Your command then passes, and so does -u payment_payu_gpo,theme_compassion_2025,my_compassion. Both end with this module at 18.0.1.3.0 and payment_payu_gpo at 18.0.1.1.0.
  • Tests. This module's tests pass, alone and merged with #443: test_one_card_reaches_payu_per_order passes, and test_name_message_next_to_a_terms_url is skipped alone and passes with #443. The my_compassion failures in these runs all come from the fresh database (no child, no active payment method).
  • Fast checkout. Read, and a script ran your _onStepClick with the form's validator on a mocked page: names made of spaces are refused for PayU and still accepted for the other payment modes.

About the language of the card route's refusal, see the thread on CompassionCH/compassion-accounting#298: the browser's language decides there, not the cookie.

Open points

Levels: Must fix (money or security) · Before go-live (before real donors use it) · Should fix · Suggestion

  1. Suggestion: The message of the pre-migration could ask to run the same upgrade again with payment_payu_gpo added (thread on pre-migration.py:27).
  2. Suggestion: A test for names made only of spaces (thread on test_cardholder_name.py:168).

Verdict

Approved. Merge it together with CompassionCH/compassion-accounting#298.

Assisted-by: claude-opus-5-5, high, claude-code
Assisted-by: claude-opus-5-5, medium, claude-code
Assisted-by: gpt-6-astra, high, codex
Assisted-by: Qwen3.8-Flash-Next-GGUF UD-IQ4_XS, high, pi

…pgrade

When the pre-migration stops an upgrade, the modules processed before this
one are already committed and those after it are left as they were. The
message now asks to add payment_payu_gpo and run the same upgrade again,
instead of an upgrade of the two PayU modules that leaves the others behind.

Test: names made of spaces posted to the fast checkout count as no name.
Assisted-by: claude-opus-5-5, high, claude-code
@NoeBerdoz
NoeBerdoz merged commit b566cb0 into 18.0 Nov 4, 2026
1 check passed
@NoeBerdoz
NoeBerdoz deleted the 18.0-payu-cardholder-first-last-name branch November 4, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants