In Citadels, when do characters get the extra gold from their colour?
You can trigger the bonus before or after building. This means you can either build a building with your existing gold, then trigger the gold collection, OR trigger the gold collection, and use that gold to pay for a new building.

What you cannot do is gain some of the gold, build the building, and gain the extra gold from building that building.

To answer the edit, you always get the merchant's one gold before building.  You can still choose to take his 1 gold per green either before or after building.