There is no orphan in this book. The main character is a boy on his own who chose to leave home to be a shepherd.
The boy, Santiago, received gold from several places.
When the boy tells his father that he wants to leave home to be a shepherd, his father gives him three pieces of Spanish gold which he had found while plowing his fields, as part of his inheritance.
When the boy is in the desert trying to get the Pyramids, he sees an omen that attackers are coming to the oasis. The highest of all the chieftains at the oasis tells the boy that in payment for this warning (if he is correct), the boy will receive a gold piece for every 50 enemies they kill in the battle. At the end of the battle, the boy is given a bag of 50 gold coins.
Of course, when the boy finds the treasure at the end, he uncovers all kind of gold and coins.