├── README.md ├── requirements.txt ├── .github ├── ISSUE_TEMPLATE │ ├── custom.md │ ├── feature_request.md │ └── bug_report.md └── workflows │ └── codeql.yml ├── src ├── paymentx │ ├── wsgi.py │ ├── settings.py │ ├── __init__.py │ ├── urls.py │ └── twitter │ │ ├── __init__.py │ │ ├── serializers.py │ │ ├── exceptions.py │ │ ├── client.py │ │ ├── views.py │ │ └── models.py └── pi_network │ ├── exceptions.py │ ├── serializers.py │ ├── client.py │ ├── models.py │ └── views.py ├── .whitesource ├── .gitignore ├── manage.py ├── LICENSE ├── docs ├── development_guide.md ├── api_reference.md └── architecture.md ├── tests ├── test_pi_network.py └── test_paymentx.py └── LICENCE.md /README.md: -------------------------------------------------------------------------------- 1 | # pitweetpay-integration 2 | Integration of Twitter PaymentX with Pi Network for seamless cryptocurrency transactions. 3 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Django==3.2.25 2 | djangorestframework==3.12.4 3 | psycopg2==2.9.1 4 | pytest==6.2.4 5 | pytest-django==4.4.0 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/paymentx/wsgi.py: -------------------------------------------------------------------------------- 1 | import os 2 | from django.core.wsgi import get_wsgi_application 3 | 4 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pitweetpay_integration.settings') 5 | 6 | application = get_wsgi_application() 7 | -------------------------------------------------------------------------------- /src/pi_network/exceptions.py: -------------------------------------------------------------------------------- 1 | # pi_network/exceptions.py 2 | class PiNetworkError(Exception): 3 | pass 4 | 5 | class UserNotFoundError(PiNetworkError): 6 | pass 7 | 8 | class TransactionNotFoundError(PiNetworkError): 9 | pass 10 | -------------------------------------------------------------------------------- /src/paymentx/settings.py: -------------------------------------------------------------------------------- 1 | PAYMENTX_API_KEY = "your_paymentx_api_key" 2 | PAYMENTX_API_SECRET_KEY = "your_paymentx_api_secret_key" 3 | PI_NETWORK_API_KEY = "your_pi_network_api_key" 4 | PI_NETWORK_REDIRECT_URL = "https://your-domain.com/pi_network/callback/" 5 | -------------------------------------------------------------------------------- /src/paymentx/__init__.py: -------------------------------------------------------------------------------- 1 | from .twitter import * 2 | from .exceptions import PaymentXError 3 | from .models import Payment, Transaction 4 | from .serializers import PaymentSerializer, TransactionSerializer 5 | from .views import PaymentListView, TransactionListView 6 | -------------------------------------------------------------------------------- /.whitesource: -------------------------------------------------------------------------------- 1 | { 2 | "scanSettings": { 3 | "baseBranches": [] 4 | }, 5 | "checkRunSettings": { 6 | "vulnerableCheckRunConclusionLevel": "failure", 7 | "displayMode": "diff", 8 | "useMendCheckNames": true 9 | }, 10 | "issueSettings": { 11 | "minSeverityLevel": "LOW", 12 | "issueType": "DEPENDENCY" 13 | } 14 | } -------------------------------------------------------------------------------- /src/paymentx/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from .paymentx.twitter.views import create_payment_request 3 | from .pi_network.views import pi_network_callback 4 | 5 | urlpatterns = [ 6 | path("create_payment_request/", create_payment_request, name="create_payment_request"), 7 | path("pi_network/callback/", pi_network_callback, name="pi_network_callback"), 8 | ] 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /src/paymentx/twitter/__init__.py: -------------------------------------------------------------------------------- 1 | from .client import PaymentXClient 2 | from .exceptions import PaymentXAPIError 3 | from .models import PaymentRequest, Payment, Transaction 4 | from .serializers import PaymentRequestSerializer, PaymentSerializer, TransactionSerializer 5 | from .views import ( 6 | CreatePaymentRequestView, 7 | PaymentRequestListView, 8 | PaymentRequestDetailView, 9 | PaymentListView, 10 | TransactionListView, 11 | ) 12 | -------------------------------------------------------------------------------- /src/pi_network/serializers.py: -------------------------------------------------------------------------------- 1 | # pi_network/serializers.py 2 | from rest_framework import serializers 3 | from .models import User, Transaction 4 | 5 | class UserSerializer(serializers.ModelSerializer): 6 | class Meta: 7 | model = User 8 | fields = ['id', 'name', 'email'] 9 | 10 | class TransactionSerializer(serializers.ModelSerializer): 11 | sender = UserSerializer() 12 | receiver = UserSerializer() 13 | 14 | class Meta: 15 | model = Transaction 16 | fields = ['id', 'sender', 'receiver', 'amount', 'created_at'] 17 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings') 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /src/paymentx/twitter/serializers.py: -------------------------------------------------------------------------------- 1 | from rest_framework import serializers 2 | from .models import PaymentRequest, Payment, Transaction 3 | 4 | class PaymentRequestSerializer(serializers.ModelSerializer): 5 | """Serializer for PaymentRequest model.""" 6 | class Meta: 7 | model = PaymentRequest 8 | fields = '__all__' 9 | 10 | class PaymentSerializer(serializers.ModelSerializer): 11 | """Serializer for Payment model.""" 12 | class Meta: 13 | model = Payment 14 | fields = '__all__' 15 | 16 | class TransactionSerializer(serializers.ModelSerializer): 17 | """Serializer for Transaction model.""" 18 | class Meta: 19 | model = Transaction 20 | fields = '__all__' 21 | -------------------------------------------------------------------------------- /src/paymentx/twitter/exceptions.py: -------------------------------------------------------------------------------- 1 | class PaymentXError(Exception): 2 | """Base exception for all PaymentX exceptions.""" 3 | pass 4 | 5 | class PaymentXAPIError(PaymentXError): 6 | """Exception raised when there is an error with the PaymentX API.""" 7 | def __init__(self, status_code, error_code, error_message): 8 | self.status_code = status_code 9 | self.error_code = error_code 10 | self.error_message = error_message 11 | 12 | class PaymentXValidationError(PaymentXError): 13 | """Exception raised when there is a validation error with the PaymentX API.""" 14 | def __init__(self, error_code, error_message): 15 | self.error_code = error_code 16 | self.error_message = error_message 17 | -------------------------------------------------------------------------------- /src/pi_network/client.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from .exceptions import PiNetworkAPIError 3 | 4 | class PiNetworkClient: 5 | def __init__(self, api_key): 6 | self.api_key = api_key 7 | self.base_url = "https://api.pi-network.com/v1" 8 | 9 | def _request(self, method, url, **kwargs): 10 | headers = { 11 | "Authorization": f"Bearer {self.api_key}", 12 | } 13 | kwargs["headers"] = headers 14 | response = requests.request(method, url, **kwargs) 15 | if response.status_code >= 400: 16 | raise PiNetworkAPIError(response.json()) 17 | return response.json() 18 | 19 | def get_user_balance(self, user_id): 20 | url = f"{self.base_url}/users/{user_id}/balance" 21 | return self._request("GET", url) 22 | 23 | # Other Pi Network API methods... 24 | -------------------------------------------------------------------------------- /src/pi_network/models.py: -------------------------------------------------------------------------------- 1 | # pi_network/models.py 2 | from django.db import models 3 | 4 | class User(models.Model): 5 | name = models.CharField(max_length=255) 6 | email = models.EmailField(unique=True) 7 | created_at = models.DateTimeField(auto_now_add=True) 8 | updated_at = models.DateTimeField(auto_now=True) 9 | 10 | def __str__(self): 11 | return self.name 12 | 13 | class Transaction(models.Model): 14 | sender = models.ForeignKey(User, on_delete=models.CASCADE, related_name='sent_transactions') 15 | receiver = models.ForeignKey(User, on_delete=models.CASCADE, related_name='received_transactions') 16 | amount = models.DecimalField(max_digits=10, decimal_places=2) 17 | created_at = models.DateTimeField(auto_now_add=True) 18 | 19 | def __str__(self): 20 | return f"{self.sender.name} -> {self.receiver.name}: {self.amount}" 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 KOSASIH 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/paymentx/twitter/client.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from .exceptions import PaymentXAPIError 3 | 4 | class PaymentXClient: 5 | def __init__(self, api_key, api_secret_key): 6 | self.api_key = api_key 7 | self.api_secret_key = api_secret_key 8 | self.base_url = "https://api.paymentx.com/twitter/v1" 9 | 10 | def _request(self, method, url, **kwargs): 11 | headers = { 12 | "Authorization": f"Bearer {self.api_key}", 13 | "X-PaymentX-Secret-Key": self.api_secret_key, 14 | } 15 | kwargs["headers"] = headers 16 | response = requests.request(method, url, **kwargs) 17 | if response.status_code >= 400: 18 | raise PaymentXAPIError(response.json()) 19 | return response.json() 20 | 21 | def create_payment_request(self, amount, currency, description, **kwargs): 22 | url = f"{self.base_url}/payment_requests" 23 | data = { 24 | "amount": amount, 25 | "currency": currency, 26 | "description": description, 27 | } 28 | data.update(kwargs) 29 | return self._request("POST", url, json=data) 30 | 31 | # Other PaymentX API methods... 32 | -------------------------------------------------------------------------------- /src/pi_network/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.views.decorators.csrf import csrf_exempt 3 | from .client import PiNetworkClient 4 | from .exceptions import PiNetworkAPIError 5 | 6 | @csrf_exempt 7 | def pi_network_callback(request): 8 | if request.method != "POST": 9 | return render(request, "pi_network/callback.html", {"error": "Invalid request method"}) 10 | 11 | try: 12 | pi_network_client = PiNetworkClient(api_key=settings.PI_NETWORK_API_KEY) 13 | pi_network_user_id = request.POST["user_id"] 14 | transaction_id = request.POST["transaction_id"] 15 | amount = float(request.POST["amount"]) 16 | currency = request.POST["currency"] 17 | except KeyError: 18 | return render(request, "pi_network/callback.html", {"error": "Missing required parameters"}) 19 | 20 | try: 21 | pi_network_client.confirm_transaction(transaction_id=transaction_id, amount=amount, currency=currency) 22 | # Update the payment request status in PaymentX 23 | # ... 24 | except PiNetworkAPIError as e: 25 | return render(request, "pi_network/callback.html", {"error": str(e)}) 26 | 27 | return render(request, "pi_network/callback.html", {"success": True}) 28 | -------------------------------------------------------------------------------- /docs/development_guide.md: -------------------------------------------------------------------------------- 1 | # Development Guide 2 | 3 | This document provides a guide for developers working on our system, including setup instructions, coding standards, and best practices. 4 | 5 | ## Setup 6 | 7 | - Install Dependencies 8 | - Install Node.js and npm 9 | - Install Python and pip 10 | - Install PostgreSQL and RabbitMQ 11 | - Install required packages using pip install -r requirements.txt 12 | 13 | ## Set up Environment 14 | 15 | - Create a new virtual environment using python -m venv myenv 16 | - Activate the virtual environment using source myenv/bin/activate 17 | - Set up environment variables using export DJANGO_SETTINGS_MODULE=myproject.settings 18 | 19 | ## Run the Application 20 | 21 | - Run the frontend using npm start 22 | - Run the backend API using python manage.py runserver 23 | - Run the message queue using rabbitmq-server 24 | 25 | # Coding Standards 26 | 27 | ## Python 28 | 29 | - Use 4-space indentation 30 | - Use descriptive variable names 31 | - Use docstrings for functions and classes 32 | - Follow PEP 8 guidelines 33 | 34 | ## JavaScript 35 | 36 | - Use 2-space indentation 37 | - Use descriptive variable names 38 | - Use JSDoc for functions and classes 39 | - Follow Airbnb JavaScript Style Guide 40 | 41 | ## HTML/CSS 42 | 43 | - Use semantic HTML5 elements 44 | - Use CSS preprocessors like Sass or Less 45 | - Follow CSS Guidelines 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /tests/test_pi_network.py: -------------------------------------------------------------------------------- 1 | # tests/test_pi_network.py 2 | import unittest 3 | from pi_network.exceptions import PiNetworkError 4 | from pi_network.models import User, Transaction 5 | from pi_network.serializers import UserSerializer, TransactionSerializer 6 | 7 | class TestPiNetwork(unittest.TestCase): 8 | def test_user_serializer(self): 9 | user = User(name='Alice', email='alice@example.com') 10 | serializer = UserSerializer(user) 11 | self.assertEqual(serializer.data, {'id': user.id, 'name': 'Alice', 'email': 'alice@example.com'}) 12 | 13 | def test_transaction_serializer(self): 14 | sender = User.objects.create(name='Alice', email='alice@example.com') 15 | receiver = User.objects.create(name='Bob', email='bob@example.com') 16 | transaction = Transaction.objects.create(sender=sender, receiver=receiver, amount=5.0) 17 | serializer = TransactionSerializer(transaction) 18 | self.assertEqual(serializer.data, {'id': transaction.id, 'sender': {'id': sender.id, 'name': 'Alice', 'email': 'alice@example.com'}, 'receiver': {'id': receiver.id, 'name': 'Bob', 'email': 'bob@example.com'}, 'amount': 5.0, 'created_at': str(transaction.created_at)}) 19 | 20 | def test_pinetwork_error(self): 21 | with self.assertRaises(PiNetworkError): 22 | raise PiNetworkError('Test PiNetworkError') 23 | 24 | if __name__ == '__main__': 25 | unittest.main() 26 | -------------------------------------------------------------------------------- /src/paymentx/twitter/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.views.decorators.csrf import csrf_exempt 3 | from .client import PaymentXClient 4 | from .exceptions import PaymentXAPIError 5 | 6 | @csrf_exempt 7 | def create_payment_request(request): 8 | if request.method != "POST": 9 | return render(request, "paymentx/create_payment_request.html", {"error": "Invalid request method"}) 10 | 11 | try: 12 | amount = float(request.POST["amount"]) 13 | currency = request.POST["currency"] 14 | description = request.POST["description"] 15 | pi_network_user_id = request.POST["pi_network_user_id"] 16 | except KeyError: 17 | return render(request, "paymentx/create_payment_request.html", {"error": "Missing required parameters"}) 18 | 19 | try: 20 | paymentx_client = PaymentXClient(api_key=settings.PAYMENTX_API_KEY, api_secret_key=settings.PAYMENTX_API_SECRET_KEY) 21 | payment_request = paymentx_client.create_payment_request( 22 | amount=amount, 23 | currency=currency, 24 | description=description, 25 | redirect_url=f"{settings.PI_NETWORK_REDIRECT_URL}/{pi_network_user_id}" 26 | ) 27 | except PaymentXAPIError as e: 28 | return render(request, "paymentx/create_payment_request.html", {"error": str(e)}) 29 | 30 | return render(request, "paymentx/create_payment_request.html", {"payment_request": payment_request}) 31 | -------------------------------------------------------------------------------- /tests/test_paymentx.py: -------------------------------------------------------------------------------- 1 | # tests/test_paymentx.py 2 | import unittest 3 | from paymentx.exceptions import PaymentXError 4 | from paymentx.models import Payment, Transaction 5 | from paymentx.serializers import PaymentSerializer, TransactionSerializer 6 | 7 | class TestPaymentX(unittest.TestCase): 8 | def test_payment_serializer(self): 9 | payment = Payment(amount=10.0, currency='USD', description='Test Payment') 10 | serializer = PaymentSerializer(payment) 11 | self.assertEqual(serializer.data, {'id': payment.id, 'amount': 10.0, 'currency': 'USD', 'description': 'Test Payment'}) 12 | 13 | def test_transaction_serializer(self): 14 | sender = User.objects.create(name='Alice', email='alice@example.com') 15 | receiver = User.objects.create(name='Bob', email='bob@example.com') 16 | transaction = Transaction.objects.create(sender=sender, receiver=receiver, amount=5.0) 17 | serializer = TransactionSerializer(transaction) 18 | self.assertEqual(serializer.data, {'id': transaction.id, 'sender': {'id': sender.id, 'name': 'Alice', 'email': 'alice@example.com'}, 'receiver': {'id': receiver.id, 'name': 'Bob', 'email': 'bob@example.com'}, 'amount': 5.0, 'created_at': str(transaction.created_at)}) 19 | 20 | def test_paymentx_error(self): 21 | with self.assertRaises(PaymentXError): 22 | raise PaymentXError('Test PaymentXError') 23 | 24 | if __name__ == '__main__': 25 | unittest.main() 26 | -------------------------------------------------------------------------------- /src/paymentx/twitter/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class PaymentRequest(models.Model): 4 | """Model representing a payment request.""" 5 | amount = models.DecimalField(max_digits=10, decimal_places=2) 6 | currency = models.CharField(max_length=3) 7 | description = models.CharField(max_length=255) 8 | redirect_url = models.URLField() 9 | payment_request_id = models.CharField(max_length=255, unique=True) 10 | created_at = models.DateTimeField(auto_now_add=True) 11 | updated_at = models.DateTimeField(auto_now=True) 12 | 13 | class Payment(models.Model): 14 | """Model representing a payment.""" 15 | payment_request = models.ForeignKey(PaymentRequest, on_delete=models.CASCADE) 16 | payment_id = models.CharField(max_length=255, unique=True) 17 | amount = models.DecimalField(max_digits=10, decimal_places=2) 18 | currency = models.CharField(max_length=3) 19 | status = models.CharField(max_length=255) 20 | created_at = models.DateTimeField(auto_now_add=True) 21 | updated_at = models.DateTimeField(auto_now=True) 22 | 23 | class Transaction(models.Model): 24 | """Model representing a transaction.""" 25 | payment = models.ForeignKey(Payment, on_delete=models.CASCADE) 26 | transaction_id = models.CharField(max_length=255, unique=True) 27 | amount = models.DecimalField(max_digits=10, decimal_places=2) 28 | currency = models.CharField(max_length=3) 29 | status = models.CharField(max_length=255) 30 | created_at = models.DateTimeField(auto_now_add=True) 31 | updated_at = models.DateTimeField(auto_now=True) 32 | -------------------------------------------------------------------------------- /docs/api_reference.md: -------------------------------------------------------------------------------- 1 | # API Reference 2 | 3 | This document provides a reference guide for the API endpoints and methods available in our system. 4 | 5 | ## Endpoints 6 | 7 | Users 8 | 9 | - GET /users: Retrieve a list of all users 10 | - GET /users/{id}: Retrieve a single user by ID 11 | - POST /users: Create a new user 12 | - PUT /users/{id}: Update a single user 13 | - DELETE /users/{id}: Delete a single user 14 | 15 | Payments 16 | 17 | - GET /payments: Retrieve a list of all payments 18 | - GET /payments/{id}: Retrieve a single payment by ID 19 | - POST /payments: Create a new payment 20 | - PUT /payments/{id}: Update a single payment 21 | - DELETE /payments/{id}: Delete a single payment 22 | 23 | Transactions 24 | 25 | - GET /transactions: Retrieve a list of all transactions 26 | - GET /transactions/{id}: Retrieve a single transaction by ID 27 | - POST /transactions: Create a new transaction 28 | - PUT /transactions/{id}: Update a single transaction 29 | - DELETE /transactions/{id}: Delete a single transaction 30 | 31 | ## Methods 32 | 33 | ### GET 34 | 35 | - Retrieve a list of resources or a single resource by ID 36 | 37 | ### POST 38 | 39 | - Create a new resource 40 | 41 | ### PUT 42 | 43 | - Update a single resource 44 | 45 | ## DELETE 46 | 47 | - Delete a single resource 48 | 49 | ## Request Headers 50 | 51 | - Content-Type: application/json 52 | - Authorization: Bearer 53 | 54 | ## Response Codes 55 | 56 | - 200 OK: Request successful 57 | - 400 Bad Request: Invalid request 58 | - 401 Unauthorized: Unauthorized access 59 | - 404 Not Found: Resource not found 60 | - 500 Internal Server Error: Server error 61 | -------------------------------------------------------------------------------- /docs/architecture.md: -------------------------------------------------------------------------------- 1 | # Architecture Overview 2 | 3 | This document provides an overview of the architecture of our system, including the components, interactions, and technologies used. 4 | 5 | ## Components 6 | 7 | - Frontend 8 | - Built using React and TypeScript 9 | - Responsible for rendering the user interface and handling user input 10 | - Communicates with the backend API to retrieve and send data 11 | 12 | ## Backend API 13 | 14 | - Built using Django and Python 15 | - Responsible for handling business logic, data storage, and retrieval 16 | - Exposes a RESTful API for the frontend to interact with 17 | 18 | ## Database 19 | 20 | - Built using PostgreSQL 21 | - Responsible for storing and retrieving data 22 | - Interacts with the backend API to store and retrieve data 23 | 24 | ## Message Queue 25 | 26 | - Built using RabbitMQ 27 | - Responsible for handling asynchronous tasks and message passing between components 28 | - Interacts with the backend API to send and receive messages 29 | 30 | ## Interactions 31 | 32 | ### User Interaction 33 | 34 | - The user interacts with the frontend, which sends requests to the backend API 35 | - The backend API processes the requests and returns responses to the frontend 36 | - The frontend renders the responses to the user 37 | 38 | ### API Interaction 39 | 40 | - The frontend sends requests to the backend API to retrieve or send data 41 | - The backend API processes the requests and returns responses to the frontend 42 | - The frontend renders the responses to the user 43 | 44 | ### Database Interaction 45 | 46 | - The backend API interacts with the database to store and retrieve data 47 | - The database stores and retrieves data as requested by the backend API 48 | 49 | ### Message Queue Interaction 50 | 51 | - The backend API sends messages to the message queue to handle asynchronous tasks 52 | - The message queue processes the messages and sends responses to the backend API 53 | - The backend API processes the responses and returns results to the frontend 54 | 55 | ### Technologies 56 | 57 | - Frontend: React, TypeScript, Webpack 58 | - Backend API: Django, Python, PostgreSQL 59 | - Database: PostgreSQL 60 | - Message Queue: RabbitMQ 61 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | PiOS License 2 | 3 | Copyright (C) 2024 KOSASIH 4 | 5 | Permission is hereby granted by the application software developer (“Software Developer”), free 6 | of charge, to any person obtaining a copy of this application, software and associated 7 | documentation files (the “Software”), which was developed by the Software Developer for use on 8 | Pi Network, whereby the purpose of this license is to permit the development of derivative works 9 | based on the Software, including the right to use, copy, modify, merge, publish, distribute, 10 | sub-license, and/or sell copies of such derivative works and any Software components incorporated 11 | therein, and to permit persons to whom such derivative works are furnished to do so, in each case, 12 | solely to develop, use and market applications for the official Pi Network. For purposes of this 13 | license, Pi Network shall mean any application, software, or other present or future platform 14 | developed, owned or managed by Pi Community Company, and its parents, affiliates or subsidiaries, 15 | for which the Software was developed, or on which the Software continues to operate. However, 16 | you are prohibited from using any portion of the Software or any derivative works thereof in any 17 | manner (a) which infringes on any Pi Network intellectual property rights, (b) to hack any of Pi 18 | Network’s systems or processes or (c) to develop any product or service which is competitive with 19 | the Pi Network. 20 | 21 | The above copyright notice and this permission notice shall be included in all copies or 22 | substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 25 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 26 | AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, PUBLISHERS, OR COPYRIGHT HOLDERS OF THIS 27 | SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL 28 | DAMAGES (INCLUDING, BUT NOT LIMITED TO BUSINESS INTERRUPTION, LOSS OF USE, DATA OR PROFITS) 29 | HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 30 | TORT (INCLUDING NEGLIGENCE) ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 31 | OR OTHER DEALINGS IN THE SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 32 | 33 | Pi, Pi Network and the Pi logo are trademarks of the Pi Community Company. 34 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "main" ] 17 | pull_request: 18 | branches: [ "main" ] 19 | schedule: 20 | - cron: '20 0 * * 0' 21 | 22 | jobs: 23 | analyze: 24 | name: Analyze (${{ matrix.language }}) 25 | # Runner size impacts CodeQL analysis time. To learn more, please see: 26 | # - https://gh.io/recommended-hardware-resources-for-running-codeql 27 | # - https://gh.io/supported-runners-and-hardware-resources 28 | # - https://gh.io/using-larger-runners (GitHub.com only) 29 | # Consider using larger runners or machines with greater resources for possible analysis time improvements. 30 | runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} 31 | timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} 32 | permissions: 33 | # required for all workflows 34 | security-events: write 35 | 36 | # required to fetch internal or private CodeQL packs 37 | packages: read 38 | 39 | # only required for workflows in private repositories 40 | actions: read 41 | contents: read 42 | 43 | strategy: 44 | fail-fast: false 45 | matrix: 46 | include: 47 | - language: python 48 | build-mode: none 49 | # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' 50 | # Use `c-cpp` to analyze code written in C, C++ or both 51 | # Use 'java-kotlin' to analyze code written in Java, Kotlin or both 52 | # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both 53 | # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, 54 | # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. 55 | # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how 56 | # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages 57 | steps: 58 | - name: Checkout repository 59 | uses: actions/checkout@v4 60 | 61 | # Initializes the CodeQL tools for scanning. 62 | - name: Initialize CodeQL 63 | uses: github/codeql-action/init@v3 64 | with: 65 | languages: ${{ matrix.language }} 66 | build-mode: ${{ matrix.build-mode }} 67 | # If you wish to specify custom queries, you can do so here or in a config file. 68 | # By default, queries listed here will override any specified in a config file. 69 | # Prefix the list here with "+" to use these queries and those in the config file. 70 | 71 | # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 72 | # queries: security-extended,security-and-quality 73 | 74 | # If the analyze step fails for one of the languages you are analyzing with 75 | # "We were unable to automatically build your code", modify the matrix above 76 | # to set the build mode to "manual" for that language. Then modify this step 77 | # to build your code. 78 | # ℹ️ Command-line programs to run using the OS shell. 79 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 80 | - if: matrix.build-mode == 'manual' 81 | shell: bash 82 | run: | 83 | echo 'If you are using a "manual" build mode for one or more of the' \ 84 | 'languages you are analyzing, replace this with the commands to build' \ 85 | 'your code, for example:' 86 | echo ' make bootstrap' 87 | echo ' make release' 88 | exit 1 89 | 90 | - name: Perform CodeQL Analysis 91 | uses: github/codeql-action/analyze@v3 92 | with: 93 | category: "/language:${{matrix.language}}" 94 | --------------------------------------------------------------------------------