RezinaLMS-BackEnd/internal/ports/payment.go
Yared Yemane 9f04706fb9 feat: add admin grant, extend, and cancel for learner subscriptions
Record complimentary admin payment rows for audit, cancel only open payments so paid revenue stays intact, and exclude ADMIN_GRANT/ADMIN_EXTEND from revenue analytics.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-10 02:33:29 -07:00

28 lines
1.6 KiB
Go

package ports
import (
"Yimaru-Backend/internal/domain"
"context"
)
type PaymentStore interface {
CreatePayment(ctx context.Context, input domain.CreatePaymentInput) (*domain.Payment, error)
CreateAdminPayment(ctx context.Context, input domain.CreateAdminPaymentInput) (*domain.Payment, error)
GetPaymentByID(ctx context.Context, id int64) (*domain.Payment, error)
GetPaymentBySessionID(ctx context.Context, sessionID string) (*domain.Payment, error)
GetPaymentByNonce(ctx context.Context, nonce string) (*domain.Payment, error)
GetPaymentByTransactionID(ctx context.Context, transactionID string) (*domain.Payment, error)
GetPaymentsByUserID(ctx context.Context, userID int64, limit, offset int32) ([]domain.Payment, error)
GetPendingPaymentsByUserID(ctx context.Context, userID int64) ([]domain.Payment, error)
UpdatePaymentStatus(ctx context.Context, id int64, status string) error
UpdatePaymentStatusBySessionID(ctx context.Context, sessionID, status, transactionID, paymentMethod string) error
UpdatePaymentStatusByNonce(ctx context.Context, nonce, status, transactionID, paymentMethod string) error
UpdatePaymentSessionID(ctx context.Context, id int64, sessionID, paymentURL string) error
LinkPaymentToSubscription(ctx context.Context, paymentID, subscriptionID int64) error
CancelPaymentsBySubscriptionID(ctx context.Context, subscriptionID int64) (int64, error)
GetExpiredPendingPayments(ctx context.Context) ([]domain.Payment, error)
ExpirePayment(ctx context.Context, id int64) error
ExpireStalePendingPayments(ctx context.Context) (int64, error)
ListPaymentsAdmin(ctx context.Context, filter domain.PaymentListFilter) (domain.PaymentListPage, error)
}