mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-12 16:38:48 +00:00
133 lines
4.7 KiB
Java
133 lines
4.7 KiB
Java
package com.imprimelibros.erp.payments.model;
|
|
|
|
import jakarta.persistence.*;
|
|
import java.time.LocalDateTime;
|
|
|
|
@Entity
|
|
@Table(
|
|
name = "payment_transactions",
|
|
uniqueConstraints = {
|
|
@UniqueConstraint(name = "uq_tx_gateway_txid", columnNames = {"gateway_transaction_id"})
|
|
},
|
|
indexes = {
|
|
@Index(name = "idx_tx_pay", columnList = "payment_id"),
|
|
@Index(name = "idx_tx_type_status", columnList = "type,status"),
|
|
@Index(name = "idx_tx_idem", columnList = "idempotency_key")
|
|
}
|
|
)
|
|
public class PaymentTransaction {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
|
@JoinColumn(name = "payment_id", nullable = false)
|
|
private Payment payment;
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
@Column(name = "type", nullable = false, length = 16)
|
|
private PaymentTransactionType type;
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
@Column(name = "status", nullable = false, length = 16)
|
|
private PaymentTransactionStatus status;
|
|
|
|
@Column(name = "amount_cents", nullable = false)
|
|
private Long amountCents;
|
|
|
|
@Column(name = "currency", nullable = false, length = 3)
|
|
private String currency;
|
|
|
|
@Column(name = "gateway_transaction_id", length = 128)
|
|
private String gatewayTransactionId;
|
|
|
|
@Column(name = "gateway_response_code", length = 64)
|
|
private String gatewayResponseCode;
|
|
|
|
@Column(name = "avs_result", length = 8)
|
|
private String avsResult;
|
|
|
|
@Column(name = "cvv_result", length = 8)
|
|
private String cvvResult;
|
|
|
|
@Column(name = "three_ds_version", length = 16)
|
|
private String threeDsVersion;
|
|
|
|
@Column(name = "idempotency_key", length = 128)
|
|
private String idempotencyKey;
|
|
|
|
@Column(name = "request_payload", columnDefinition = "json")
|
|
private String requestPayload;
|
|
|
|
@Column(name = "response_payload", columnDefinition = "json")
|
|
private String responsePayload;
|
|
|
|
@Column(name = "processed_at")
|
|
private LocalDateTime processedAt;
|
|
|
|
@Column(name = "created_at", nullable = false,
|
|
columnDefinition = "datetime default current_timestamp")
|
|
private LocalDateTime createdAt;
|
|
|
|
public PaymentTransaction() {}
|
|
|
|
// Getters & Setters
|
|
public Long getId() { return id; }
|
|
public void setId(Long id) { this.id = id; }
|
|
|
|
public Payment getPayment() { return payment; }
|
|
public void setPayment(Payment payment) { this.payment = payment; }
|
|
|
|
public PaymentTransactionType getType() { return type; }
|
|
public void setType(PaymentTransactionType type) { this.type = type; }
|
|
|
|
public PaymentTransactionStatus getStatus() { return status; }
|
|
public void setStatus(PaymentTransactionStatus status) { this.status = status; }
|
|
|
|
public Long getAmountCents() { return amountCents; }
|
|
public void setAmountCents(Long amountCents) { this.amountCents = amountCents; }
|
|
|
|
public String getCurrency() { return currency; }
|
|
public void setCurrency(String currency) { this.currency = currency; }
|
|
|
|
public String getGatewayTransactionId() { return gatewayTransactionId; }
|
|
public void setGatewayTransactionId(String gatewayTransactionId) { this.gatewayTransactionId = gatewayTransactionId; }
|
|
|
|
public String getGatewayResponseCode() { return gatewayResponseCode; }
|
|
public void setGatewayResponseCode(String gatewayResponseCode) { this.gatewayResponseCode = gatewayResponseCode; }
|
|
|
|
public String getAvsResult() { return avsResult; }
|
|
public void setAvsResult(String avsResult) { this.avsResult = avsResult; }
|
|
|
|
public String getCvvResult() { return cvvResult; }
|
|
public void setCvvResult(String cvvResult) { this.cvvResult = cvvResult; }
|
|
|
|
public String getThreeDsVersion() { return threeDsVersion; }
|
|
public void setThreeDsVersion(String threeDsVersion) { this.threeDsVersion = threeDsVersion; }
|
|
|
|
public String getIdempotencyKey() { return idempotencyKey; }
|
|
public void setIdempotencyKey(String idempotencyKey) { this.idempotencyKey = idempotencyKey; }
|
|
|
|
public String getRequestPayload() { return requestPayload; }
|
|
public void setRequestPayload(String requestPayload) { this.requestPayload = requestPayload; }
|
|
|
|
public String getResponsePayload() { return responsePayload; }
|
|
public void setResponsePayload(String responsePayload) { this.responsePayload = responsePayload; }
|
|
|
|
public LocalDateTime getProcessedAt() { return processedAt; }
|
|
public void setProcessedAt(LocalDateTime processedAt) { this.processedAt = processedAt; }
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
}
|