obsługa przekierowania płatności

This commit is contained in:
2025-06-10 19:54:25 +02:00
parent 8656ececf1
commit bacfd529aa
3 changed files with 31 additions and 51 deletions

View File

@@ -42,7 +42,7 @@ public class OrderController {
} }
@PostMapping("/token") @PostMapping("/token")
public ResponseEntity<?> fetchToken(HttpServletRequest request,@RequestParam Long orderId) { public ResponseEntity<?> fetchToken(@RequestParam Long orderId) {
Order order = orderService.getOrderById(orderId); Order order = orderService.getOrderById(orderId);
Client client = order.getClient(); Client client = order.getClient();
OAuthPaymentResponseDTO authPaymentDTO = paymentService.getOAuthToken(); OAuthPaymentResponseDTO authPaymentDTO = paymentService.getOAuthToken();
@@ -51,8 +51,15 @@ public class OrderController {
String paymentDescription = order.getOrderType() == Enums.OrderType.ACTIVATION ? "Aktywacja ogłoszenia" : "Podbicie ogłoszenia"; String paymentDescription = order.getOrderType() == Enums.OrderType.ACTIVATION ? "Aktywacja ogłoszenia" : "Podbicie ogłoszenia";
paymentDescription += order.getNotice().getTitle(); paymentDescription += order.getNotice().getTitle();
TransactionPaymentRequestDTO.Callbacks callbacks = new TransactionPaymentRequestDTO.Callbacks();
TransactionPaymentRequestDTO.PayerUrls payerUrls = new TransactionPaymentRequestDTO.PayerUrls();
payerUrls.setSuccess("com.hamx.artisanconnect://dashboard/userNotices");
payerUrls.setError("com.hamx.artisanconnect://dashboard/userNotices");
callbacks.setPayerUrls(payerUrls);
TransactionPaymentRequestDTO paymentRequest = new TransactionPaymentRequestDTO( TransactionPaymentRequestDTO paymentRequest = new TransactionPaymentRequestDTO(
order.getAmount(), paymentDescription, payer); order.getAmount(), paymentDescription, payer, callbacks);
String response = paymentService.createTransaction(order, authPaymentDTO.getAccess_token(), paymentRequest); String response = paymentService.createTransaction(order, authPaymentDTO.getAccess_token(), paymentRequest);

View File

@@ -1,8 +1,12 @@
package _11.asktpk.artisanconnectbackend.dto; package _11.asktpk.artisanconnectbackend.dto;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@Getter @Setter
public class OrderWithPaymentsDTO { public class OrderWithPaymentsDTO {
private Long orderId; private Long orderId;
private String orderType; private String orderType;
@@ -10,53 +14,4 @@ public class OrderWithPaymentsDTO {
private Double amount; private Double amount;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private List<PaymentDTO> payments; private List<PaymentDTO> payments;
// Gettery i settery
public Long getOrderId() {
return orderId;
}
public void setOrderId(Long orderId) {
this.orderId = orderId;
}
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public LocalDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}
public List<PaymentDTO> getPayments() {
return payments;
}
public void setPayments(List<PaymentDTO> payments) {
this.payments = payments;
}
} }

View File

@@ -11,6 +11,7 @@ public class TransactionPaymentRequestDTO {
private double amount; private double amount;
private String description; private String description;
private Payer payer; private Payer payer;
private Callbacks callbacks;
@Getter @Getter
@Setter @Setter
@@ -20,4 +21,21 @@ public class TransactionPaymentRequestDTO {
private String email; private String email;
private String name; private String name;
} }
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class Callbacks {
private PayerUrls payerUrls;
}
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class PayerUrls {
private String success;
private String error;
}
} }