Was ransoming of captives during the middle ages purely the realm of the nobility or could the commoners get in on the action? Also during a battle were all ransoms collected under the "general" or was it more loose and a matter for individuals?
Like say a group of pike-man downed a knight mid battle, could they ransom them or would it go to their liege lord or above?
From the sources I have read, it seems to either be directly stated or heavily inferred that commoners were more than capable of taking a noble POW, but often lacked the ability to follow through with the negotiations and ransoming.
To get right to your questions, it was not purely the realm for the nobility to do the capturing of nobles, but often heavily favored for them to do the negotiating and actual ransoming. Properly keeping a prisoner is expensive. They require care and guard that would be expensive for a commoner (even though commoners were often in groups). There was also a level of hospitality expected of POWs befitting of their station. It wasn't seen as honorable for a duke to be kept in rags and tied to a tree (akin to Jamie Lannister in Game of Thrones). That isn't to say it didn't happen.
Furthermore, the negotiations could take days to weeks to fulfill. Commoners didn't necessarily have the ability to properly negotiate (illiteracy, foreign languages, expenses in travel/communicating etc) the ransom and release unless the exchanged rather soon. There was monetary and political factors that often were involved in a random. It could take weeks for a family to muster the demands required, perhaps even longer if they needed to mortgage land.
Additionally, commoners would be out of the loop as far as political maneuverings regarding what the upper classes had in mind. Their liege might have certain VIP POW prisoner exchanges in mind, or may not desire some nobles to be released so quickly (keeps them out of the war, and may keep their family from committing more to a cause that endangers their important members).
The end result was often for example an English commoner would sell a French noble POW to their own English nobility; or would agreed to be paid a portion of their ransom. Additionally, the context of the war would change the sensitivity and situation of the negotiations. A crusader war in the Levant would be conduct differently than regional war between German states, or a dynastic feud such as the Hundred Years War.
A famous, albeit outlier example would be King John II of France's capture by the English in late 1356 at the Battle of Poitiers. It took four years to negotiate his ransom of something like 4 million francs and 83 prisoners to be exchanged. This is an extreme example because of his rank and the political situation; however, as most captured would simply nobles and not royals.
Another case was Bertrand du Guesclin's captured by the French in 1364, which was 100,000 francs. As you can see, these are astronomical sums for a commoner and the handling of it was for the most part very difficulty for them to succeed in.
An example of more large scale negotiations would be the siege and fall of Jerusalem in 1187, where Saladin negotiated the surrender from Balian of Ibelin. Part of the deal was several thousand in coins were paid to Saladin as ransoms for many of the city's inhabitants. Furthermore, safe passage to crusader held territory was also part of the deal. Saladin on his own accord allowed many young and elderly to be released without ransom and unharmed. However, some thousands were unable to secure their own ransom and paid via enslavement.
Nobles actually preferred to capture each other because of the financial gain, reputation, and hope for equal chivalric treatment should they be captured themselves. I want to make a little note on chivalry here that for the most part, battlefield chivalry was between the upper classes. Knights weren't necessarily chivalrous towards enemy commoners. Furthermore, due to their martial training and better armor it was more likely a noble would be captured than killed.
I can't recall the specific source, but I do remember once reading over about a group of angry peasants holding a minor noble captive and they were trying to deal with things themselves, refusing to hand him over to their sides higher command. The way it was written did not make this situation seem unique, but did make it seem as if their own liege's did not see it as ideal. It was basically akin to as if a group of highwaymen bandits pounced upon a traveling noble and were trying to figure out how they turn him into money and not a noose (although the context was a battlefield captive, not a robbery).
However, when it came to commoners being taken prisoner by other commoners, things were less formal and sources and chroniclers often paid a bit less attention to them...mostly just reducing them to a number. This could be handled smaller scale but again change if their liege didn't want to be releasing enemy combatants without considering the grand scheme of things. A commoner was often ransomed by their friends/family retrieving a hidden sack of coin, or pooling their resource to buy back their friends. Otherwise, they would be at the mercy of the higher powers in a more grand ransom negotiation (such as large scale prisoner exchanges or payments). In short, if one survived capture as a commoner (or even as a besieged non-combatant), they were very much at the whim and will of the nobility.
Sources to follow.
Edit: some proofreading.