Conversation
There was a problem hiding this comment.
Pull request overview
Adds OAuth 2.0 client-credentials token acquisition + caching to support Eupago management API calls, and introduces a new refund() operation built on that foundation. This extends the package without changing the existing API-key flow used for reference creation and status queries.
Changes:
- Introduces
Auth\TokenProviderto request/cache bearer tokens (client credentials grant). - Adds
EuPago::refund()with normalized response mapping and Pest feature coverage. - Documents new OAuth config + refunds in the README; adds
illuminate/cachedependency and config keys.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/TestCase.php | Adds test config for OAuth client credentials. |
| tests/Feature/TokenProviderTest.php | Adds feature tests for token grant behavior and caching/expiry margin. |
| tests/Feature/RefundTest.php | Adds feature tests for refund success/rejection/error behavior and bearer transport. |
| src/EuPago.php | Adds refund endpoint constant, refund() method, and response key normalization. |
| src/Auth/TokenProvider.php | Implements client-credentials token retrieval and cache scoping by env + client id. |
| README.md | Documents OAuth client credentials setup and the new refunds API. |
| config/eupago.php | Adds client_id / client_secret configuration keys. |
| composer.json | Adds illuminate/cache required dependency to support token caching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Closes #70
Adds the OAuth 2.0 foundation for Eupago's management API plus the first feature gated behind it: refunds. Ships as an additive minor (~v3.7.0) — the existing API-key transport for reference creation and status queries is untouched.
What's included
OAuth 2.0 foundation
client_id/client_secret(EUPAGO_CLIENT_ID,EUPAGO_CLIENT_SECRET), only needed for management callsAuth\TokenProvider: client credentials grant againstPOST /api/auth/token, caching the token for theexpires_inlifetime minus a 60s safety margin, scoped by environment + client idilluminate/cacheadded torequire, following the existing one-package-per-facade conventionRefunds
EuPago::refund($transactionId, $amount, ?$reason, ?$iban, ?$bic)againstPOST /api/management/v1.02/refund/{trid}, keyed by the callback'stransacaosuccess,status,refund_id); rejections (HTTP 4xx withtransactionStatus: Rejected) land in the existing error bag keyed by the rejection code, while transport/server errors throw — mirroringcreate()/status()Docs & tests
Notes