mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
* Added payment to groups and pay with group plan with Stripe * Added edit card for Stripe * Added stripe cancel * Added subscribe with Amazon payments * Added Amazon cancel for group subscription * Added group subscription with paypal * Added paypal cancel * Added ipn cancel for Group plan * Added a subscription tab and hid only the task tab when group is not subscribed * Fixed linting issues * Fixed tests * Added payment unit tests * Added back refresh after stripe payment * Fixed style issues * Limited grouop query fields and checked access * Abstracted subscription schema * Added year group plan and more access checks * Maded purchase fields private * Removed id and timestampes * Added else checks to ensure user subscription is not altered. Removed active field from group model * Added toJSONTransform function * Moved plan active check to other toJson function * Added check to see if purchaed has been populated * Added purchase details to private * Added correct data usage when paying for group sub
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
import mongoose from 'mongoose';
|
|
import baseModel from '../libs/baseModel';
|
|
|
|
export let schema = new mongoose.Schema({
|
|
planId: String,
|
|
paymentMethod: String, // enum: ['Paypal','Stripe', 'Gift', 'Amazon Payments', '']}
|
|
customerId: String, // Billing Agreement Id in case of Amazon Payments
|
|
dateCreated: Date,
|
|
dateTerminated: Date,
|
|
dateUpdated: Date,
|
|
extraMonths: {type: Number, default: 0},
|
|
gemsBought: {type: Number, default: 0},
|
|
mysteryItems: {type: Array, default: () => []},
|
|
lastBillingDate: Date, // Used only for Amazon Payments to keep track of billing date
|
|
consecutive: {
|
|
count: {type: Number, default: 0},
|
|
offset: {type: Number, default: 0}, // when gifted subs, offset++ for each month. offset-- each new-month (cron). count doesn't ++ until offset==0
|
|
gemCapExtra: {type: Number, default: 0},
|
|
trinkets: {type: Number, default: 0},
|
|
},
|
|
}, {
|
|
strict: true,
|
|
minimize: false, // So empty objects are returned
|
|
_id: false,
|
|
});
|
|
|
|
schema.plugin(baseModel, {
|
|
noSet: ['_id'],
|
|
timestamps: false,
|
|
});
|
|
|
|
export let model = mongoose.model('SubscriptionPlan', schema);
|