Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The changes align with the documented issue, are narrowly scoped, and are covered by targeted regression tests for the reported failure modes.
Review effort: Lite
Findings: None
What changed in this PR
This PR addresses several correctness issues in the EuPago payment helpers that were surfaced in issue #96, focusing on compatibility with strict Eloquent models, safe reuse of payment instances, and accepting broader input types for identifiers and dates.
Changes:
- Persist only model-fillable reference attributes (avoids strict-model failures when API responses include non-column keys).
- Reset the internal error bag at the start of
create(),status(), andrefund()(and Credit Cardcreate()) so reused instances report only the latest operation’s errors. - Broaden accepted types:
MBWayidentifiers now acceptint|string, MB reference dates now acceptDateTimeInterface, andrefund()URL-encodes the transaction id in the request path.
| File | Description |
|---|---|
| tests/Feature/TraitHelpersTest.php | Adds regression tests for strict models, immutable dates, and string MB Way ids. |
| tests/Feature/RefundTest.php | Adds tests for URL-encoding refund transaction ids and clearing errors on reused instances. |
| src/Traits/HasMultibancoReferences.php | Accepts DateTimeInterface for MB reference dates to support immutable dates. |
| src/Traits/HasMbWayReferences.php | Accepts `int |
| src/Traits/CreatesEuPagoReferences.php | Persists only fillable attributes when creating related reference models. |
| src/MBWay/MBWay.php | Updates MB Way identifier typing to `int |
| src/MB/MB.php | Accepts DateTimeInterface and formats dates for requests. |
| src/EuPago.php | Clears errors at operation start and URL-encodes refund transaction id in the request path. |
| src/CreditCard/CreditCard.php | Clears errors at Credit Card create() start for reused instances. |
| docs/mbway.md | Updates docs to reflect identifier is no longer limited to int. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Description
Fixes the problems the package review found in the payment classes and traits. Every change is backward compatible.
success,response, andstatusfor Credit Card), which a model withModel::shouldBeStrict()orpreventSilentlyDiscardingAttributes()refused after Eupago had already created the payment.create(),status()andrefund()(and Credit Card'screate()) start with an empty error bag, sohasErrors()on a reused instance reports only the latest operation instead of earlier failures.MBWayandcreateMbwayReference()takeint|string $id, so string order ids work and zero-padded ids reach Eupago unchanged. Integer callers, including understrict_types, keep working.MBandcreateMbReference()takeDateTimeInterfacedates, soCarbonImmutableis accepted.refund()URL-encodes the transaction id in the request path.Each fix has a test that fails without it.
Fixes
This fixes #96.