Repository navigation
[CC-2923] Make PayPage V2 Risk.confirmedAmount nullable - #193
Ryouzanpaku wants to merge 3 commits into
Conversation
confirmedAmount was a primitive double defaulting to 0.0, so it was always serialized into the PayPage V2 request even when the merchant never set it. Change it to a nullable Double so Gson omits it unless explicitly set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Changelog and version edits are scoped to the release ticket (CC-4252), so this feature branch no longer touches CHANGELOG and won't conflict.
|
The change fulfils the ticket. One note for the release notes: |
…medAmount in changelog getConfirmedAmount() now returns Double instead of primitive double; callers assigning to a primitive double can hit a NullPointerException when unset. Addresses PR #193 review note (sixer1182). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ryouzanpaku
left a comment
There was a problem hiding this comment.
Independent Code Review — [CC-2923] Make PayPage V2 Risk.confirmedAmount nullable
Summary
The change switches Risk.confirmedAmount from primitive double to boxed Double. Because Gson omits null fields and JsonParser uses default (non-null-serializing) config, an unset confirmedAmount is now left out of the PayPage V2 request body, while a value set via setConfirmedAmount(...) — including 0.0 — is still serialized. This precisely matches the bug and both acceptance criteria in CC-2923 ("only set when setConfirmedAmount() is used" / "default creation does not assign a value"). Lombok @Data with the repo's lombok.accessors.chain=true regenerates the getter/setter, so existing chained usages (PaypageV2Test, PaylaterInvoiceTest) still compile via autoboxing. The new RiskTest is a focused, API-key-free unit test with good edge coverage (0.0, positive, negative). Minimal, correct, well-scoped fix.
Issues (to resolve before merge — no code change to this diff expected)
- Required
Unit tests/buildcheck is currently red. Thebuildjob runsmvn test --fail-at-end, which also executes the ~35 integration tests that hit the live sandbox (token.test.upcgw.com,paypage.test.unzer.com) and depend on secrets/live availability — a known flaky source. The visible log is truncated before the failure summary, and the newRiskTestis a pure unit test unrelated to that suite (author reportsmvn test -Dtest=RiskTest→ 4/4 green on JDK 17). Please confirm the failure is the pre-existing integration flakiness (not this change) and get the required check green before merging; I could not positively seeRiskTestexecute in the truncated CI log.
Suggestions (non-blocking)
- Public-API / binary breaking change. The generated accessors change signature: getter return
double→Doubleand setter paramdouble→Double. Source-compatible for callers via auto-(un)boxing, but binary-incompatible for pre-compiled consumers, anddouble x = risk.getConfirmedAmount()can now NPE when unset. Appropriate for a published SDK to call out in release notes. Already acknowledged by @sixer1182 and documented by the author in the 5.10.0Fixedentry in #197 — note the implied merge dependency on that changelog PR. - Assertion robustness (minor).
confirmedAmountIsSerializedWhenSetrelies oncontains("\"confirmedAmount\": " + amount), which couples the test to Gson's pretty-print spacing anddouble→string formatting. It passes against the currentJsonParserconfig, but deserializing and asserting the numeric field would be marginally more resilient. Optional.
Overall: the code change is correct and complete for CC-2923. Posting as a comment (not a block on the code) — the only merge gate is confirming the red CI is unrelated and green.
| private String customerGroup; | ||
| private Integer confirmedOrders; | ||
| private double confirmedAmount; | ||
| private Double confirmedAmount; |
There was a problem hiding this comment.
Correct fix for the Gson-omits-null behaviour. Note: via Lombok @Data this changes the generated accessors' signatures (getter double→Double, setter param double→Double) — source-compatible through auto-(un)boxing but a binary-incompatible change for pre-compiled SDK consumers, and double x = risk.getConfirmedAmount() can NPE when unset. Worth the release note (already captured in #197).
sixer1182
left a comment
There was a problem hiding this comment.
Requesting changes for two reasons.
-
Binary compatibility. Changing
Risk.confirmedAmountfromdoubletoDoublechanges the getter and setter signatures (DtoLjava/lang/Double;). Code compiled against 5.9.0 that callsgetConfirmedAmount()orsetConfirmedAmount(double)fails at runtime withNoSuchMethodError. Callers that unbox the getter result get an NPE when the value was never set. The CHANGELOG entry in #197 places this in 5.10.0, a minor release. Please either (a) confirm that a major version bump is intended, or (b) keep the primitive getter and setter signatures and change only the serialization (for example a Gson exclusion for unset values), so the public API stays unchanged. If the break stays, the changelog must state it. -
Test assertion.
RiskTest.confirmedAmountIsSerializedWhenSetchecks for the exact string"confirmedAmount": <value>with one space after the colon. That depends on the pretty-printer inJsonParser. Please compare parsed JSON instead, or confirm the formatting is stable.
…n unset Address review feedback: instead of changing Risk.confirmedAmount from double to Double (a source/binary break), keep the public double getConfirmedAmount() / setConfirmedAmount(double) signatures and back them with a nullable Double field so Gson omits the value only when it was never set. Preserves 5.9.0 compatibility (no NoSuchMethodError, no unbox NPE) while still satisfying CC-2923. Also assert serialized JSON by parsing instead of pretty-print string matching. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ount note Move the SECCI plans feature, minimumInstallmentFee, and fetchPaylaterInstallmentPlans deprecation (from #198) into this release changelog, which owns the 5.10.0 version bump. Correct the Risk.confirmedAmount Fixed entry: the public double API is kept (see #193), so there is no source/binary break. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks — addressed both points in 48c399d:
|
What
com.unzer.payment.models.paypage.Risk.confirmedAmountwas a primitivedouble, which defaults to0.0. Because Gson serializes primitives unconditionally, every PayPage V2 request carried"confirmedAmount": 0.0even when the merchant never calledsetConfirmedAmount(...).This changes the field to a nullable
Doubleso it is only serialized when explicitly set (Gson omitsnullfields by default). Lombok@Datakeeps generating the getter/setter.Why
CC-2923 —
confirmedAmountshould remain unset unlesssetConfirmedAmount()is called.Tests
RiskTest(new): defaultRiskomitsconfirmedAmountfrom the serialized body; a set value (including0.0and negatives) is serialized. Verified withmvn test -Dtest=RiskTeston JDK 17 — 4/4 pass.🤖 Generated with Claude Code