As you can see from the diagram on the Documentation page of the Arduino WiFi Shield:
https://store.arduino.cc/usa/arduino-wifi-shield
The SD card's SS pin is connected to pin 4 of your Arduino board. So try connecting the keypad to a pin other than pin 4 and update your code accordingly. You should also be sure your code uses SD.begin(4) to set pin 4 as the SD card SS pin. If that doesn't solve your problem then you probably need to provide some information on what sort of hardware you have connected for the barcode scanner part of the project.
You will also notice that pin 7 of your Arduino board is used for "handshake" with the shield, which is likely why the original problem was solved when you changed the keypad connection from pin 7 to pin 9.
