Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/Http/Controllers/CaptureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace App\Http\Controllers;

use App\Http\Requests\CreateCaptureRequest;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;

class CaptureController extends Controller
{
public function createForPayment(string $paymentId, Request $request): JsonResponse
public function createForPayment(string $paymentId, CreateCaptureRequest $request): JsonResponse
{
$requestId = $request->header('request-id');
$merchantId = $request->header('merchant-id');
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/RefundController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace App\Http\Controllers;

use App\Http\Requests\CreateRefundRequest;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

use Illuminate\Support\Str;

class RefundController extends Controller
{
public function create(Request $request): JsonResponse
public function create(CreateRefundRequest $request): JsonResponse
{
$requestId = $request->header('request-id');
$merchantId = $request->header('merchant-id');
Expand Down
13 changes: 8 additions & 5 deletions app/Http/Controllers/VerificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@

namespace App\Http\Controllers;

use App\Http\Requests\CreateVerificationRequest;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;

class VerificationController extends Controller
{
public function create(Request $request): JsonResponse
public function create(CreateVerificationRequest $request): JsonResponse
{
$requestId = $request->header('request-id');
$merchantId = $request->header('merchant-id');

if($request->input('currency') == 'HRK') {
if ($request->input('currency') === 'HRK') {
return response()->json([
'error' => 'Currency HRK is not supported',
'code' => 'CURRENCY_NOT_SUPPORTED'
], 500);
'responseStatus' => 'ERROR',
'responseCode' => '422',
'responseMessage' => 'Currency HRK is not supported',
'errors' => ['currency' => ['Currency HRK is not supported']]
], 422);
}

// Mock verification creation response
Expand Down
1 change: 0 additions & 1 deletion app/Http/Middleware/SecureHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public function handle(Request $request, Closure $next): Response
$response->headers->set('X-Frame-Options', 'deny');
$response->headers->set('Content-Security-Policy', "default-src 'self'; frame-ancestors 'none'");
$response->headers->set('X-Content-Type-Options', 'nosniff');
$response->headers->set('Allow', 'GET, POST');
$response->headers->set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload');

return $response;
Expand Down
19 changes: 17 additions & 2 deletions app/Http/Requests/CreateCaptureRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CreateCaptureRequest extends FormRequest
*/
public function authorize(): bool
{
return false;
return $this->hasHeader('merchant-id') && $this->hasHeader('request-id');
}

/**
Expand All @@ -22,7 +22,22 @@ public function authorize(): bool
public function rules(): array
{
return [
//
'amount' => 'required|integer|min:1',
'currency' => 'required|string|size:3',
'finalCapture' => 'boolean',
];
}

/**
* Get custom messages for validator errors.
*/
public function messages(): array
{
return [
'amount.required' => 'Capture amount is required',
'amount.integer' => 'Capture amount must be an integer in cents',
'currency.required' => 'Currency code is required',
'currency.size' => 'Currency code must be exactly 3 characters',
];
}
}
21 changes: 19 additions & 2 deletions app/Http/Requests/CreateRefundRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CreateRefundRequest extends FormRequest
*/
public function authorize(): bool
{
return false;
return $this->hasHeader('merchant-id') && $this->hasHeader('request-id');
}

/**
Expand All @@ -22,7 +22,24 @@ public function authorize(): bool
public function rules(): array
{
return [
//
'amount' => 'required|integer|min:1',
'currency' => 'required|string|size:3',
'parentTransactionId' => 'required|string|max:64',
'refundType' => 'string|in:REFERENCED,STANDALONE',
];
}

/**
* Get custom messages for validator errors.
*/
public function messages(): array
{
return [
'amount.required' => 'Refund amount is required',
'amount.integer' => 'Refund amount must be an integer in cents',
'currency.required' => 'Currency code is required',
'currency.size' => 'Currency code must be exactly 3 characters',
'parentTransactionId.required' => 'Parent transaction ID is required',
];
}
}
24 changes: 22 additions & 2 deletions app/Http/Requests/CreateVerificationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CreateVerificationRequest extends FormRequest
*/
public function authorize(): bool
{
return false;
return $this->hasHeader('merchant-id') && $this->hasHeader('request-id');
}

/**
Expand All @@ -22,7 +22,27 @@ public function authorize(): bool
public function rules(): array
{
return [
//
'currency' => 'required|string|size:3',
'paymentMethodType' => 'required|array',
'paymentMethodType.card.accountNumber' => 'required_with:paymentMethodType.card|string|min:13|max:19',
'paymentMethodType.card.expiry.month' => 'required_with:paymentMethodType.card|string|size:2',
'paymentMethodType.card.expiry.year' => 'required_with:paymentMethodType.card|string|size:4',
'paymentMethodType.card.cvv' => 'string|min:3|max:4',
];
}

/**
* Get custom messages for validator errors.
*/
public function messages(): array
{
return [
'currency.required' => 'Currency code is required',
'currency.size' => 'Currency code must be exactly 3 characters',
'paymentMethodType.required' => 'Payment method type is required',
'paymentMethodType.card.accountNumber.required_with' => 'Card number is required for card verifications',
'paymentMethodType.card.expiry.month.required_with' => 'Card expiry month is required',
'paymentMethodType.card.expiry.year.required_with' => 'Card expiry year is required',
];
}
}