Skip to content

Commit a262fad

Browse files
andrestejerina97matiasperrone
authored andcommitted
feat: Extend Swagger Coverage for controller PaymentGatewayWebHookController
1 parent 6fc66f5 commit a262fad

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

app/Http/Controllers/PaymentGatewayWebHookController.php

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use App\Services\Model\IProcessPaymentService;
1717
use App\Services\Model\ISummitOrderService;
1818
use Illuminate\Http\Request as LaravelRequest;
19+
use Illuminate\Http\Response;
20+
use Illuminate\Support\Facades\Cache;
1921
use models\oauth2\IResourceServerContext;
2022
use models\summit\IPaymentConstants;
2123
use models\summit\ISummitRepository;
@@ -24,6 +26,8 @@
2426
use models\exceptions\EntityNotFoundException;
2527
use models\exceptions\ValidationException;
2628
use Exception;
29+
use OpenApi\Attributes as OA;
30+
2731
/**
2832
* Class PaymentGatewayWebHookController
2933
* @package App\Http\Controllers
@@ -96,6 +100,46 @@ private function getProcessPaymentService(string $application_type):?IProcessPay
96100
* @param LaravelRequest $request
97101
* @return \Illuminate\Http\JsonResponse|mixed
98102
*/
103+
#[OA\Post(
104+
path: "/api/public/v1/summits/all/payments/{application_name}/confirm",
105+
summary: "Generic payment gateway webhook confirmation",
106+
description: "Handles payment gateway webhook callbacks for a given application type.",
107+
operationId: "genericConfirm",
108+
tags: ["PaymentGatewayHook"],
109+
security: [],
110+
parameters: [
111+
new OA\Parameter(
112+
name: "application_name",
113+
in: "path",
114+
required: true,
115+
description: "Application name (e.g. Show admin)",
116+
schema: new OA\Schema(type: "string")
117+
)
118+
],
119+
requestBody: new OA\RequestBody(
120+
required: false,
121+
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayWebhookRequest')
122+
),
123+
responses: [
124+
new OA\Response(
125+
response: Response::HTTP_OK,
126+
description: "Payment processed successfully",
127+
content: new OA\JsonContent(ref: '#/components/schemas/PaymentProcessingResponse')
128+
),
129+
new OA\Response(
130+
response: Response::HTTP_ALREADY_REPORTED,
131+
description: "Already reported"
132+
),
133+
new OA\Response(
134+
response: Response::HTTP_BAD_REQUEST,
135+
description: "Payload error"
136+
),
137+
new OA\Response(
138+
response: Response::HTTP_PRECONDITION_FAILED,
139+
description: "Precondition failed - missing configuration or invalid data"
140+
)
141+
]
142+
)]
99143
public function genericConfirm($application_type, LaravelRequest $request){
100144
try {
101145

@@ -150,6 +194,53 @@ public function genericConfirm($application_type, LaravelRequest $request){
150194
* @param LaravelRequest $request
151195
* @return \Illuminate\Http\JsonResponse|mixed
152196
*/
197+
#[OA\Post(
198+
path: "/api/public/v1/summits/{summit_id}/payments/{application_name}/confirm",
199+
summary: "Summit payment gateway webhook confirmation",
200+
description: "Handles payment gateway webhook callbacks for a given summit and application type.",
201+
operationId: "confirm",
202+
tags: ["PaymentGatewayHook"],
203+
security: [],
204+
parameters: [
205+
new OA\Parameter(
206+
name: "summit_id",
207+
in: "path",
208+
required: true,
209+
description: "Summit identifier",
210+
schema: new OA\Schema(type: "integer")
211+
),
212+
new OA\Parameter(
213+
name: "application_name",
214+
in: "path",
215+
required: true,
216+
description: "Application Name (e.g ShowAdmin)",
217+
schema: new OA\Schema(type: "string")
218+
)
219+
],
220+
requestBody: new OA\RequestBody(
221+
required: false,
222+
content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayWebhookRequest')
223+
),
224+
responses: [
225+
new OA\Response(
226+
response: Response::HTTP_OK,
227+
description: "Payment processed successfully",
228+
content: new OA\JsonContent(ref: '#/components/schemas/PaymentProcessingResponse')
229+
),
230+
new OA\Response(
231+
response: Response::HTTP_ALREADY_REPORTED,
232+
description: "Already reported"
233+
),
234+
new OA\Response(
235+
response: Response::HTTP_BAD_REQUEST,
236+
description: "Payload error"
237+
),
238+
new OA\Response(
239+
response: Response::HTTP_PRECONDITION_FAILED,
240+
description: "Precondition failed - missing configuration or invalid data"
241+
)
242+
]
243+
)]
153244
public function confirm($summit_id, $application_type, LaravelRequest $request){
154245

155246
try {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
namespace App\Swagger\schemas;
3+
4+
use OpenApi\Attributes as OA;
5+
6+
#[OA\Schema(
7+
schema: 'PaymentGatewayWebhookRequest',
8+
type: 'object',
9+
description: 'Generic payment gateway webhook payload. The structure depends on the payment provider (e.g., Stripe, etc.)',
10+
properties: [
11+
new OA\Property(
12+
property: 'id',
13+
type: 'string',
14+
example: 'evt_1234567890',
15+
description: 'Webhook event ID from payment provider'
16+
),
17+
new OA\Property(
18+
property: 'type',
19+
type: 'string',
20+
example: 'charge.succeeded',
21+
description: 'Event type from payment provider'
22+
),
23+
new OA\Property(
24+
property: 'cart_id',
25+
type: 'string',
26+
example: '1234567890',
27+
description: 'Cart or order identifier'
28+
),
29+
new OA\Property(
30+
property: 'data',
31+
type: 'object',
32+
description: 'Event data payload from payment provider'
33+
),
34+
]
35+
)]
36+
class PaymentGatewayWebhookRequestSchema {}
37+
38+
#[OA\Schema(
39+
schema: 'PaymentProcessingResponse',
40+
type: 'string',
41+
example: 'ok',
42+
description: 'Confirmation message that payment was processed successfully'
43+
)]
44+
class PaymentProcessingResponseSchema {}

0 commit comments

Comments
 (0)