tenderizer / src /models /Transaction.js
ismizo's picture
Upload 28 files
0ba1efd verified
Raw History Blame Contribute Delete
1.49 kB
import mongoose from 'mongoose';
const transactionSchema = new mongoose.Schema({
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
required: true
},
amount: {
type: Number,
required: true
},
currency: {
type: String,
default: 'TZS'
},
creditsPurchased: {
type: Number,
required: true
},
providerReference: String, // ID from ClickPesa (auto payments)
reference: String, // Our internal short ref
phoneNumber: String,
// Payment method tracking
paymentMethod: {
type: String,
enum: ['auto', 'mpesa_manual'],
default: 'auto'
},
// M-Pesa manual payment fields
mpesaProof: String, // Storage key of screenshot OR typed transaction code
mpesaProofType: {
type: String,
enum: ['screenshot', 'code'],
default: 'code'
},
mpesaNumber: String, // The M-Pesa number used
reviewNote: String, // Admin note on approval/rejection
reviewedBy: String, // Admin email who reviewed
reviewedAt: Date,
status: {
type: String,
enum: ['pending', 'pending_review', 'completed', 'failed', 'rejected', 'SUCCESS', 'SETTLED'],
default: 'pending'
},
createdAt: {
type: Date,
default: Date.now
}
});
const Transaction = mongoose.model('Transaction', transactionSchema);
export default Transaction;