niki/domain/payment/service/entity.go

95 lines
1.7 KiB
Go

package service
import (
"encoding/json"
"time"
)
type PaymentStatus string
const (
PaymentStatusPending PaymentStatus = "Pending"
PaymentStatusSuccess PaymentStatus = "Success"
PaymentStatusFailed PaymentStatus = "Failed"
PaymentStatusCancelled PaymentStatus = "Cancelled"
//...
)
type Currency string
const (
CurrencyIRR Currency = "IRR"
CurrencyUSD Currency = "USD"
)
type TransactionType string
const (
TransactionTypeRequest TransactionType = "request"
TransactionTypeVerify TransactionType = "verify"
)
type TransactionStatus string
const (
TransactionStatusPending = "Pending"
TransactionStatusSuccess = "Success"
TransactionStatusFailed = "Failed"
)
type PayableType string
const (
PayableTypeDonate PayableType = "Donate"
PayableTypeOrder PayableType = "Order"
PayableTypeWalet PayableType = "WaletCharge"
)
type PaymentMethod struct {
ID uint
Name string
IsActive bool
CreatedAt time.Time
UpdatedAt time.Time
}
type Gateway struct {
ID uint
Name string
Code string
IsActive bool
Config json.RawMessage
CreatedAt time.Time
UpdatedAt time.Time
}
type Payment struct {
ID uint
UserID uint
MethodID uint
GatewayID uint
PayableType PayableType
PayableID uint
TotalAmount int64
PaidAmount int64
Currency Currency
Status PaymentStatus
Description string
CreatedAt time.Time
UpdatedAt time.Time
PaidAt *time.Time
}
type PaymentTransaction struct {
ID uint
PaymentID uint
Type TransactionType
RequestData json.RawMessage
ResponseData json.RawMessage
RefID string
Status TransactionStatus
GatewayToken string
ErrorMessage string
CreatedAt time.Time
UpdatedAt time.Time
}