Simulate a UPI-style payment system using a Bash script that:
- Accepts the receiver’s name and amount as arguments
- Displays a list of popular payment methods (e.g., GPay, PhonePe, etc.)
- Prompts the user to select one
- Uses functions, arrays, and case logic to simulate payment processing
- Displays a confirmation message with emoji ✨
-
Make the script executable:
chmod +x mock_pay.sh
-
Run the script with receiver name and amount:
./mock_pay.sh Ravi 250
-
Follow the on-screen instructions to pick a payment method.
👋 Welcome to Mock UPI Bash App!
Paying ₹250 to: Ravi
🧾 Available Payment Methods:
1. PhonePe
2. GPay
3. Paytm
4. AmazonPay
5. BHIM UPI
💳 Choose a payment method [1-5]: 2
🔐 Initiating payment of ₹250 to Ravi via GPay...
⌛ Processing...
✅ Payment Successful! Thank you for using GPay 🙏
Feature | Purpose |
---|---|
declare -a |
Store multiple payment methods in array |
$1 , $2 |
Accept command-line arguments |
functions |
Encapsulate logic like simulate_payment() |
read -p |
User input for method choice |
case , if |
Validate and branch logic |
sleep |
Simulate real-time delay in response |
- Add fake UPI ID entry + OTP screen using
$RANDOM
- Introduce a 10% random chance of “Transaction Failed ❌”
- Log all successful payments to a
transactions.log
file - Add difficulty levels: prepaid wallet, credit card, UPI
Because it's fun, contextual (India-based UPI), and teaches real scripting concepts:
- CLI apps
- Argument parsing
- User interaction
- Basic stateful logic
“This is how we teach core scripting — with real-life stuff students already use daily.” 🇮🇳