Repository navigation
[CC-4346] Nullable paylater plan model: all params gettable for invoice & direct debit - #255
Merged
Merged
Conversation
…e for every type QA on PR #253 (CC-4346) found the three paylater plan types return structurally different plan objects, but the SDK forced them all through one InstallmentPlan class with non-nullable getters. The live Unzer OpenAPI spec declares a single schema for all three /plans endpoints with every field optional and no type discriminator; the types differ only in which optional fields they populate at runtime (invoice/direct-debit omit the interest-rate fields and send rates without a date). So one tolerant class with every field nullable is the correct mapping, not a subclass split. - InstallmentPlan: all getters/setters nullable; add interestAmount (getInterestAmount) that was dropped. Fixes getSecciUrl()/ getEffectiveInterestRate() throwing on invoice/direct-debit plans. - PaylaterPlans: setAmount/setCurrency/setPlans tolerate null (a null field in the response no longer TypeErrors the fetch; null plans -> empty list). - Tests: real invoice + direct-debit response fixtures (previously only installment-shaped data existed, which hid the crash); unit mapping now parameterized over all three types incl. interestAmount; a null-field regression test; the integration test exercises all three types via fetchPaylaterPlans and asserts every plan parameter is gettable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ent BC test The legacy fetchPaylaterInstallmentPlans() flow maps through the same InstallmentPlan class widened to nullable here. Its mapping regression test (PaylaterInstallmentPlansTest::verifyJsonResponseIsHandledProperly) already asserts the plan getters still map, but not the two fields this change touched. Pin getNumberOfRates() and the new getInterestAmount() on the legacy path so backward compatibility covers exactly what changed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… BC subclass Mirror the container-level rename (PaylaterInstallmentPlans -> PaylaterPlans) at the plan-item level so early adopters of the new fetchPaylaterPlans() flow never have to migrate twice. Since PaylaterPlans is unreleased (4.1.0), changing what getPlans() returns is free now. - Add PaylaterPlan as the canonical item model (carries the nullable getters + interestAmount). Fluent setters return `static` so the subclass keeps its own return typing. - InstallmentPlan becomes an empty @deprecated subclass of PaylaterPlan: the legacy fetchPaylaterInstallmentPlans() flow still returns InstallmentPlan and existing type hints / instanceof checks keep working (is-a PaylaterPlan). Unlike the standalone container deprecation, inheritance is safe here: the item has no sibling-typed parameter method that could widen and fatal. - PaylaterPlans now maps to PaylaterPlan; PaylaterInstallmentPlans unchanged. - Tests: new flow asserts PaylaterPlan instances; legacy flow asserts items are still InstallmentPlan and now also PaylaterPlan; added a deprecated-subclass guard. CHANGELOG: PaylaterPlan added, InstallmentPlan deprecated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ce, to preserve BC
The previous commit made InstallmentPlan a subclass of PaylaterPlan. With
`static` fluent-setter returns this changed InstallmentPlan::setX()'s declared
return type to `static` and made an existing integration that subclasses
InstallmentPlan and overrides a setter with `: InstallmentPlan` fatal
("must be compatible with ... : static") — the same signature-widening break
the container deprecation (PaylaterInstallmentPlans) deliberately avoided.
Switch to the standalone pattern used for the legacy containers:
- InstallmentPlan is reverted to its original signatures byte-for-byte (only an
@deprecated docblock added); it does NOT extend PaylaterPlan. Its setters
return `: InstallmentPlan` exactly as released, so existing type hints and
subclasses keep working.
- PaylaterPlan is an independent new class with the nullable getters +
interestAmount and `: PaylaterPlan` returns (no `static`).
- Legacy fetchPaylaterInstallmentPlans() returns InstallmentPlan; new
fetchPaylaterPlans() returns PaylaterPlan. No is-a relationship between them,
matching the container decision.
Tests: replaced the subclass guard with a reflection test pinning
InstallmentPlan's setter return types to InstallmentPlan and asserting it is
not a subclass of PaylaterPlan. Full unit suite: 808 tests green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…legacy Feeds the same installment response to both PaylaterInstallmentPlans (legacy) and PaylaterPlans (new) and asserts the mapped plan data is identical (id, amount, currency, and per plan: secciUrl, numberOfRates, totalAmount, minimumInstallmentFee, nominal/effective interest rate, and rates). Documents that switching flows is a rename of the query/result/item types plus passing the payment type to fetchPaylaterPlans(), not a data-shape change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…GELOG fixes From QA review on PR #254: - Make PaylaterPlans::setCountry()/setCustomerType() accept null, completing the bug-4 null-tolerance (a null field in the response no longer TypeErrors the fetch). These are query-only fields not present in the /plans response, so the path was unreachable via the real API, but the guard is free and uniform. Extended the null-field regression test to cover currency/country/customerType. - Restore the "## [4.0.2]" CHANGELOG heading that a prior edit accidentally dropped, which had mis-nested the 4.0.2 Changed entries under 4.1.0. - Document the PaymentServiceInterface BC: fetchPaylaterPlans() was added to the interface (breaks external implementors) — noted under a 4.1.0 ### Changed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rface note - Remove the PaymentServiceInterface "### Changed/Breaking change" note. Adding fetchPaylaterPlans() to the interface is not a consumer-facing break: the interface already declared fetchPaylaterInstallmentPlans() in the released 4.0.2, Unzer::getPaymentService() is typed to the interface, and only an external class that itself implements the interface is affected (same pattern as the already-shipped legacy method). No breaking change for SDK users. - Collapse the paylater "now exposed / previously dropped" and the nullable "Fixed" bullets (they describe churn within this unreleased feature, not a net change vs 4.0.2) into one Added entry describing PaylaterPlan's fields. - Simplify the deprecation entries (drop the standalone/inheritance detail). The setCountry/setCustomerType null-tolerance code fix stays; it just no longer needs a CHANGELOG line. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…8.2) Replace the docblock-only `@var` properties with native typed properties (`?int`/`?string`/`?float`/`?array`, each defaulting to null). The engine now enforces the types at the language level instead of relying on annotations, matching the newer resource style (e.g. Resources/V2/Paypage). Safe here: the fields are private (expose() only reflects protected properties) and default to null, so there is no uninitialized-typed-property access. Values still flow through the existing typed setters, so mapping is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Convert the PaylaterPlans container's docblock-only `@var` properties to native typed properties (`?float`/`?string`/`array`/`?PaylaterPlansQuery`, defaulting to null / []). Matches the already-typed PaylaterPlansQuery and PaylaterPlan. Properties are private (not read by expose(), which only reflects protected) and default-initialized, and values still flow through the typed setters, so mapping and behaviour are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…overage Minor follow-ups from an independent PR review (no behaviour change): - Fix @return docblocks on PaylaterPlans getters to match the nullable signatures (float -> float|null, string -> string|null). - Clarify PaylaterPlan class docblock: invoice/direct-debit omit nominalInterestRate and effectiveInterestRate specifically (interestAmount is sent by all three types, so the "omit interest-rate fields" wording was ambiguous). - Strengthen nullPlanAndEnvelopeFieldsMapWithoutError: set numberOfRates and totalAmount to null too, so their null-tolerance is actually exercised. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Khaled-Mahmoud-Unzer
approved these changes
Nov 26, 2026
Khaled-Mahmoud-Unzer
left a comment
There was a problem hiding this comment.
QA review against the bugs from CC-4346 comment 497250 and my review on #254. I ran the CC-4346 tests in php-sdk-test-automation (offline and live sandbox) against this branch: 66 of 67 pass. The one failure is the lowercase-currency error, which is on the API side, not the SDK.
Fixed
- Calling
getEffectiveInterestRate()on invoice and direct debit plans returnsnullinstead of crashing. getInterestAmount()exists and returns the value from the response.getSecciUrl()returnsnullwhen the plan has no SECCI link.- A
nullvalue in any field no longer crashes the fetch, now includingcountry,customerType, and a plan where every field is null. - The deleted
## [4.0.2]CHANGELOG heading is back.
Backward compatibility is kept: the legacy fetchPaylaterInstallmentPlans() still returns InstallmentPlan, and the legacy classes keep their 4.0.2 signatures.
Not fixed
- Bug 5: there's still no CHANGELOG line about
fetchPaylaterPlans()being added toPaymentServiceInterface. I understand it was left out on purpose. It only affects external classes that implement the interface, and it's docs only, so I'm not blocking on it. It was suggested in CC-4346 comment 496917, so please confirm there that leaving it out is fine.
Approving.
Ryouzanpaku
enabled auto-merge (squash)
November 26, 2026 10:16
sixer1182
approved these changes
Nov 26, 2026
sixer1182
left a comment
Member
There was a problem hiding this comment.
Approving. The nullable PaylaterPlan model fixes the invoice / direct debit TypeError, and the legacy classes are untouched apart from the @deprecated docblocks.
Two non-blocking CHANGELOG suggestions:
- The line about
getMinimumInstallmentFee()on the legacyInstallmentPlanwas removed, but that method is new compared to 4.0.2. I would restore it, since the entry now says the legacy types are unchanged. fetchPaylaterPlans()was added toPaymentServiceInterface. A one-line note would help anyone who implements that interface themselves.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #254 (closed automatically when its branch was renamed from
CC-4346-plan-nullable-mappingtoCC-4346/plan-nullable-mappingto satisfy theCC-{ticket}/{title}branch-name check). Same commits (929a9b2a); the QA review, Copilot review, and discussion threads live on #254.Why
Follow-up to merged CC-4346 (#253). QA found the three paylater plan types return structurally different plan objects, but the SDK forced them through one
InstallmentPlanwith non-nullable getters, so invoice/direct-debit plans threw aTypeError, andinterestAmountwas dropped.What
PaylaterPlan— new canonical plan-item model (all getters nullable; addsgetInterestAmount()); uses native typed properties. Fixes the invoice/direct-debitTypeErrorand null-field crashes.PaylaterPlans— new result container (null-tolerant envelope setters);getPlans()returnsPaylaterPlan[]. Typed properties.PaylaterPlansQuery— generalized query (already typed).InstallmentPlan,InstallmentPlansQuery,PaylaterInstallmentPlans,fetchPaylaterInstallmentPlans()are byte-for-byte unchanged (only@deprecateddocblocks added).InstallmentPlanis a standalone deprecated class (not a subclass ofPaylaterPlan) so its return types stay exactly as released — verified by reflection test.Verification
TypeError).🤖 Generated with Claude Code