He then put the credit codes into his phone from the pictures he had taken.
Judge Anthony Halpin said the theft showed "very sharp practice" and the manner in which Rostas stole the phone credit was "nothing short of Dickensian opportunism".
The defendant, of Carrigwood in Firhouse, admitted before Tallaght District Court to two counts of theft.
The incident took place at the Spar shop, Grove Road in Knocklyon on September 19 and September 24 last year.
Garda Rossa Smith said Rostas entered the shop and asked for €20 mobile phone credit, which was placed on the counter.
Gda Smith said Rostas then distracted the shop assistant by asking her for cigarettes.
When her back was turned he took a picture of the phone credit number with his phone.
Gda Smith said Rostas did this a second time, and then made an excuse that he had forgotten his wallet and walked out of the shop.
He later keyed in the credit into his phone, reading the credit code from the picture he had taken.
Gda Smith said Rostas was identified from CCTV footage, and was also traced back to the mobile phone, which was registered in his name.
The court heard that Rostas had entered the shop a second time and stole €20 credit.
A total of €60 mobile phone credit was stolen.
Judge Halpin criticised the underhand nature of the crime, saying Rostas has previous theft-related convictions.
Rostas was sentenced to five months in prison, suspended for two years.