You don't. Apple does not give out codes. iPhones do not use unlock codes.
If the iPhone is locked to MetroPcs only they can unlock it.
The person you bought it from would need to request the unlock to MetroPCS since they would have been MetroPCS clients and can provide the info MetroPCS requires to unlock.
https://www.metropcs.com/terms-conditions/phone-unlock-policy.html
How to unlock your iPhone - Apple Support
@Kappy, I don't believe Activation Lock is the issue here, rather Carrier Lock.