Skip to content

Commit

Permalink
Removed the Invoice entity from the Payment Service models.
Browse files Browse the repository at this point in the history
Added invoiceId as a UUID to reference invoices managed by the Invoice Service.
Maintained the paymentGateway field to identify the external payment gateway used.
  • Loading branch information
felixojiambo committed Dec 15, 2024
1 parent 07a2456 commit 0580f81
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Set;
Expand All @@ -20,7 +23,7 @@ public class Payment {
private UUID id;

@Column(nullable = false, unique = true)
private String paymentReference;
private String paymentReference; // Unique reference for the payment

@Column(nullable = false)
private BigDecimal amount;
Expand All @@ -32,22 +35,22 @@ public class Payment {
@Column(nullable = false)
private PaymentStatus status;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "payment_method_id")
private PaymentMethod paymentMethod;
@Column(nullable = false)
private UUID invoiceId; // Reference to Invoice managed by Invoice Service

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "payment_gateway_id")
private PaymentGateway paymentGateway;
@Column(nullable = false)
private String paymentGateway; // e.g., Stripe, PayPal

@OneToMany(mappedBy = "payment", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<Transaction> transactions;

@OneToMany(mappedBy = "payment", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<Refund> refunds;

@Column(nullable = false)
@CreationTimestamp
@Column(nullable = false, updatable = false)
private LocalDateTime createdAt;

@UpdateTimestamp
private LocalDateTime updatedAt;
}

0 comments on commit 0580f81

Please sign in to comment.