Skip to content

Commit e5f9051

Browse files
feat: Extend Swagger Coverage for controller PaymentGatewayWebHookController
1 parent a531804 commit e5f9051

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

app/Http/Controllers/PaymentGatewayWebHookController.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use App\Services\Model\IProcessPaymentService;
1717
use App\Services\Model\ISummitOrderService;
1818
use Illuminate\Http\Request as LaravelRequest;
19+
use Illuminate\Http\Response;
1920
use Illuminate\Support\Facades\Cache;
2021
use models\oauth2\IResourceServerContext;
2122
use models\summit\IPaymentConstants;
@@ -25,6 +26,8 @@
2526
use models\exceptions\EntityNotFoundException;
2627
use models\exceptions\ValidationException;
2728
use Exception;
29+
use OpenApi\Attributes as OA;
30+
2831
/**
2932
* Class PaymentGatewayWebHookController
3033
* @package App\Http\Controllers
@@ -97,6 +100,45 @@ private function getProcessPaymentService(string $application_type):?IProcessPay
97100
* @param LaravelRequest $request
98101
* @return \Illuminate\Http\JsonResponse|mixed
99102
*/
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+
),
128+
new OA\Response(
129+
response: Response::HTTP_ALREADY_REPORTED,
130+
description: "Already reported"
131+
),
132+
new OA\Response(
133+
response: Response::HTTP_BAD_REQUEST,
134+
description: "Payload error"
135+
),
136+
new OA\Response(
137+
response: Response::HTTP_PRECONDITION_FAILED,
138+
description: "Precondition failed - missing configuration or invalid data"
139+
)
140+
]
141+
)]
100142
public function genericConfirm($application_type, LaravelRequest $request){
101143
try {
102144

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

161249
try {

app/Swagger/schemas.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,22 @@ class RSVPUpdateRequestSchema_{
351351
]
352352
)]
353353
class RSVPAdminAddRequestSchema {}
354+
355+
#[OA\Schema(
356+
schema: 'PaymentGatewayWebhookRequest',
357+
type: 'object',
358+
description: 'Generic payment gateway webhook payload. The structure depends on the payment provider (e.g., Stripe, etc.)',
359+
example: [
360+
'id' => 'evt_1234567890',
361+
'cart_id' => '1234567890',
362+
'type' => 'charge.succeeded',
363+
'data' => [
364+
'object' => [
365+
'id' => 'ch_1234567890',
366+
'status' => 'succeeded'
367+
]
368+
]
369+
]
370+
)]
371+
class PaymentGatewayWebhookRequestSchema {}
372+

0 commit comments

Comments
 (0)