Example: Payment Program
Last updated
Last updated
We have two Python modules:
orders.py – Handles order creation.
payments.py – Processes payments.
When an order is placed, it sends the order details to the payment module for processing.
payments
Modulepayments.py
def process_payment(order_id, amount):
print(f"Processing payment of ${amount} for Order {order_id}")
return f"Payment for Order {order_id} successful"
orders
Moduleorders.py
from payments import * #Import the payments module
def place_order():
order_id = 101
amount = 50.00
confirmation = payments.process_payment(order_id, amount) #Integration happens here
print
Processing payment of $50.0 for Order 101
Payment for Order 101 successful