Skip to content

[CC-4346] Nullable paylater plan model: all params gettable for invoice & direct debit - #254

Closed
Ryouzanpaku wants to merge 10 commits into
mainfrom
CC-4346-plan-nullable-mapping
Closed

Ryouzanpaku wants to merge 10 commits into
mainfrom
CC-4346-plan-nullable-mapping

Conversation

@Ryouzanpaku

Copy link
Copy Markdown
Contributor

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 InstallmentPlan class with non-nullable getters, so getSecciUrl()/getEffectiveInterestRate() throw a TypeError on real invoice and direct-debit plans, and interestAmount was dropped entirely.

Root-cause finding

The authoritative Unzer OpenAPI spec (https://api.unzer.com/swagger-ui/api-docs) declares one schema for all three /plans endpoints — every field optional, nothing required/nullable-flagged, and no type discriminator in the response. The types differ only in which optional fields they populate at runtime (invoice/direct-debit omit nominalInterestRate/effectiveInterestRate and send rates without a date). 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; add interestAmount (getInterestAmount()). Fixes QA bugs 1 (effectiveInterestRate), 2 (interestAmount dropped), 3 (secciUrl).
  • PaylaterPlans — setAmount/setCurrency/setPlans tolerate null; a null field in the response no longer TypeErrors the fetch, and plans: null maps to an empty list. Fixes QA bug 4 (same pattern as CC-4255/CC-4256).
  • Tests — added real invoice + direct-debit response fixtures (only installment-shaped data existed before, which hid the crash). Unit mapping is now parameterized over all three types incl. interestAmount, plus a null-field regression test. The integration test exercises all three types via fetchPaylaterPlans and asserts every plan parameter is gettable from the live response.
  • CHANGELOG updated under 4.1.0.

Verification

  • vendor/bin/phpunit test/unit → 805 tests, 3128 assertions, green (17 in PaylaterPlansTest).
  • All changed files lint clean; no external callers of the embedded InstallmentPlan getters (the sibling legacy InstalmentPlan already uses nullable getters, so this matches convention).
  • Integration test needs the sandbox key to run (not executed in PR CI).

Notes

  • QA bug 5 (CHANGELOG line for the PaymentServiceInterface BC) is doc-only and out of scope here.
  • Minor BC: InstallmentPlan::getSecciUrl()/getEffectiveInterestRate() widen string/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

Ryouzanpaku and others added 3 commits November 25, 2026 10:39
…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>
@Ryouzanpaku

Copy link
Copy Markdown
Contributor Author

Follow-up: plan-item rename InstallmentPlan → PaylaterPlan (done before release, on purpose)

To avoid making early adopters of the new fetchPaylaterPlans() flow migrate twice, the plan-item rename is done now (same spirit as the container rename PaylaterInstallmentPlans → PaylaterPlans), while PaylaterPlans is still unreleased:

  • PaylaterPlan is the new canonical item model (carries the nullable getters + interestAmount). PaylaterPlans::getPlans() now returns PaylaterPlan[].
  • InstallmentPlan is now an empty @deprecated subclass of PaylaterPlan. The deprecated fetchPaylaterInstallmentPlans() flow still returns InstallmentPlan, and existing InstallmentPlan type-hints / instanceof checks keep working (an InstallmentPlan is-a PaylaterPlan). Fluent setters use : static, so the subclass keeps its own return typing.

Why inheritance here, when the container deprecation used standalone classes: the container couldn't inherit because PaylaterInstallmentPlans::setQueryParameter(InstallmentPlansQuery) would have widened a parameter type (a PHP declaration-compat fatal). The plan item has no sibling-typed parameter method, so inheritance is safe and gives zero duplication + a useful is-a relationship.

BC note: PaylaterPlans::getPlans() changing its element type InstallmentPlan → PaylaterPlan is only a change within the unreleased 4.1.0 feature — no released consumer is affected. The legacy installment path is unchanged.

Unit suite: 806 tests, 3149 assertions, green.

…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>
@Ryouzanpaku

Copy link
Copy Markdown
Contributor Author

Correction: InstallmentPlan is now standalone, not a subclass of PaylaterPlan

The earlier note described making InstallmentPlan extends PaylaterPlan. That reintroduced the exact signature-widening break the container deprecation avoided, so it was reverted. Proof (before the fix):

  • InstallmentPlan::setSecciUrl() declared return type became static (not InstallmentPlan).
  • An existing integration that subclasses InstallmentPlan and overrides a setter with : InstallmentPlan fatals: "must be compatible with … : static".

Final approach mirrors how the legacy containers were handled:

  • InstallmentPlan is reverted to its original signatures byte-for-byte (only an @deprecated docblock added) and is a standalone class — it does not extend PaylaterPlan. Its setters return : InstallmentPlan exactly as released.
  • PaylaterPlan is an independent new class with the nullable getters + interestAmount.
  • Legacy fetchPaylaterInstallmentPlans() → InstallmentPlan; new fetchPaylaterPlans() → PaylaterPlan. No is-a relationship, same as the container decision.

Verified after the fix: InstallmentPlan::setSecciUrl/​setNumberOfRates/​setEffectiveInterestRate all report return type InstallmentPlan, is_subclass_of(InstallmentPlan, PaylaterPlan) === false, and the external-subclass override that previously fataled now compiles. Added a reflection test pinning these. Unit suite: 808 tests green (unit only — integration needs the sandbox key).

…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>
@Ryouzanpaku

Copy link
Copy Markdown
Contributor Author

Verified against the live sandbox (SBX)

Ran the integration tests locally against sbx-api.unzer.com (credentials from test/.env). Both flows pass.

New flow — fetchPaylaterPlans() — test/integration/PaymentTypes/PaylaterPlansTest.php: 7 tests, 185 assertions, OK. Real responses confirm the modeled shapes:

  • paylater-installment → full fields incl. interestAmount (e.g. "1.53"), effectiveInterestRate, dated rates.
  • paylater-invoice / paylater-direct-debit → numberOfRates:1, interestAmount:"0.00", no nominalInterestRate/effectiveInterestRate, single rate without a date. All read back as null (not a TypeError), secciUrl present and downloadable.
  • unsupported type (sepa-direct-debit) → 404 API.720.100.001 surfaced as UnzerApiException; negative amount / invalid currency / invalid country → 400 surfaced as UnzerApiException.

Legacy flow — fetchPaylaterInstallmentPlans() — test/integration/PaymentTypes/PaylaterInstallmentTest.php (plan tests): 2 tests, 4 assertions, OK — backward compatibility confirmed end-to-end.

Unit suite remains green (809 tests). The SDK masks the Authorization header in its debug logs, so no credentials were exposed.

@Ryouzanpaku
Ryouzanpaku marked this pull request as ready for review November 25, 2026 13:47
@Ryouzanpaku
Ryouzanpaku requested a review from a team as a code owner November 25, 2026 13:47

@Khaled-Mahmoud-Unzer Khaled-Mahmoud-Unzer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

  1. Calling getEffectiveInterestRate() on invoice and direct debit plans returns null instead of crashing.
  2. getInterestAmount() now exists and returns the value from the response.
  3. getSecciUrl() returns null when the plan has no SECCI link, instead of crashing.
  4. A null value in amount, currency, plans, secciUrl or installmentRates no longer crashes the fetch.

Not fixed

  1. A null value in customerType or country still crashes the fetch. PaylaterPlans::setCustomerType(string) and setCountry(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
  2. The CHANGELOG still has no line about fetchPaylaterPlans() being added to PaymentServiceInterface (bug 5). That change breaks external classes that implement the interface.

New finding

  1. 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 ### Changed entries 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>
@Ryouzanpaku

Copy link
Copy Markdown
Contributor Author

Thanks @Khaled-Mahmoud-Unzer — all three open points are valid; addressed in 70c6fbec.

Not fixed #1 — setCustomerType/setCountry crash on null: fixed. Both are now ?string, so a null field in the response is tolerated (completes bug 4). Context: country/customerType are query-only and never appear in the /plans response envelope (confirmed in the OpenAPI spec and the live-SBX runs), so the crash wasn't reachable via a real API response — but the guard is free and makes null-tolerance uniform, so no reason to leave it. Extended nullPlanAndEnvelopeFieldsMapWithoutError to cover currency/country/customerType null.

Not fixed #2 — CHANGELOG missing the PaymentServiceInterface BC (bug 5): added under a new 4.1.0 ### Changed — explicitly flagged as a breaking change for external implementors of PaymentServiceInterface.

New finding — deleted ## [4.0.2] heading: good catch, that was my mistake — an earlier edit's match range swallowed the heading, mis-nesting the 4.0.2 ### Changed entries under 4.1.0. Heading restored; the 4.1.0 section now reads Added → Changed → Deprecated → Removed → Fixed and 4.0.2 is a separate section again.

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>
@Ryouzanpaku

Copy link
Copy Markdown
Contributor Author

Follow-up on bug 5 (the PaymentServiceInterface CHANGELOG note) — after reviewing with the maintainer, I removed that note rather than keeping it, because it is not a consumer-facing breaking change and this release is intended to ship without breaking changes:

  • PaymentServiceInterface already declared fetchPaylaterInstallmentPlans() in the released 4.0.2 (verified against the 4.0.2 tag), and Unzer::getPaymentService() is typed to return the interface. Adding fetchPaylaterPlans() to it is the same established pattern the SDK already uses.
  • Nobody who calls the SDK is affected. The only code that would need the new method is an external class that itself implements PaymentServiceInterface (i.e. reimplements the SDK's service) — an unusual case, and the exact same kind of change that already shipped when the legacy method was added.
  • Removing it from the interface would be worse (it'd break the facade's typed call and diverge from the released design), so the code stays as-is.

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 PaylaterPlan Added entry. The ## [4.0.2] heading you spotted is restored. The setCountry/setCustomerType null-tolerance code fix remains in place.

Ryouzanpaku and others added 3 commits November 25, 2026 15:54
…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>
@Ryouzanpaku
Ryouzanpaku deleted the CC-4346-plan-nullable-mapping branch November 26, 2026 09:49
Ryouzanpaku added a commit that referenced this pull request Nov 26, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants