Build a Simple Payment App in Python | 6-Minute OOP Project for Beginners 💰

Create a Python payment app using OOP! Add, send, and view balance easily. Perfect 2-minute project for beginners. #Python #Coding #DomeBytes

💰 Build a Simple Payment App in Python (OOP Project) – Step-by-Step Guide

Python payment app with OOP - DomeBytes tutorial

You’ve learned Python basics, and you’ve built a few simple scripts. But now you want to understand Object-Oriented Programming (OOP) — the style that real-world apps use. What better way than building a payment app that sends and receives money?

In this tutorial, we’ll create a console-based payment system called PythonPay. You’ll learn how to use classes, objects, and methods to manage user balances, add money, and transfer funds between accounts. It’s beginner-friendly, takes only a few minutes to code, and gives you a solid OOP foundation.

If you’re new to Python, start with our Python programming guide for beginners before jumping into OOP.


What You’ll Learn From This Project

  • How to define a Python class with an __init__ constructor
  • Creating methods like show_balance(), add_money(), and send_money()
  • Working with multiple objects (users) that interact with each other
  • Building an interactive menu loop for a console app
  • Basic input validation (checking for positive amounts and sufficient balance)

These concepts are the same ones used in real payment apps like Google Pay or PhonePe — just scaled down. Master them here, and you’ll be ready for bigger projects.


Why Use OOP for a Payment App?

Without OOP, you’d store balances in separate variables and write many if-else statements to manage transfers. That becomes messy fast. With OOP, each user is an object that contains their own data (balance, name) and actions (send, add). The code is cleaner, reusable, and easier to extend.

Real‑world example: When you send money on a banking app, each account is an object. The “send money” method checks the sender’s balance, deducts it, and adds it to the receiver — exactly what we’re building here.


Full Python Code for the Payment App

print("💰 Welcome to PythonPay - Simple Payment App 💰")

class User:
    def __init__(self, name, balance=0):
        self.name = name
        self.balance = balance

    def show_balance(self):
        print(f"\n💳 {self.name}'s Balance: ₹{self.balance}")

    def add_money(self, amount):
        if amount > 0:
            self.balance += amount
            print(f"✅ ₹{amount} added successfully!")
        else:
            print("❌ Invalid amount!")

    def send_money(self, receiver, amount):
        if amount <= 0:
            print("❌ Invalid amount!")
        elif self.balance < amount:
            print("⚠️ Insufficient balance!")
        else:
            self.balance -= amount
            receiver.balance += amount
            print(f"✅ Sent ₹{amount} to {receiver.name}")

# Creating two user objects
user1 = User("Amal", 500)
user2 = User("Rahul", 300)

def menu():
    print("\n1️⃣ Show Balance\n2️⃣ Add Money\n3️⃣ Send Money\n4️⃣ Exit")

while True:
    menu()
    choice = input("Select an option: ")

    if choice == '1':
        user1.show_balance()
    elif choice == '2':
        amt = int(input("Enter amount to add: ₹"))
        user1.add_money(amt)
    elif choice == '3':
        amt = int(input(f"Enter amount to send to {user2.name}: ₹"))
        user1.send_money(user2, amt)
    elif choice == '4':
        print("👋 Thank you for using PythonPay!")
        break
    else:
        print("❌ Invalid option, try again!")

Step-by-Step Explanation

1. The User Class

We define a User class with a constructor __init__ that takes name and an optional balance (default 0). Each user object stores its own name and balance.

2. Methods (Actions)

  • show_balance() – Prints the current balance.
  • add_money(amount) – Adds a positive amount to the balance.
  • send_money(receiver, amount) – Checks if amount is valid and balance sufficient; then deducts from self and adds to receiver.

3. Creating Users

user1 = User("Amal", 500) creates an object named Amal with ₹500. user2 = User("Rahul", 300) creates Rahul with ₹300.

4. Interactive Menu Loop

The while True loop displays options and calls the appropriate method based on user input. Option 4 breaks the loop, exiting the app.

For another OOP project, try building a coffee ordering app — it follows a similar structure.


How to Extend This Project (Real‑World Use Cases)

Once you understand the basics, try adding these features:

  • Multiple users with login: Store users in a dictionary and authenticate with a PIN before transactions.
  • Transaction history: Keep a list of all sends and adds for each user.
  • Save data to a file: Use JSON or CSV to persist balances after the program closes.
  • Add a GUI: Turn this console app into a desktop app using Tkinter or PyQt.
  • Currency conversion: Add support for different currencies (USD, EUR, etc.).

If you're interested in file handling, check out our guide on recovering data from corrupted memory cards — it covers how data is stored and retrieved at a low level.


Common Beginner Mistakes & Fixes

  • Forgetting self in methods: Every method inside a class must have self as the first parameter. Otherwise Python won't know which object to use.
  • Not converting input to integer: input() returns a string. Use int() or float() for amounts.
  • Modifying the wrong object: In send_money(), we deduct from self.balance and add to receiver.balance. A common mistake is to deduct twice from the sender.
  • Indentation errors: All code inside the class must be indented consistently (4 spaces per level).

Video Tutorial (Watch & Code Along)

👉 Full article and code: DomeBytes Payment App Page


Frequently Asked Questions (FAQ)

1. Can I add more than two users?

Absolutely. Just create more objects: user3 = User("Priya", 1000). You'll also need to modify the menu to let the user choose who to send money to — for example, using a list of users and selecting by index.

2. Why does it say “invalid amount” when I enter a negative number?

Because we added validation: if amount > 0. In real payment apps, you cannot deposit or send negative money. That's good practice.

3. Can I run this on my phone?

Yes! Use Pydroid 3 (Android) or Pythonista (iOS). The code is pure Python and works perfectly in terminal‑based apps.

4. How do I make the program remember balances after I close it?

You need to save data to a file. Use json or pickle to store user objects, then load them when the program starts. This is an intermediate topic — start with our file handling basics.

5. Is this project good for a college assignment?

Yes, it demonstrates OOP concepts clearly. Many teachers ask for a “bank account” or “payment system” project. Add comments, a report, and maybe a simple GUI to impress.


Related Posts You Might Like


Final Thoughts

You’ve just built a working payment app in Python using OOP. It may be simple, but the structure is exactly what you’d use in larger projects. The User class can be extended to include phone numbers, transaction limits, or even a database backend.

Keep practicing: try adding a third user, implement a “transfer history” log, or build a simple GUI. Every small improvement teaches you something new. And if you get stuck, the DomeBytes YouTube channel has step‑by‑step tutorials.

Subscribe for more Python projects and happy coding!

About the author

AMAL AJI
Web wizard

Post a Comment

💡 Got a question or feedback about this post? Drop your comment below! We review all messages before publishing to keep the discussion clean and useful.