feat(payments): add Payment model for Phase 1 receipt data capture
Introduces the payments collection with fields Phase 2 will need to generate official donation receipts: amount, paymentDate, paymentType (monthly|annual), helcimTransactionId (unique), and receiptIssued / receiptId placeholders Phase 2 will populate. Schema-only; no routes or UI in this commit.
This commit is contained in:
parent
335a4db7cc
commit
bf5a333117
1 changed files with 28 additions and 0 deletions
28
server/models/payment.js
Normal file
28
server/models/payment.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import mongoose from 'mongoose'
|
||||
|
||||
const paymentSchema = new mongoose.Schema(
|
||||
{
|
||||
memberId: { type: mongoose.Schema.Types.ObjectId, ref: 'Member', required: true, index: true },
|
||||
helcimTransactionId: { type: String, required: true, unique: true },
|
||||
helcimCustomerId: { type: String, index: true },
|
||||
helcimSubscriptionId: { type: String, index: true, default: null },
|
||||
|
||||
amount: { type: Number, required: true, min: 0 },
|
||||
currency: { type: String, default: 'CAD' },
|
||||
paymentDate: { type: Date, required: true },
|
||||
|
||||
paymentType: { type: String, enum: ['monthly', 'annual'], required: true },
|
||||
status: { type: String, enum: ['success', 'failed', 'refunded'], required: true, default: 'success' },
|
||||
failureReason: { type: String, default: null },
|
||||
|
||||
receiptIssued: { type: Boolean, default: false },
|
||||
receiptId: { type: String, default: null },
|
||||
|
||||
rawHelcim: { type: mongoose.Schema.Types.Mixed, default: null },
|
||||
},
|
||||
{ timestamps: true, collection: 'payments' }
|
||||
)
|
||||
|
||||
paymentSchema.index({ memberId: 1, paymentDate: -1 })
|
||||
|
||||
export default mongoose.models.Payment || mongoose.model('Payment', paymentSchema)
|
||||
Loading…
Add table
Add a link
Reference in a new issue