diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2PaymentGatewayProfileApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2PaymentGatewayProfileApiController.php index 22056d93e..940301f87 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2PaymentGatewayProfileApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2PaymentGatewayProfileApiController.php @@ -1,4 +1,7 @@ -repository = $repository; $this->summit_repository = $summit_repository; @@ -67,6 +74,293 @@ public function __construct use DeleteSummitChildElement; + // OpenAPI Documentation + + #[OA\Get( + path: '/api/v1/summits/{id}/payment-gateway-profiles', + summary: 'Get all payment gateway profiles for a summit', + operationId: 'getAllPaymentGatewayProfiles', + description: 'Retrieves a paginated list of payment gateway profiles configured for a specific summit. Payment profiles manage payment processing for registrations and bookable rooms.', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::SummitRegistrationAdmins, + ] + ], + security: [ + [ + 'summit_payment_gateway_oauth2' => [ + SummitScopes::ReadAllSummitData, + SummitScopes::ReadPaymentProfiles + ] + ] + ], + tags: ['Payment Gateway Profiles'], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + description: 'Summit ID', + schema: new OA\Schema(type: 'integer') + ), + new OA\Parameter( + name: 'page', + in: 'query', + required: false, + description: 'Page number for pagination', + schema: new OA\Schema(type: 'integer', example: 1) + ), + new OA\Parameter( + name: 'per_page', + in: 'query', + required: false, + description: 'Items per page', + schema: new OA\Schema(type: 'integer', example: 10, maximum: 100) + ), + new OA\Parameter( + name: 'filter[]', + in: 'query', + required: false, + description: 'Filter expressions. Format: fieldvalue. Available fields: application_type (=@, ==), active (==). Operators: == (equals), =@ (starts with)', + style: 'form', + explode: true, + schema: new OA\Schema( + type: 'array', + items: new OA\Items(type: 'string', example: 'application_type==Registration') + ) + ), + new OA\Parameter( + name: 'order', + in: 'query', + required: false, + description: 'Order by field(s). Available fields: id, application_type. Use "-" prefix for descending order.', + schema: new OA\Schema(type: 'string', example: 'id') + ), + ], + responses: [ + new OA\Response( + response: 200, + description: 'Payment gateway profiles retrieved successfully', + content: new OA\JsonContent(ref: '#/components/schemas/PaginatedPaymentGatewayProfilesResponse') + ), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"), + ] + )] + + #[OA\Get( + path: '/api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}', + summary: 'Get a payment gateway profile by ID', + operationId: 'getPaymentGatewayProfile', + description: 'Retrieves detailed information about a specific payment gateway profile.', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::SummitRegistrationAdmins, + ] + ], + security: [ + [ + 'summit_payment_gateway_oauth2' => [ + SummitScopes::ReadAllSummitData, + SummitScopes::ReadPaymentProfiles + ] + ] + ], + tags: ['Payment Gateway Profiles'], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + description: 'Summit ID', + schema: new OA\Schema(type: 'integer') + ), + new OA\Parameter( + name: 'payment_profile_id', + in: 'path', + required: true, + description: 'Payment Gateway Profile ID', + schema: new OA\Schema(type: 'integer') + ), + ], + responses: [ + new OA\Response( + response: 200, + description: 'Payment gateway profile retrieved successfully', + content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfile') + ), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"), + ] + )] + + #[OA\Post( + path: '/api/v1/summits/{id}/payment-gateway-profiles', + summary: 'Create a new payment gateway profile', + operationId: 'createPaymentGatewayProfile', + description: 'Creates a new payment gateway profile for the summit. Supports Stripe and LawPay providers.', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::SummitRegistrationAdmins, + ] + ], + security: [ + [ + 'summit_payment_gateway_oauth2' => [ + SummitScopes::WriteSummitData, + SummitScopes::WritePaymentProfiles + ] + ] + ], + tags: ['Payment Gateway Profiles'], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + description: 'Summit ID', + schema: new OA\Schema(type: 'integer') + ), + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfileCreateRequest') + ), + responses: [ + new OA\Response( + response: 201, + description: 'Payment gateway profile created successfully', + content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfile') + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"), + ] + )] + + #[OA\Put( + path: '/api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}', + summary: 'Update a payment gateway profile', + operationId: 'updatePaymentGatewayProfile', + description: 'Updates an existing payment gateway profile.', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::SummitRegistrationAdmins, + ] + ], + security: [ + [ + 'summit_payment_gateway_oauth2' => [ + SummitScopes::WriteSummitData, + SummitScopes::WritePaymentProfiles + ] + ] + ], + tags: ['Payment Gateway Profiles'], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + description: 'Summit ID', + schema: new OA\Schema(type: 'integer') + ), + new OA\Parameter( + name: 'payment_profile_id', + in: 'path', + required: true, + description: 'Payment Gateway Profile ID', + schema: new OA\Schema(type: 'integer') + ), + ], + requestBody: new OA\RequestBody( + required: true, + content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfileUpdateRequest') + ), + responses: [ + new OA\Response( + response: 200, + description: 'Payment gateway profile updated successfully', + content: new OA\JsonContent(ref: '#/components/schemas/PaymentGatewayProfile') + ), + new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"), + ] + )] + + #[OA\Delete( + path: '/api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}', + summary: 'Delete a payment gateway profile', + operationId: 'deletePaymentGatewayProfile', + description: 'Deletes an existing payment gateway profile from the summit.', + x: [ + 'required-groups' => [ + IGroup::SuperAdmins, + IGroup::Administrators, + IGroup::SummitAdministrators, + IGroup::SummitRegistrationAdmins, + ] + ], + security: [ + [ + 'summit_payment_gateway_oauth2' => [ + SummitScopes::WriteSummitData, + SummitScopes::WritePaymentProfiles + ] + ] + ], + tags: ['Payment Gateway Profiles'], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + description: 'Summit ID', + schema: new OA\Schema(type: 'integer') + ), + new OA\Parameter( + name: 'payment_profile_id', + in: 'path', + required: true, + description: 'Payment Gateway Profile ID', + schema: new OA\Schema(type: 'integer') + ), + ], + responses: [ + new OA\Response( + response: 204, + description: 'Payment gateway profile deleted successfully' + ), + new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"), + new OA\Response(response: Response::HTTP_FORBIDDEN, description: "Forbidden"), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Not Found"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"), + ] + )] + /** * @return ISummitRepository */ @@ -126,46 +420,52 @@ protected function updateChild(Summit $summit, int $child_id, array $payload): I /** * @return array */ - protected function getFilterRules():array + protected function getFilterRules(): array { return [ 'application_type' => ['=@', '=='], - 'active' => ['=='], + 'active' => ['=='], ]; } /** * @return array */ - protected function getFilterValidatorRules():array{ + protected function getFilterValidatorRules(): array + { return [ 'application_type' => 'sometimes|required|string', - 'active' => 'sometimes|required|boolean', + 'active' => 'sometimes|required|boolean', ]; } /** * @return array */ - protected function getOrderRules():array{ + protected function getOrderRules(): array + { return [ 'id', 'application_type', ]; } - protected function serializerType():string{ + protected function serializerType(): string + { return SerializerRegistry::SerializerType_Private; } - protected function addSerializerType():string{ + protected function addSerializerType(): string + { return SerializerRegistry::SerializerType_Private; } - protected function updateSerializerType():string{ + protected function updateSerializerType(): string + { return SerializerRegistry::SerializerType_Private; } - public function getChildSerializer(){ + public function getChildSerializer() + { return SerializerRegistry::SerializerType_Private; } -} \ No newline at end of file +} diff --git a/app/Swagger/Security/OAuth2CPaymentGatewayProfileAPIAuthSchema.php b/app/Swagger/Security/OAuth2CPaymentGatewayProfileAPIAuthSchema.php new file mode 100644 index 000000000..c3ee66a3a --- /dev/null +++ b/app/Swagger/Security/OAuth2CPaymentGatewayProfileAPIAuthSchema.php @@ -0,0 +1,27 @@ + 'Read all summit data', + SummitScopes::ReadPaymentProfiles => 'Read payment profiles', + SummitScopes::WriteSummitData => 'Write summit data', + SummitScopes::WritePaymentProfiles => 'Write payment profiles', + ], + ), + ], + ) +] +class OAuth2CPaymentGatewayProfileAPIAuthSchema{} diff --git a/app/Swagger/schemas.php b/app/Swagger/schemas.php index d68f81ad6..b940875b5 100644 --- a/app/Swagger/schemas.php +++ b/app/Swagger/schemas.php @@ -499,6 +499,86 @@ class PaginatedOrganizationsResponseSchema class OrganizationCreateRequestSchema { } + +#[OA\Schema( + schema: 'PaymentGatewayProfile', + type: 'object', + properties: [ + new OA\Property(property: 'id', type: 'integer', example: 1), + new OA\Property(property: 'created', type: 'integer', format: 'int64', example: 1633024800), + new OA\Property(property: 'last_edited', type: 'integer', format: 'int64', example: 1633024800), + new OA\Property(property: 'active', type: 'boolean', example: true), + new OA\Property(property: 'provider', type: 'string', enum: ['Stripe', 'LawPay'], example: 'Stripe'), + new OA\Property(property: 'application_type', type: 'string', enum: ['Registration', 'BookableRooms'], example: 'Registration'), + new OA\Property(property: 'test_mode_enabled', type: 'boolean', example: false, description: 'Only for Stripe provider'), + new OA\Property(property: 'live_publishable_key', type: 'string', example: 'pk_live_...', description: 'Only for Stripe provider'), + new OA\Property(property: 'test_publishable_key', type: 'string', example: 'pk_test_...', description: 'Only for Stripe provider'), + ] +)] +class PaymentGatewayProfileSchema +{ +} + +#[OA\Schema( + schema: 'PaginatedPaymentGatewayProfilesResponse', + allOf: [ + new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'), + new OA\Schema( + properties: [ + new OA\Property( + property: 'data', + type: 'array', + items: new OA\Items(ref: '#/components/schemas/PaymentGatewayProfile') + ) + ] + ) + ] +)] +class PaginatedPaymentGatewayProfilesResponseSchema +{ +} + +#[OA\Schema( + schema: 'PaymentGatewayProfileCreateRequest', + required: ['active', 'provider', 'application_type'], + type: 'object', + properties: [ + new OA\Property(property: 'active', type: 'boolean', example: true), + new OA\Property(property: 'provider', type: 'string', enum: ['Stripe', 'LawPay'], example: 'Stripe'), + new OA\Property(property: 'application_type', type: 'string', enum: ['Registration', 'BookableRooms'], example: 'Registration'), + new OA\Property(property: 'test_mode_enabled', type: 'boolean', example: false, description: 'Required for Stripe provider'), + new OA\Property(property: 'live_secret_key', type: 'string', example: 'sk_live_...', description: 'Optional for Stripe provider'), + new OA\Property(property: 'live_publishable_key', type: 'string', example: 'pk_live_...', description: 'Required with live_secret_key for Stripe'), + new OA\Property(property: 'test_secret_key', type: 'string', example: 'sk_test_...', description: 'Optional for Stripe provider'), + new OA\Property(property: 'test_publishable_key', type: 'string', example: 'pk_test_...', description: 'Required with test_secret_key for Stripe'), + new OA\Property(property: 'send_email_receipt', type: 'boolean', example: true, description: 'Optional for Stripe provider'), + new OA\Property(property: 'merchant_account_id', type: 'string', example: 'merchant_123', description: 'Optional for LawPay provider'), + ] +)] +class PaymentGatewayProfileCreateRequestSchema +{ +} + +#[OA\Schema( + schema: 'PaymentGatewayProfileUpdateRequest', + required: ['provider'], + type: 'object', + properties: [ + new OA\Property(property: 'active', type: 'boolean', example: true), + new OA\Property(property: 'provider', type: 'string', enum: ['Stripe', 'LawPay'], example: 'Stripe'), + new OA\Property(property: 'application_type', type: 'string', enum: ['Registration', 'BookableRooms'], example: 'Registration'), + new OA\Property(property: 'test_mode_enabled', type: 'boolean', example: false, description: 'Required for Stripe provider'), + new OA\Property(property: 'live_secret_key', type: 'string', example: 'sk_live_...', description: 'Optional for Stripe provider'), + new OA\Property(property: 'live_publishable_key', type: 'string', example: 'pk_live_...', description: 'Required with live_secret_key for Stripe'), + new OA\Property(property: 'test_secret_key', type: 'string', example: 'sk_test_...', description: 'Optional for Stripe provider'), + new OA\Property(property: 'test_publishable_key', type: 'string', example: 'pk_test_...', description: 'Required with test_secret_key for Stripe'), + new OA\Property(property: 'send_email_receipt', type: 'boolean', example: true, description: 'Optional for Stripe provider'), + new OA\Property(property: 'merchant_account_id', type: 'string', example: 'merchant_123', description: 'Optional for LawPay provider'), + ] +)] +class PaymentGatewayProfileUpdateRequestSchema +{ +} // User Stories