This repository was archived by the owner on Nov 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Merged
Dev #9
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
09ad0c2
Update security configuration
mehara-rothila 32d6653
Update invoice and payment controllers
mehara-rothila fe071c8
Disable hardcoded invoice data seeding
mehara-rothila 2c2518b
Disable method-level security for debugging
mehara-rothila 992cdc6
Fix payment initiation DTO field name
mehara-rothila 29844ed
Add comprehensive invoice response fields
mehara-rothila 4d7f73f
Implement PayHere payment gateway integration
mehara-rothila fb2b202
Remove hardcoded PayHere credentials from config
mehara-rothila 52cf44c
Update PayHere payment gateway configuration to use environment varia…
DinithEdirisinghe d77ee78
Add part-payment tracking fields to Invoice entity
mehara-rothila f2d7dfc
Add ONLINE payment method for gateway integration
mehara-rothila 26f618d
Add requiresDeposit flag to invoice creation DTO
mehara-rothila 672e587
Extend invoice response with part-payment metadata
mehara-rothila 43ab5ae
Implement part-payment calculation and tracking logic
mehara-rothila a427c31
Fix PayHere hash generation with Base64 merchant secret decoding
mehara-rothila ec40c7f
Configure PayHere sandbox credentials and endpoints
mehara-rothila bbbfe26
Add RestTemplate configuration for HTTP client
mehara-rothila 47e0c87
Create notification request DTO for payment events
mehara-rothila 01eb770
Implement notification client for payment alerts
mehara-rothila 3eb97a6
Restrict build trigger to specific branches for pull requests
RandithaK 01bcdc0
Merge pull request #8 from TechTorque-2025/randitha-superbranch
RandithaK dfff49e
Merge branch 'main' into dev
RandithaK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
14 changes: 14 additions & 0 deletions
14
payment-service/src/main/java/com/techtorque/payment_service/config/RestTemplateConfig.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.techtorque.payment_service.config; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.client.RestTemplate; | ||
|
|
||
| @Configuration | ||
| public class RestTemplateConfig { | ||
|
|
||
| @Bean | ||
| public RestTemplate restTemplate() { | ||
| return new RestTemplate(); | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,8 @@ | |
|
|
||
| @Configuration | ||
| @EnableWebSecurity | ||
| @EnableMethodSecurity(prePostEnabled = true) | ||
| // TEMPORARILY DISABLED FOR DEBUGGING - method-level security was blocking all requests | ||
| // @EnableMethodSecurity(prePostEnabled = true) | ||
| public class SecurityConfig { | ||
|
|
||
| // A more comprehensive whitelist for Swagger/OpenAPI, based on the auth-service config. | ||
|
|
@@ -32,22 +33,18 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | |
|
|
||
| // Set session management to STATELESS | ||
| .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
|
|
||
| // Explicitly disable form login and HTTP Basic authentication | ||
| .formLogin(formLogin -> formLogin.disable()) | ||
| .httpBasic(httpBasic -> httpBasic.disable()) | ||
| // Set up authorization rules | ||
|
|
||
| // TEMPORARILY DISABLE ALL SECURITY FOR DEBUGGING | ||
| .authorizeHttpRequests(authz -> authz | ||
| // Permit all requests to the Swagger UI and API docs paths | ||
| .requestMatchers(SWAGGER_WHITELIST).permitAll() | ||
|
|
||
| // All other requests must be authenticated | ||
| .anyRequest().authenticated() | ||
| ) | ||
| .anyRequest().permitAll() | ||
| ); | ||
|
Comment on lines
+41
to
+44
|
||
|
|
||
| // Add our custom filter to read headers from the Gateway | ||
| .addFilterBefore(new GatewayHeaderFilter(), UsernamePasswordAuthenticationFilter.class); | ||
| // .addFilterBefore(new GatewayHeaderFilter(), UsernamePasswordAuthenticationFilter.class); | ||
|
Comment on lines
46
to
+47
|
||
|
|
||
| return http.build(); | ||
| } | ||
|
|
||
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
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
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
19 changes: 19 additions & 0 deletions
19
...ce/src/main/java/com/techtorque/payment_service/dto/notification/NotificationRequest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.techtorque.payment_service.dto.notification; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Data | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class NotificationRequest { | ||
| private String userId; | ||
| private String type; // INFO, WARNING, ERROR, SUCCESS | ||
| private String message; | ||
| private String details; | ||
| private String relatedEntityId; | ||
| private String relatedEntityType; | ||
| } |
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
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
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
2 changes: 1 addition & 1 deletion
2
payment-service/src/main/java/com/techtorque/payment_service/entity/PaymentMethod.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| package com.techtorque.payment_service.entity; | ||
| public enum PaymentMethod { CARD, CASH, BANK_TRANSFER } | ||
| public enum PaymentMethod { CARD, CASH, BANK_TRANSFER, ONLINE } |
89 changes: 89 additions & 0 deletions
89
payment-service/src/main/java/com/techtorque/payment_service/service/NotificationClient.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| package com.techtorque.payment_service.service; | ||
|
|
||
| import com.techtorque.payment_service.dto.notification.NotificationRequest; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.http.HttpEntity; | ||
| import org.springframework.http.HttpHeaders; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.web.client.RestTemplate; | ||
|
|
||
| /** | ||
| * Client service for sending notifications to Notification Service | ||
| * Handles payment-related notifications (invoice created, payment due, payment received) | ||
| */ | ||
| @Service | ||
| @Slf4j | ||
| public class NotificationClient { | ||
|
|
||
| private final RestTemplate restTemplate; | ||
| private final String notificationServiceUrl; | ||
|
|
||
| public NotificationClient(RestTemplate restTemplate, | ||
| @Value("${notification.service.url:http://localhost:8088}") String notificationServiceUrl) { | ||
| this.restTemplate = restTemplate; | ||
| this.notificationServiceUrl = notificationServiceUrl; | ||
| } | ||
|
|
||
| /** | ||
| * Send notification to user asynchronously | ||
| * Non-blocking - failures won't affect payment operations | ||
| */ | ||
| public void sendNotification(NotificationRequest request) { | ||
| try { | ||
| log.info("Sending payment notification to user: {} - {}", request.getUserId(), request.getMessage()); | ||
|
|
||
| HttpHeaders headers = new HttpHeaders(); | ||
| headers.setContentType(MediaType.APPLICATION_JSON); | ||
|
|
||
| HttpEntity<NotificationRequest> entity = new HttpEntity<>(request, headers); | ||
|
|
||
| restTemplate.postForEntity( | ||
| notificationServiceUrl + "/api/v1/notifications/create", | ||
| entity, | ||
| Void.class | ||
| ); | ||
|
|
||
| log.debug("Payment notification sent successfully"); | ||
|
|
||
| } catch (Exception e) { | ||
| // Log error but don't throw - notification failure shouldn't break payment operations | ||
| log.error("Failed to send payment notification to user {}: {}", request.getUserId(), e.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Helper method to send invoice notification | ||
| */ | ||
| public void sendInvoiceNotification(String userId, String type, String message, | ||
| String details, String invoiceId) { | ||
| NotificationRequest request = NotificationRequest.builder() | ||
| .userId(userId) | ||
| .type(type) | ||
| .message(message) | ||
| .details(details) | ||
| .relatedEntityId(invoiceId) | ||
| .relatedEntityType("INVOICE") | ||
| .build(); | ||
|
|
||
| sendNotification(request); | ||
| } | ||
|
|
||
| /** | ||
| * Helper method to send payment notification | ||
| */ | ||
| public void sendPaymentNotification(String userId, String type, String message, | ||
| String details, String paymentId) { | ||
| NotificationRequest request = NotificationRequest.builder() | ||
| .userId(userId) | ||
| .type(type) | ||
| .message(message) | ||
| .details(details) | ||
| .relatedEntityId(paymentId) | ||
| .relatedEntityType("PAYMENT") | ||
| .build(); | ||
|
|
||
| sendNotification(request); | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method-level security is disabled. This removes authorization checks from all @PreAuthorize annotations. This should not be merged to production branches. Consider fixing the underlying issue causing requests to be blocked rather than disabling security.