obsługa przekierowania płatności
This commit is contained in:
@@ -42,7 +42,7 @@ public class OrderController {
|
||||
}
|
||||
|
||||
@PostMapping("/token")
|
||||
public ResponseEntity<?> fetchToken(HttpServletRequest request,@RequestParam Long orderId) {
|
||||
public ResponseEntity<?> fetchToken(@RequestParam Long orderId) {
|
||||
Order order = orderService.getOrderById(orderId);
|
||||
Client client = order.getClient();
|
||||
OAuthPaymentResponseDTO authPaymentDTO = paymentService.getOAuthToken();
|
||||
@@ -51,8 +51,15 @@ public class OrderController {
|
||||
|
||||
String paymentDescription = order.getOrderType() == Enums.OrderType.ACTIVATION ? "Aktywacja ogłoszenia" : "Podbicie ogłoszenia";
|
||||
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(
|
||||
order.getAmount(), paymentDescription, payer);
|
||||
order.getAmount(), paymentDescription, payer, callbacks);
|
||||
|
||||
String response = paymentService.createTransaction(order, authPaymentDTO.getAccess_token(), paymentRequest);
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package _11.asktpk.artisanconnectbackend.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Getter @Setter
|
||||
public class OrderWithPaymentsDTO {
|
||||
private Long orderId;
|
||||
private String orderType;
|
||||
@@ -10,53 +14,4 @@ public class OrderWithPaymentsDTO {
|
||||
private Double amount;
|
||||
private LocalDateTime createdAt;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public class TransactionPaymentRequestDTO {
|
||||
private double amount;
|
||||
private String description;
|
||||
private Payer payer;
|
||||
private Callbacks callbacks;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -20,4 +21,21 @@ public class TransactionPaymentRequestDTO {
|
||||
private String email;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user