I have written a couple of examples in the past that you can use as a reference or a starting point.
My samples are attached (to save space I removed the sample INDD docs that were used by the samples)
Some things to remember:
1. If you want to use a Barcode font approach you need to take care of the encoding of the characters to the ones that the Barcode font actually uses and should make sure the font is available to your RIP.
2. With PGE, you end up with many copies of the PGE code in the output stream so you should try to reduce the size of the PGE EPS file. In the zip file you will find some instructions about this as well).
Notes on my samples:
1. My example use a free library written by Terry Burton from the UK (link to his library:
https://code.google.com/p/postscriptbarcode/) that can generate many types of barcodes, both linear and 2D. If you take this approach be sure to download a recent copy of the library.
2. You can see how I divided the PGE file into two parts, one only gets into the output stream once, the other gets embedded each time the PGE is drawn. This approach is in order to decrease the "footstamp" of the PGE.
3. There's an option to instruct XMPie not to copy all the ADORs into the PGE each time, but rather only the one / ones required by the PGE. More details are in the technical note in the attached zip file. My samples were created without this approach, but can easily be modified to use it.
Good luck