Compare commits
7 Commits
paymentInt
...
MailSender
| Author | SHA1 | Date | |
|---|---|---|---|
| 62a5ad1bc6 | |||
| 8ea5d84779 | |||
| a09603f8cb | |||
| 45c607060a | |||
| 0b85fed4b8 | |||
| d2163e1601 | |||
| f4c8177270 |
5
pom.xml
5
pom.xml
@@ -77,6 +77,11 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
<version>3.3.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.controller;
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.EmailDTO;
|
||||||
|
import _11.asktpk.artisanconnectbackend.service.EmailService;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/email")
|
||||||
|
public class EmailController {
|
||||||
|
private final EmailService emailService;
|
||||||
|
|
||||||
|
public EmailController(EmailService emailService) {
|
||||||
|
this.emailService = emailService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/send")
|
||||||
|
public ResponseEntity<String> sendEmail(@RequestBody EmailDTO email) {
|
||||||
|
try {
|
||||||
|
emailService.sendEmail(email);
|
||||||
|
return ResponseEntity.ok("Email wysłany pomyślnie");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(500).body("Błąd podczas wysyłania emaila");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,8 +43,10 @@ public class OrderController {
|
|||||||
paymentDescription += order.getNotice().getTitle();
|
paymentDescription += order.getNotice().getTitle();
|
||||||
TransactionPaymentRequestDTO request = new TransactionPaymentRequestDTO(
|
TransactionPaymentRequestDTO request = new TransactionPaymentRequestDTO(
|
||||||
order.getAmount(), paymentDescription, payer);
|
order.getAmount(), paymentDescription, payer);
|
||||||
|
|
||||||
String response = paymentService.createTransaction(order,authPaymentDTO.getAccess_token(), request);
|
String response = paymentService.createTransaction(order,authPaymentDTO.getAccess_token(), request);
|
||||||
System.out.println(response);
|
System.out.println(response);
|
||||||
|
System.out.println(request);
|
||||||
|
|
||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ public class WishlistController {
|
|||||||
this.noticeService = noticeService;
|
this.noticeService = noticeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/toggle")
|
@PostMapping("/toggle/{noticeId}")
|
||||||
public ResponseEntity<RequestResponseDTO> toggleWishlist(@RequestBody WishlistDTO wishlistDTO) {
|
public ResponseEntity<RequestResponseDTO> toggleWishlist(@PathVariable Long noticeId) {
|
||||||
Long noticeId = wishlistDTO.getNoticeId();
|
|
||||||
Long clientId = wishlistDTO.getClientId();
|
Long clientId = 1L;
|
||||||
NoticeDTO noticeDTO = noticeService.getNoticeById(noticeId);
|
NoticeDTO noticeDTO = noticeService.getNoticeById(noticeId);
|
||||||
if (noticeDTO == null) {
|
if (noticeDTO == null) {
|
||||||
return ResponseEntity.badRequest().body(new RequestResponseDTO("Notice not found"));
|
return ResponseEntity.badRequest().body(new RequestResponseDTO("Notice not found"));
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import jakarta.validation.constraints.Email;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class EmailDTO {
|
||||||
|
@Email(message = "Podaj poprawny adres email")
|
||||||
|
@NotBlank(message = "Adres email nie może być pusty")
|
||||||
|
private String to;
|
||||||
|
|
||||||
|
@NotBlank(message = "Temat nie może być pusty")
|
||||||
|
private String subject;
|
||||||
|
|
||||||
|
@NotBlank(message = "Treść nie może być pusta")
|
||||||
|
private String body;
|
||||||
|
}
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
package _11.asktpk.artisanconnectbackend.dto;
|
package _11.asktpk.artisanconnectbackend.dto;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.*;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
public class TransactionPaymentRequestDTO {
|
public class TransactionPaymentRequestDTO {
|
||||||
private double amount;
|
private double amount;
|
||||||
private String description;
|
private String description;
|
||||||
|
|||||||
@@ -54,6 +54,27 @@ import lombok.Setter;
|
|||||||
private double amountPaid;
|
private double amountPaid;
|
||||||
private DateInfo date;
|
private DateInfo date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "YourClassName{" +
|
||||||
|
"result='" + result + '\'' +
|
||||||
|
", requestId='" + requestId + '\'' +
|
||||||
|
", transactionId='" + transactionId + '\'' +
|
||||||
|
", title='" + title + '\'' +
|
||||||
|
", posId='" + posId + '\'' +
|
||||||
|
", status='" + status + '\'' +
|
||||||
|
", date=" + date +
|
||||||
|
", amount=" + amount +
|
||||||
|
", currency='" + currency + '\'' +
|
||||||
|
", description='" + description + '\'' +
|
||||||
|
", hiddenDescription='" + hiddenDescription + '\'' +
|
||||||
|
", payer=" + payer +
|
||||||
|
", payments=" + payments +
|
||||||
|
", transactionPaymentUrl='" + transactionPaymentUrl + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package _11.asktpk.artisanconnectbackend.service;
|
||||||
|
|
||||||
|
import _11.asktpk.artisanconnectbackend.dto.EmailDTO;
|
||||||
|
import org.springframework.mail.SimpleMailMessage;
|
||||||
|
import org.springframework.mail.javamail.JavaMailSender;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class EmailService {
|
||||||
|
private final JavaMailSender mailSender;
|
||||||
|
|
||||||
|
public EmailService(JavaMailSender mailSender) {
|
||||||
|
this.mailSender = mailSender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendEmail(EmailDTO email) {
|
||||||
|
SimpleMailMessage message = new SimpleMailMessage();
|
||||||
|
message.setTo(email.getTo());
|
||||||
|
message.setSubject(email.getSubject());
|
||||||
|
message.setText(email.getBody());
|
||||||
|
message.setFrom("patryk.kania001@gmail.com");
|
||||||
|
mailSender.send(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,10 +69,12 @@ public class PaymentService {
|
|||||||
|
|
||||||
payment.setStatus(Enums.PaymentStatus.PENDING);
|
payment.setStatus(Enums.PaymentStatus.PENDING);
|
||||||
|
|
||||||
payment.setTransactionId(response.getTransactionId());
|
payment.setTransactionId(response.getTitle());
|
||||||
payment.setTransactionPaymentUrl(response.getTransactionPaymentUrl());
|
payment.setTransactionPaymentUrl(response.getTransactionPaymentUrl());
|
||||||
paymentRepository.save(payment);
|
paymentRepository.save(payment);
|
||||||
|
|
||||||
|
System.out.println(response);
|
||||||
|
|
||||||
return response.getTransactionPaymentUrl();
|
return response.getTransactionPaymentUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ file.upload-dir=/Users/andsol/Desktop/uploads
|
|||||||
spring.servlet.multipart.max-file-size=10MB
|
spring.servlet.multipart.max-file-size=10MB
|
||||||
spring.servlet.multipart.max-request-size=10MB
|
spring.servlet.multipart.max-request-size=10MB
|
||||||
|
|
||||||
|
spring.mail.host=smtp.gmail.com
|
||||||
|
spring.mail.port=587
|
||||||
|
spring.mail.username=patryk.kania001@gmail.com
|
||||||
|
spring.mail.password=pmyd ylwg mbsn hcpp
|
||||||
|
spring.mail.properties.mail.smtp.auth=true
|
||||||
|
spring.mail.properties.mail.smtp.starttls.enable=true
|
||||||
|
|
||||||
tpay.clientId = 01JQKC048X62ST9V59HNRSXD92-01JQKC2CQHPYXQFSFX8BKC24BX
|
tpay.clientId = 01JQKC048X62ST9V59HNRSXD92-01JQKC2CQHPYXQFSFX8BKC24BX
|
||||||
tpay.clientSecret = 44898642be53381cdcc47f3e44bf5a15e592f5d270fc3a6cf6fb81a8b8ebffb9
|
tpay.clientSecret = 44898642be53381cdcc47f3e44bf5a15e592f5d270fc3a6cf6fb81a8b8ebffb9
|
||||||
tpay.authUrl = https://openapi.sandbox.tpay.com/oauth/auth
|
tpay.authUrl = https://openapi.sandbox.tpay.com/oauth/auth
|
||||||
|
|||||||
Reference in New Issue
Block a user