mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-02-09 12:29:13 +00:00
falta vista de pagos
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
package com.imprimelibros.erp.payments.model;
|
||||
|
||||
public enum CaptureMethod { AUTOMATIC, MANUAL }
|
||||
|
||||
public enum CaptureMethod { automatic, manual }
|
||||
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
package com.imprimelibros.erp.payments.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(
|
||||
name = "idempotency_keys",
|
||||
uniqueConstraints = {
|
||||
@UniqueConstraint(name = "uq_idem_scope_key", columnNames = {"scope","idem_key"})
|
||||
},
|
||||
indexes = {
|
||||
@Index(name = "idx_idem_resource", columnList = "resource_id")
|
||||
}
|
||||
)
|
||||
public class IdempotencyKey {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "scope", nullable = false, length = 16)
|
||||
private IdempotencyScope scope;
|
||||
|
||||
@Column(name = "idem_key", nullable = false, length = 128)
|
||||
private String idemKey;
|
||||
|
||||
@Column(name = "resource_id")
|
||||
private Long resourceId;
|
||||
|
||||
@Column(name = "response_cache", columnDefinition = "json")
|
||||
private String responseCache;
|
||||
|
||||
@Column(name = "created_at", nullable = false,
|
||||
columnDefinition = "datetime default current_timestamp")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "expires_at")
|
||||
private LocalDateTime expiresAt;
|
||||
|
||||
public IdempotencyKey() {}
|
||||
|
||||
// Getters & Setters
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public IdempotencyScope getScope() { return scope; }
|
||||
public void setScope(IdempotencyScope scope) { this.scope = scope; }
|
||||
|
||||
public String getIdemKey() { return idemKey; }
|
||||
public void setIdemKey(String idemKey) { this.idemKey = idemKey; }
|
||||
|
||||
public Long getResourceId() { return resourceId; }
|
||||
public void setResourceId(Long resourceId) { this.resourceId = resourceId; }
|
||||
|
||||
public String getResponseCache() { return responseCache; }
|
||||
public void setResponseCache(String responseCache) { this.responseCache = responseCache; }
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
public LocalDateTime getExpiresAt() { return expiresAt; }
|
||||
public void setExpiresAt(LocalDateTime expiresAt) { this.expiresAt = expiresAt; }
|
||||
}
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
package com.imprimelibros.erp.payments.model;
|
||||
|
||||
public enum IdempotencyScope { PAYMENT, REFUND, WEBHOOK }
|
||||
@ -17,10 +17,6 @@ public class Payment {
|
||||
@Column(name = "user_id")
|
||||
private Long userId;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "payment_method_id")
|
||||
private PaymentMethod paymentMethod;
|
||||
|
||||
@Column(nullable = false, length = 3)
|
||||
private String currency;
|
||||
|
||||
@ -35,11 +31,11 @@ public class Payment {
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false, length = 32)
|
||||
private PaymentStatus status = PaymentStatus.REQUIRES_PAYMENT_METHOD;
|
||||
private PaymentStatus status = PaymentStatus.requires_payment_method;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "capture_method", nullable = false, length = 16)
|
||||
private CaptureMethod captureMethod = CaptureMethod.AUTOMATIC;
|
||||
private CaptureMethod captureMethod = CaptureMethod.automatic;
|
||||
|
||||
@Column(nullable = false, length = 32)
|
||||
private String gateway;
|
||||
@ -55,7 +51,7 @@ public class Payment {
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "three_ds_status", nullable = false, length = 32)
|
||||
private ThreeDSStatus threeDsStatus = ThreeDSStatus.NOT_APPLICABLE;
|
||||
private ThreeDSStatus threeDsStatus = ThreeDSStatus.not_applicable;
|
||||
|
||||
@Column(length = 22)
|
||||
private String descriptor;
|
||||
@ -99,9 +95,6 @@ public class Payment {
|
||||
public Long getUserId() { return userId; }
|
||||
public void setUserId(Long userId) { this.userId = userId; }
|
||||
|
||||
public PaymentMethod getPaymentMethod() { return paymentMethod; }
|
||||
public void setPaymentMethod(PaymentMethod paymentMethod) { this.paymentMethod = paymentMethod; }
|
||||
|
||||
public String getCurrency() { return currency; }
|
||||
public void setCurrency(String currency) { this.currency = currency; }
|
||||
|
||||
|
||||
@ -1,100 +0,0 @@
|
||||
package com.imprimelibros.erp.payments.model;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "payment_methods")
|
||||
public class PaymentMethod {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private Long userId;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(nullable = false, length = 32)
|
||||
private PaymentMethodType type;
|
||||
|
||||
@Column(length = 32)
|
||||
private String brand;
|
||||
|
||||
@Column(length = 4)
|
||||
private String last4;
|
||||
|
||||
@Column(name = "exp_month")
|
||||
private Integer expMonth;
|
||||
|
||||
@Column(name = "exp_year")
|
||||
private Integer expYear;
|
||||
|
||||
@Column(length = 128)
|
||||
private String fingerprint;
|
||||
|
||||
@Column(length = 128, unique = true)
|
||||
private String tokenId;
|
||||
|
||||
@Column(length = 128)
|
||||
private String sepaMandateId;
|
||||
|
||||
@Column(length = 190)
|
||||
private String payerEmail;
|
||||
|
||||
@Column(columnDefinition = "json")
|
||||
private String metadata;
|
||||
|
||||
@Column(name = "created_at", nullable = false,
|
||||
columnDefinition = "datetime default current_timestamp")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "updated_at", nullable = false,
|
||||
columnDefinition = "datetime default current_timestamp on update current_timestamp")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
// ---- Getters/Setters ----
|
||||
public PaymentMethod() {}
|
||||
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public Long getUserId() { return userId; }
|
||||
public void setUserId(Long userId) { this.userId = userId; }
|
||||
|
||||
public PaymentMethodType getType() { return type; }
|
||||
public void setType(PaymentMethodType type) { this.type = type; }
|
||||
|
||||
public String getBrand() { return brand; }
|
||||
public void setBrand(String brand) { this.brand = brand; }
|
||||
|
||||
public String getLast4() { return last4; }
|
||||
public void setLast4(String last4) { this.last4 = last4; }
|
||||
|
||||
public Integer getExpMonth() { return expMonth; }
|
||||
public void setExpMonth(Integer expMonth) { this.expMonth = expMonth; }
|
||||
|
||||
public Integer getExpYear() { return expYear; }
|
||||
public void setExpYear(Integer expYear) { this.expYear = expYear; }
|
||||
|
||||
public String getFingerprint() { return fingerprint; }
|
||||
public void setFingerprint(String fingerprint) { this.fingerprint = fingerprint; }
|
||||
|
||||
public String getTokenId() { return tokenId; }
|
||||
public void setTokenId(String tokenId) { this.tokenId = tokenId; }
|
||||
|
||||
public String getSepaMandateId() { return sepaMandateId; }
|
||||
public void setSepaMandateId(String sepaMandateId) { this.sepaMandateId = sepaMandateId; }
|
||||
|
||||
public String getPayerEmail() { return payerEmail; }
|
||||
public void setPayerEmail(String payerEmail) { this.payerEmail = payerEmail; }
|
||||
|
||||
public String getMetadata() { return metadata; }
|
||||
public void setMetadata(String metadata) { this.metadata = metadata; }
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
public LocalDateTime getUpdatedAt() { return updatedAt; }
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) { this.updatedAt = updatedAt; }
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
package com.imprimelibros.erp.payments.model;
|
||||
|
||||
public enum PaymentMethodType { CARD, BIZUM, BANK_TRANSFER }
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package com.imprimelibros.erp.payments.model;
|
||||
|
||||
public enum PaymentStatus {
|
||||
REQUIRES_PAYMENT_METHOD, REQUIRES_ACTION, AUTHORIZED,
|
||||
CAPTURED, PARTIALLY_REFUNDED, REFUNDED, CANCELED, FAILED
|
||||
requires_payment_method, requires_action, authorized,
|
||||
captured, partially_refunded, refunded, canceled, failed
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -120,4 +120,13 @@ public class PaymentTransaction {
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (createdAt == null) {
|
||||
createdAt = now;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.imprimelibros.erp.payments.model;
|
||||
|
||||
public enum PaymentTransactionStatus { PENDING, SUCCEEDED, FAILED }
|
||||
public enum PaymentTransactionStatus { pending, succeeded, failed }
|
||||
|
||||
|
||||
@ -33,11 +33,11 @@ public class Refund {
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "reason", nullable = false, length = 32)
|
||||
private RefundReason reason = RefundReason.CUSTOMER_REQUEST;
|
||||
private RefundReason reason = RefundReason.customer_request;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "status", nullable = false, length = 16)
|
||||
private RefundStatus status = RefundStatus.PENDING;
|
||||
private RefundStatus status = RefundStatus.pending;
|
||||
|
||||
@Column(name = "requested_by_user_id")
|
||||
private Long requestedByUserId;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.imprimelibros.erp.payments.model;
|
||||
|
||||
public enum RefundReason {
|
||||
CUSTOMER_REQUEST, PARTIAL_RETURN, PRICING_ADJUSTMENT, DUPLICATE, FRAUD, OTHER
|
||||
customer_request, partial_return, pricing_adjustment, duplicate, fraud, other
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.imprimelibros.erp.payments.model;
|
||||
|
||||
public enum RefundStatus { PENDING, SUCCEEDED, FAILED, CANCELED }
|
||||
public enum RefundStatus { pending, succeeded, failed, canceled }
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.imprimelibros.erp.payments.model;
|
||||
|
||||
public enum ThreeDSStatus { NOT_APPLICABLE, ATTEMPTED, CHALLENGE, SUCCEEDED, FAILED }
|
||||
public enum ThreeDSStatus { not_applicable, attempted, challenge, succeeded, failed }
|
||||
|
||||
|
||||
@ -85,4 +85,12 @@ public class WebhookEvent {
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (createdAt == null) {
|
||||
createdAt = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user