Skip to content

Commit

Permalink
models complete, invoice to be managed via service-to-service communi…
Browse files Browse the repository at this point in the history
…cation without creating an entity in the Payment Service.
  • Loading branch information
felixojiambo committed Dec 15, 2024
1 parent a5b90b7 commit ff2dda4
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.finpay.payment_service.models;

import lombok.*;
import java.util.Set;
import java.util.UUID;

@Entity
@Table(name = "payment_gateways")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PaymentGateway {

@Id
@GeneratedValue
private UUID id;

@Column(nullable = false, unique = true)
private String name; // e.g., Stripe, PayPal, Square

@Column(nullable = false)
private String apiEndpoint;

@Column(nullable = false)
private String apiKey;

@OneToMany(mappedBy = "paymentGateway", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<Payment> payments;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.finpay.payment_service.models;

import lombok.*;
import java.util.Set;
import java.util.UUID;

@Entity
@Table(name = "payment_methods")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class PaymentMethod {

@Id
@GeneratedValue
private UUID id;

@Column(nullable = false, unique = true)
private String type; // e.g., CREDIT_CARD, BANK_TRANSFER, DIGITAL_WALLET

@OneToMany(mappedBy = "paymentMethod", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<Payment> payments;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.finpay.payment_service.models;

import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.UUID;

@Entity
@Table(name = "refunds")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Refund {

@Id
@GeneratedValue
private UUID id;

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

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private RefundStatus status;

@Column(nullable = false)
private BigDecimal amount;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "payment_id")
private Payment payment;

@Column(nullable = false)
private LocalDateTime createdAt;

private LocalDateTime updatedAt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.finpay.payment_service.models;

public enum RefundStatus {
INITIATED,
COMPLETED,
FAILED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.finpay.payment_service.models;

public enum TransactionStatus {
SUCCESS,
FAILURE,
PENDING
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.finpay.payment_service.models;

public enum TransactionType {
INITIATION,
RETRY,
REFUND
}

0 comments on commit ff2dda4

Please sign in to comment.