Repository navigation
[CC-4346] Nullable paylater plan model: all params gettable for invoice & direct debit - #254
Ryouzanpaku wants to merge 10 commits into
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>
Follow-up: plan-item rename
|
…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>
Correction:
|
…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>
Verified against the live sandbox (SBX)Ran the integration tests locally against New flow —
Legacy flow — Unit suite remains green (809 tests). The SDK masks the |
Khaled-Mahmoud-Unzer
left a comment
There was a problem hiding this comment.
QA review against the bugs from CC-4346 comment 497250. I ran the CC-4346 tests in php-sdk-test-automation (offline and live sandbox) against this branch.
Fixed
- Calling
getEffectiveInterestRate()on invoice and direct debit plans returnsnullinstead of crashing. getInterestAmount()now exists and returns the value from the response.getSecciUrl()returnsnullwhen the plan has no SECCI link, instead of crashing.- A
nullvalue inamount,currency,plans,secciUrlorinstallmentRatesno longer crashes the fetch.
Not fixed
- A
nullvalue incustomerTypeorcountrystill crashes the fetch.PaylaterPlans::setCustomerType(string)andsetCountry(string)don't accept null, so bug 4 is only partly fixed.- Repro:
(new PaylaterPlans())->handleResponse(json_decode('{"customerType":null}')); - Actual:
TypeError: PaylaterPlans::setCustomerType(): Argument #1 ($customerType) must be of type string, null given
- Repro:
- The CHANGELOG still has no line about
fetchPaylaterPlans()being added toPaymentServiceInterface(bug 5). That change breaks external classes that implement the interface.
New finding
- The CHANGELOG change deleted the
## [4.0.2](https://github.com/unzerdev/php-sdk/compare/4.0.1..4.0.2)heading. Because of this, the 4.0.2### Changedentries now look like they belong to 4.1.0.
…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>
|
Thanks @Khaled-Mahmoud-Unzer — all three open points are valid; addressed in Not fixed #1 — Not fixed #2 — CHANGELOG missing the New finding — deleted Unit suite: 809 tests / 3300 assertions green. (Integration re-verified earlier against live SBX.) |
…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>
|
Follow-up on bug 5 (the
Separately, I trimmed the 4.1.0 CHANGELOG to net changes vs 4.0.2 only — the "nullable getters no longer throw" and "field now exposed" bullets described churn within this (unreleased) feature, so they're folded into the single |
…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>
…ce & direct debit (#255) * [CC-4346] Make paylater plan model nullable so all params are gettable 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> * [CC-4346] Pin numberOfRates and interestAmount on the legacy installment 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> * [CC-4346] Introduce PaylaterPlan item; deprecate InstallmentPlan as a 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> * [CC-4346] Make PaylaterPlan/InstallmentPlan standalone, not inheritance, 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> * [CC-4346] Add migration-equivalence test: new flow maps same data as 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> * [CC-4346] Address QA review: null-tolerant country/customerType, CHANGELOG 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> * [CC-4346] Trim 4.1.0 CHANGELOG to net changes; drop non-consumer interface 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> * [CC-4346] Use typed properties on PaylaterPlan (PHP 7.4+, min is now 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> * [CC-4346] Use typed properties on PaylaterPlans too 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> * [CC-4346] Polish from independent review: docblocks, null-tolerance coverage 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> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Why
Follow-up to the merged CC-4346 (PR #253). QA (comment 497250) found the three paylater plan types return structurally different plan objects, but the SDK forced them all through one
InstallmentPlanclass with non-nullable getters, sogetSecciUrl()/getEffectiveInterestRate()throw aTypeErroron real invoice and direct-debit plans, andinterestAmountwas dropped entirely.Root-cause finding
The authoritative Unzer OpenAPI spec (
https://api.unzer.com/swagger-ui/api-docs) declares one schema for all three/plansendpoints — every field optional, nothingrequired/nullable-flagged, and no type discriminator in the response. The types differ only in which optional fields they populate at runtime (invoice/direct-debit omitnominalInterestRate/effectiveInterestRateand send rates without adate). So the correct mapping is one tolerant class with every field nullable — not a subclass split (which would need an impossible discriminator-based dispatch).Changes
InstallmentPlan— all getters/setters nullable; addinterestAmount(getInterestAmount()). Fixes QA bugs 1 (effectiveInterestRate), 2 (interestAmountdropped), 3 (secciUrl).PaylaterPlans—setAmount/setCurrency/setPlanstoleratenull; a null field in the response no longerTypeErrors the fetch, andplans: nullmaps to an empty list. Fixes QA bug 4 (same pattern as CC-4255/CC-4256).interestAmount, plus a null-field regression test. The integration test exercises all three types viafetchPaylaterPlansand asserts every plan parameter is gettable from the live response.Verification
vendor/bin/phpunit test/unit→ 805 tests, 3128 assertions, green (17 inPaylaterPlansTest).InstallmentPlangetters (the sibling legacyInstalmentPlanalready uses nullable getters, so this matches convention).Notes
PaymentServiceInterfaceBC) is doc-only and out of scope here.InstallmentPlan::getSecciUrl()/getEffectiveInterestRate()widenstring/float→?string/?float. These belong to the unreleased 4.1.0 plan feature; the widening is what makes invoice/direct-debit usable at all.🤖 Generated with Claude Code