Maran (Siman 307:3) rules that it is prohibited to give a non-Jew money before Shabbat with instructions to buy something for the Jew on Shabbat. Hacham David (Halacha Berura p. 165, Vol. II Amira L’Akum) adds that even if the Jew did not give him any money before Shabbat, but told the non-Jew to go specifically on Shabbat and either buy or sell something on his behalf, it is prohibited.
However, the Shulhan Aruch permits telling the non-Jew, "Buy something for yourself on Shabbat, and if I need it, I’ll buy it from you after Shabbat." Since the non-Jew is not formally buying or selling for the Jew, it is permitted, even though the non-Jew understands the Jew intends to buy it from him after Shabbat. The Mishna Berura (R. Yisrael Meir Kagan, Poland 1838-1933) adds that even if the Jew guarantees that he will buy it from the non-Jew after Shabbat. This is permitted as long as the non-Jew uses his own money to purchase it.
In the next Halacha, 307:4, Maran rules that it is permissible to give the non-Jew money on Erev Shabbat to buy or sell on his behalf, so long as he is careful not to tell him to buy the item specifically on Shabbat. Even if he does decide to buy or sell on behalf of the Jew on Shabbat, it is considered his own decision, and he is not acting as the Jew’s agent. However, if Shabbat is the market day, even if the Jew does not specify to buy or sell on Shabbat, it is prohibited, since he could only perform the transaction specifically on Shabbat.
There is one more very important condition to this leniency: The non-Jew must be being paid for his services as a "Kablan," and be given a fixed price for the task.
It is prohibited to instruct a non-Jew to buy or sell for a Jew on Shabbat. However, he may be told to buy it for himself on Shabbat, and the Jew will buy it afterward. Alternatively, The Jew may instruct him to buy or sell on his behalf, without specifying Shabbat. Even if he did do it on Shabbat, it is permitted, as long as he was paid a fixed price for his services.