Skip to content

AZBrandCanada/The-Anxiety-Guy-GETDPD-API-Connector-Wordpress

Repository files navigation

This is Setup to work on Ubuntu 22.04. with Python 3* it may work with other distros, but untested

GetDPD API Integration tool For The Anxiety Guy

This repository contains various Python scripts and system service files for managing and monitoring GetDPD API transactions, WordPress user additions, and service health checks for high availability and alerts. it creats a user after a customers buys and adds them to a role you make, you need to use a wordpress plugin to lock certain pages to a role.

This API Integration Tool is built with 4x redundancy to ensure it is always active with clear warnings to telegram in the event of any errors

this works in conjunction monitoring email services, with this wordpress plugin

https://github.com/AZBrandCanada/V1.7.19-Wordpress-Automatic-Email-Testing-With-Telegram-Alerts.git

Contents

  • app.py: Main program to run the application.
  • 2.3wordpress.py: Reads API logs, adds users to WordPress, and sends Telegram alerts when new users are added or when errors occur.
  • 11getdpdlistsales.py: Connects to GetDPD's API and saves transactions to transactions.txt.
  • monitor.py: Checks the timestamp.txt file. If the file is older than 30 seconds, it sends alerts every 5 seconds to Telegram warning of an issue.
  • monitorservice.py: Monitors all services and sends alerts if any services go down.
  • statuscheck.py: Runs in crontab 0 4,10,22 * * * /usr/bin/python3 /home/user/The-Anxiety-Guy-GETDPD-Connector-Wordpress/statuscheck.py and sends a Telegram status check at the specified times.
  • processed_users.txt: Keeps a list of all users that were added to WordPress to avoid re-adding them.
  • verbosity.txt: this is a setting file for 2.3wordpress.py, to allow sending logs to telegram whenever a new user is created.
  • current_page.txt: this is a setting file for 2.3wordpress.py, set it before running to the desired page you want to start indexing from the API. setting 1 will index all pages up to the current date.(not reccomended unless you are importing all old clients to a new backend and creating accounts for all of them. in which case rate limits should be introduced. if any pages are missing in the api, you will have manually increase the number in this file to the next page that isn't empty.)

Installation and Usage

1. Clone this repository.

git clone https://github.com/AZBrandCanada/The-Anxiety-Guy-GETDPD-API-Connector-Wordpress.git

2. Navigate to the repository directory.

cd The-Anxiety-Guy-GETDPD-API-Connector-Wordpress

3. Add wordpress, getdpd, telegram and SMTP keys, any website.ca entries in the files to your own website and the role for wordpres you choose to use to these files.

nano app.py
nano 2.3wordpress.py
nano 11.getdpdlistsales.py
nano monitor.py
nano monitorservice.py
nano statuscheck.py

4. Changing the Product to your Own Producs

it needs to be the exact product name only change 'VIP - Inner Circle Anxiety Recovery Program'

nano 2.3wordpressdpd.py
and edit this line 25
vip_entries = [json.loads(line) for line in lines if 'VIP - Inner Circle Anxiety Recovery Program' in json.loads(line).get('product_name', '')]

5. Configure and enable the system services

using the provided service files below change the file locations, users and working directories to the proper ones.

Install System Service Files

getdpd-service-monitor.service

sudo nano /etc/systemd/system/getdpd-service-monitor.service
[Service]
Type=simple
User=user
ExecStart=/usr/bin/python3 /home/user/The-Anxiety-Guy-GETDPD-API-Connector-Wordpress/monitorservice.py
WorkingDirectory=/home/user/The-Anxiety-Guy-GETDPD-Connector-Wordpress
Restart=on-failure

getdpd.service

Service File Location

sudo nano /etc/systemd/system/getdpd.service
[Service]
Type=simple
User=user
ExecStart=/usr/bin/python3 /home/user/The-Anxiety-Guy-GETDPD-API-Connector-Wordpress/app.py
WorkingDirectory=/home/user/The-Anxiety-Guy-GETDPD-Connector-Wordpress
Restart=on-failure

getdpdmonitor.service

Service File Location

sudo nano /etc/systemd/system/getdpdmonitor.service
[Service]
Type=simple
User=user
ExecStart=/usr/bin/python3 /home/user/The-Anxiety-Guy-GETDPD-API-Connector-Wordpress/monitor.py
WorkingDirectory=/home/user/The-Anxiety-Guy-GETDPD-API-Connector-Wordpress
Restart=on-failure

emaillog.service

Service File Location

sudo nano /etc/systemd/system/emaillog.service
[Unit]
Description=Email Checker Service
After=network.target

[Service]
Type=simple
User=user
WorkingDirectory=/home/user/emailchecker
ExecStart=/usr/bin/python3 /home/user/The-Anxiety-Guy-GETDPD-API-Connector-Wordpress/email_checker.py
Restart=on-failure

[Install]
WantedBy=multi-user.target
crontab -e 
0 4,10,22 * * * /usr/bin/python3 /home/user/The-Anxiety-Guy-GETDPD-API-Connector-Wordpress/statuscheck.py

6. Ensure all required Python dependencies are installed.

7. Run the programs and monitor services with.

Reload systemd manager configuration:

After copying the service files, reload the systemd configuration to recognize the new service files.

sudo systemctl daemon-reload

Enable the services to start on boot.

sudo systemctl enable getdpd-service-monitor.service
sudo systemctl enable getdpd.service
sudo systemctl enable getdpdmonitor.service
sudo systemctl enable emaillog.service

Start each service to run them immediately.

sudo systemctl start getdpd-service-monitor.service
sudo systemctl start getdpd.service
sudo systemctl start getdpdmonitor.service
sudo systemctl start emaillog.service

8. Check the status of the services:

Verify that each service is running correctly.

sudo systemctl status getdpd-service-monitor.service
sudo systemctl status getdpd.service
sudo systemctl status getdpdmonitor.service
sudo systemctl status emaillog.service

This will ensure that the services are correctly installed, enabled, and running on your system. If there are any issues, the status command will provide details to help diagnose and fix them.

Contributing

We welcome contributions! Here’s how you can get started:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Make your changes.
  4. Commit your changes with a meaningful commit message.
  5. Push your changes to your forked repository.
  6. Open a pull request to the main branch of this repository.

Please ensure that your code adheres to our coding standards and is well-documented. Thank you for your contributions!

Contact

For any inquiries, issues, or suggestions, feel free to open an issue or contact us at https://AZbrand.ca

License

This project is licensed under the MIT License.

About

This connects getdpd to wordpress for a single item after a sale is made

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages