Assalamualaikum,
Let’s say I am an online retailer and own my own online store and sell office supplies.
I display the products on my website or on eBay and the customer browses my online store and places an order. I don’t keep inventory so I just route the order directly to the wholesaler or a manufacturer, who then ship the goods to the customer.
الجواب وبالله التوفيق
The first situation as per your question is that something which is not in a person’s possession (i.e. they do not have the ownership of it), in this case it is impermissible to sell it. It has been mentioned in a hadith of Rasulullah Sallallaho Alyhi Wasallam:
(لا تبع ما لیس عندک (ترمذی شریف، باب ما جاء فی کراھیۃ بیع ما لیس عندہ
Translation: Do not perform (business) transaction on something that you do not possess (even when that thing is available in the open market).
The second situation as per your question will be that of a dallal(i.e. broker). In this situation a middle man performs an agreement with both the seller and the buyer that he will help them sell and buy a product and that he will charge a fees on these transactions. This situation is considered permissible. Inherently even this condition is not correct, however the fuqahah have found a provision for its use due to the conventionality of this action and it being exigency.
(سئل محمد بن سلمۃ عن اجرۃ السمسار و نقال او جوانہ لا با ءس بہ وان کان فی الاصل فاسد الکثرۃ التعامل وکثیر من ھذا غیر جائز فجوزہ لحاجۃ الناس (حاشیہ فتاوی محمودیہ ، ص ۲۸۶، ج۲۵، بحوالہ شامی
واللہ اعلم بالصواب