Open
Conversation
- Fix authorize()=false in CreateCaptureRequest, CreateRefundRequest, CreateVerificationRequest (was blocking all requests unconditionally) - Add input validation rules to all three FormRequest classes - Wire FormRequests into CaptureController, RefundController, and VerificationController (were using unvalidated plain Request) - Fix VerificationController: return 422 instead of 500 for unsupported currency; align error envelope with API standard - Remove incorrect static Allow: GET, POST header from SecureHeaders middleware (PATCH and other verbs are also valid in this API)
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
Conservative structural improvements across security, input validation, and REST design. No business logic, database schemas, or external interfaces were altered.
Changed Files
🔒 Security
app/Http/Requests/CreateCaptureRequest.phpauthorize()changed fromreturn falseto checkingmerchant-id/request-idheadersauthorize()returningfalseby default. Left as-is, this silently blocks every capture creation request with a 403.app/Http/Requests/CreateRefundRequest.phpapp/Http/Requests/CreateVerificationRequest.php✅ Code Quality — Missing Input Validation
app/Http/Requests/CreateCaptureRequest.phpamount(required integer ≥ 1),currency(required, 3-char ISO code),finalCapture(boolean)app/Http/Requests/CreateRefundRequest.phpamount,currency,parentTransactionId(required),refundType(enum)app/Http/Requests/CreateVerificationRequest.phpcurrency,paymentMethodType(required array), nested card fieldsapp/Http/Controllers/CaptureController.phpcreateForPayment()parameter changed fromRequesttoCreateCaptureRequestRequestbypassed all validation and authorization.app/Http/Controllers/RefundController.phpcreate()parameter changed fromRequesttoCreateRefundRequestCreateRefundRequestexisted but was unused.app/Http/Controllers/VerificationController.phpcreate()parameter changed fromRequesttoCreateVerificationRequestCreateVerificationRequestexisted but was unused.🌐 REST Design
app/Http/Controllers/VerificationController.phpresponseStatus/responseCode/responseMessage/errorsenvelopeapp/Http/Middleware/SecureHeaders.phpAllow: GET, POSTresponse headerPATCH(update payment) and other verbs. A fixedAllowheader on every response is misleading to clients and API gateways.Verification
tests/TestCase.phpbase class with no test methods).php -l(syntax check) — no errors detected.