Repository navigation
[CC-4255] Fix Keypair plain-endpoint payment-type duplication - #250
Merged
Merged
Conversation
Keypair::handleResponse() appended availablePaymentTypes to $paymentTypes, but for the plain endpoint AbstractUnzerResource::updateValues() had already populated the list via the setter (the items are strings, not objects, so updateValues does not skip them). This doubled every entry. Replace the list instead of appending, which also makes repeated handling idempotent. The detailed endpoint is unaffected (its items are objects, skipped by updateValues). The existing unit test used assertArrayContains, which passed on the duplicated list; tightened to assertSame. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ryouzanpaku
added a commit
that referenced
this pull request
Nov 23, 2026
Ryouzanpaku
marked this pull request as ready for review
November 23, 2026 15:38
Ryouzanpaku
added a commit
that referenced
this pull request
Nov 23, 2026
…G) (#248) * [CC-4078] Rename unreleased changelog section to planned 4.1.0 The PHP SDK release is planned as 4.1.0, not 5.0.0. Rename the top unreleased CHANGELOG section header (and its compare URL) accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * [CC-4078] Add recurring entry to 4.1.0 changelog Scope the SepaDirectDebit recurring changelog entry under the release ticket (CC-4078) alongside the version rename, so the feature PR #247 (CC-4239) stays code-only and the two don't conflict. * [CC-4078] Complete the 4.1.0 changelog with all released changes Add the Keypair getRawResponse() addition (CC-4151) and the PIS payment-type deprecation (CC-4064) to the 4.1.0 section, alongside the recurring flag (CC-4239) and the PHP 8.1 removal (CC-4228) — the full set of merged changes for the release. * [CC-4078] Add CC-4256 Keypair boolean-parsing fix to 4.1.0 changelog Document the merged fix (#251): Keypair boolean flags sent as strings (validateBasket, cof) were coerced so "false" became true; now parsed correctly. CC-4255 (payment-type duplication, #250) will be added once merged. * [CC-4078] Prepare 4.1.0 release: bump SDK version and complete changelog Bump Unzer::SDK_VERSION to 4.1.0 and stage the remaining 4.1.0 changelog entries: deprecate Sofort (CC-4344, #252) and the Keypair plain-fetch payment-type de-duplication fix (CC-4255, #250). Those two feature PRs must merge before this release-preparation PR. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ponses array_values() rejects a stdClass, so a payment-type list that arrives with non-sequential keys (decoded as a JSON object, e.g. after an upstream array_filter) crashed fetchKeypair() with a TypeError on both the plain and detailed endpoints. Cast to array first to restore the tolerant behaviour the previous foreach had, keeping the de-duplication fix intact. Addresses QA finding on PR #250 and preserves the "detailed behaviour unchanged" AC. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ryouzanpaku
enabled auto-merge (squash)
November 24, 2026 13:09
sixer1182
approved these changes
Nov 24, 2026
sixer1182
left a comment
Member
There was a problem hiding this comment.
Approved. Reviewed against CC-4255 (PHP SDK: plain fetchKeypair() lists every payment type twice). Unit suite is green locally (799 tests, 2925 assertions) and CI is green.
Verified
- Plain keypair:
getPaymentTypes(),getAvailablePaymentTypes(),expose()andjsonSerialize()return the list exactly once, in API order. Duplicates sent by the API itself are kept as sent. - Handling a response again replaces the list instead of appending (on
mainthe list grows with every call). - Detailed keypair behaviour is unchanged. Empty lists work, and a later response without a list key keeps the previous list.
- The object-shaped list case found in QA (
{"0":"card","2":"paypal"}, plain and detailed) is fixed by the array cast and covered by tests. The merge conflict inKeypairTest.phpis resolved.
Notes (not blocking)
- A
nullpayment type list still throws aTypeErrorfrom the setter. This already happens onmain. Please make sure it is tracked in its own ticket. - A scalar string instead of a list also throws a
TypeError, also onmain. Unlikely in practice. - The follow-up in php-sdk-test-automation (remove the
skipgroup frompaymentTypesInModelMatchRawResponseTest) can only be done after the release.
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.
Summary
For the plain keypair endpoint,
availablePaymentTypesis an array of strings.AbstractUnzerResource::updateValues()does not skip string arrays, so it already populates$paymentTypesvia the setter — thenKeypair::handleResponse()appended the same list again, doubling every entry (22 → 44). The detailed endpoint is unaffected (its items are objects, whichupdateValues()skips).Pre-existing bug (not a CC-4151 regression). Note: CC-3759 made the property
protected, which is what first surfaced the duplication inexpose()/jsonSerialize()too.Fix:
handleResponse()now replaces the list instead of appending, which also makes repeated handling idempotent.Tests
handleResponseassertion fromassertArrayContains(passed on a duplicated list) toassertSame.plainKeypairPaymentTypesAreNotDuplicated: dedup + idempotency +expose()/jsonSerialize().php-cs-fixerclean.Scope
Independent of CC-4256 (string→boolean parsing), which is a separate PR. No merge-order dependency; both branch off
main.Follow-up (separate repo)
Remove the
skipgroup frompaymentTypesInModelMatchRawResponseTestin php-sdk-test-automation once released.