def buy_cart(customer_obj, cart_obj): products = cart_obj.get_cart_items() total_price = cart_obj.get_total_price() print("Total price to be paid " + str(total_price)) print("Payment details : ") card_type = input("Enter card type : ") card_num = input("Enter card number : ") payment_obj = Payment(customer_obj.get_id(), total_price, card_type, card_num) success = customer_obj.buy_products_in_bulk(products, payment_obj) if success: print("Shipment successfully initiated. Payment reference ID = " + str(payment_obj.get_id())) else: print("Some problem occurred while transaction")
def buy_product(customer_obj): view_products(customer_obj) print() product_id = int(input("Enter the id of the product to buy : ")) product_obj = database.get_product(product_id) if product_obj is None: print("Enter a valid product ID!") return quantity = int(input("Enter the quantity : ")) price = product_obj.get_price() * quantity print("Total price to be paid " + str(price)) print() print("PAYMENT DETAILS") card_type = input("Enter card type : ") card_num = input("Enter card number : ") payment_obj = Payment(customer_obj.get_id(), price, card_type, card_num) success = customer_obj.buy_product(product_obj, payment_obj, quantity) if success: print("Shipment successfully initiated. Payment reference ID = " + str(payment_obj.get_id())) else: print("Some problem occurred while transaction")