From 2bfb802b10cc505cfadb4ada55040796b994db30 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Mon, 9 Mar 2026 18:56:33 -0400 Subject: [PATCH] automation calls --- app/api/integrations/merms_stripe.py | 6 +++ app/api/routes/routes.py | 9 ++++ app/api/services/__init__.py | 1 + app/api/services/automation_calls.py | 67 ++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 app/api/services/automation_calls.py diff --git a/app/api/integrations/merms_stripe.py b/app/api/integrations/merms_stripe.py index 83bd414..ca5deb9 100644 --- a/app/api/integrations/merms_stripe.py +++ b/app/api/integrations/merms_stripe.py @@ -11,6 +11,12 @@ class StripeIntegration: STRIPE_SUCCESS_URL = Config.STRIPE_SUCCESS_URL STRIPE_CANCEL_URL= Config.STRIPE_CANCEL_URL + @staticmethod + def transction_hx(limit=30): + logger.info(f"Inside Stripe_Transaction Hx ===== :") + invoice_items = stripe.InvoiceItem.list(limit) + return invoice_items + @staticmethod def create_customer(stripe_customer): logger.info(f"Inside Stripe_Customer ===== : {stripe_customer}") diff --git a/app/api/routes/routes.py b/app/api/routes/routes.py index de5292e..d00a2be 100644 --- a/app/api/routes/routes.py +++ b/app/api/routes/routes.py @@ -13,6 +13,7 @@ from app.api.services import ( SubscriptionsService, CommonDataService, OfficeCustomerService, + AutomationCalls, GenerativesService, OfficeUsersService, OfficeTemplatesService, OfficeCountryService, WebsiteService, FileUploadService, ReportService ) @@ -897,6 +898,14 @@ def email_check(): AccountService.process_test_email(data) return {"status": "ok"}, 200 +# =================================================== +# Health Check Endpoint +@api.route("/cron/refresh-payhx", methods=["GET"]) +def refresh_payhx(): + data = {} + AutomationCalls.process_stripe_payment_refresh(data) + return {"status": "ok"}, 200 + # Health Check Endpoint @api.route("/health", methods=["GET"]) diff --git a/app/api/services/__init__.py b/app/api/services/__init__.py index db4d1a7..6a07df3 100644 --- a/app/api/services/__init__.py +++ b/app/api/services/__init__.py @@ -14,6 +14,7 @@ from app.api.services.comments import CommentsService from app.api.services.file_upload import FileUploadService from app.api.services.reports import ReportService +from app.api.services.automation_calls import AutomationCalls #WEBSITE from app.api.services.website import WebsiteService diff --git a/app/api/services/automation_calls.py b/app/api/services/automation_calls.py new file mode 100644 index 0000000..17efe3f --- /dev/null +++ b/app/api/services/automation_calls.py @@ -0,0 +1,67 @@ +from flask import session, jsonify + +from app.api.schemas.user_update import UserUpdateSchema +# from app.models.loan import Loan +from app.utils.logger import logger +from app.api.services.base_service import BaseService +# from app.api.schemas.eligibility_check import EligibilityCheckSchema +from marshmallow import ValidationError +from app.api.enums import TransactionType +# from app.api.integrations import SimbrellaIntegration +from app.extensions import db +from app.models import Members, MembersActions, MembersProfile, Payments, MembersProducts, ProvisionActions +# from app.api.services.offer_analysis import OfferAnalysis +from app.api.helpers.response_helper import ResponseHelper +from werkzeug.security import generate_password_hash, check_password_hash +from app.api.schemas.user import UserSchema +from app.api.schemas.start_profile import StartProfileSchema +from app.api.schemas.profile_links import ProfileLinksSchema +from app.api.integrations import StripeIntegration + + +from flask_mail import Mail, Message +import smtplib +from email.mime.text import MIMEText +from email.mime.multipart import MIMEMultipart + +import datetime +import jwt +import random +from app.config import Config + + +import smtplib, ssl +from email.message import EmailMessage + +class AutomationCalls(BaseService): + JWT_SECRET_KEY = Config.JWT_SECRET_KEY + + SEND_EMAIL_FROM = Config.SEND_EMAIL_FROM + SEND_EMAIL_PASS = Config.SEND_EMAIL_PASS + THIS_SITE_URL = Config.THIS_SITE_URL + + @staticmethod + def process_stripe_payment_refresh(data): + + stripe_transactions = StripeIntegration.transction_hx() + print(stripe_transactions) + logger.info(f"Return Stripe_Transaction Hx ===== : {stripe_transactions}") + + bar_data = { + "last_update": datetime.datetime.utcnow(), + "top_bar": [ + {"id": "1", "description": "Contacts", "last_update": "10-10-2010 11:00 AM", + "value": random.randint(0, 10), "data_span": 'Last 2 months', "link": "#", "extra_style": ''}, + {"id": "2", "description": "Site Traffic", "last_update": "10-10-2010 11:30 AM", + "value": random.randint(0, 10), "data_span": 'Past 12 hours', "link": "#", "extra_style": ''}, + {"id": "3", "description": "Appointments", "last_update": "10-12-2010 11:30 AM", + "value": random.randint(0, 10), "data_span": 'Last 14 days', "link": "#", "extra_style": ''}, + {"id": "4", "description": "Upgrade Account", "last_update": "10-12-2010 11:30 AM", + "value": "Free Trial", "data_span": 'End: 10/10/2025', "link": "/subscription", + "extra_style": " billing "} + ] + } + return ResponseHelper.success(data=bar_data) + + +