sub scription prooductds
This commit is contained in:
@@ -23,6 +23,7 @@ class Members(db.Model):
|
||||
country = db.Column(db.String(3), nullable=True)
|
||||
profile_completed = db.Column(db.DateTime(timezone=False))
|
||||
stripe_customer_id = db.Column(db.String(100), nullable=True)
|
||||
option_name = db.Column(db.String(100), nullable=True)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
@@ -41,6 +42,7 @@ class Members(db.Model):
|
||||
"account_name": self.account_name,
|
||||
"firstname": self.firstname,
|
||||
"lastname": self.lastname,
|
||||
'option_name': self.option_name,
|
||||
"stripe_customer_id": self.stripe_customer_id
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ from datetime import datetime, timezone
|
||||
from app.extensions import db
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
# Inside Stripe_Product ===== : {'product_id': 'prod_SvB4RlFx6qXK6v', 'price_id': 'price_1RzKi4LjZLojw6IZA246JDAa'}
|
||||
|
||||
class SubscriptionOptions(db.Model):
|
||||
__tablename__ = 'subscription_options'
|
||||
@@ -14,6 +15,8 @@ class SubscriptionOptions(db.Model):
|
||||
status = db.Column(db.Integer, nullable=True, default=1)
|
||||
added = db.Column(db.DateTime(timezone=False), server_default=func.now())
|
||||
updated = db.Column(db.DateTime(timezone=False), server_default=func.now(), onupdate=func.now())
|
||||
stripe_product_id = db.Column(db.String(100), nullable=True)
|
||||
stripe_price_id = db.Column(db.String(100), nullable=True)
|
||||
|
||||
|
||||
@classmethod
|
||||
@@ -23,6 +26,28 @@ class SubscriptionOptions(db.Model):
|
||||
return None
|
||||
return sub_options
|
||||
|
||||
@classmethod
|
||||
def set_stripe_product_id(cls,package_uid, stripe_product_id):
|
||||
# Retrieve
|
||||
sub_option = cls.query.filter_by(uid=str(package_uid)).first()
|
||||
|
||||
if not sub_option:
|
||||
raise ValueError(f"Reset with ID {package_uid} does not exist.")
|
||||
|
||||
# Update stripe_product_id
|
||||
sub_option.stripe_product_id = stripe_product_id
|
||||
|
||||
@classmethod
|
||||
def set_stripe_price_id(cls, package_uid, stripe_price_id):
|
||||
# Retrieve
|
||||
sub_option = cls.query.filter_by(uid=str(package_uid)).first()
|
||||
|
||||
if not sub_option:
|
||||
raise ValueError(f"Reset with ID {package_uid} does not exist.")
|
||||
|
||||
# Update stripe_price_id
|
||||
sub_option.stripe_price_id = stripe_price_id
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
@@ -31,6 +56,8 @@ class SubscriptionOptions(db.Model):
|
||||
"display_name": self.display_name,
|
||||
"status": self.status,
|
||||
"monthly": self.monthly,
|
||||
"stripe_product_id": self.stripe_product_id,
|
||||
"stripe_price_id": self.stripe_price_id,
|
||||
"added": self.added.isoformat() if self.added else None,
|
||||
"updated": self.updated.isoformat() if self.updated else None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user