A couple things were not working for me. The Payment method was the true name instead of the alias thats configured as the name and the currency wasn't being set for host only domains.
I moved global $currency; to the beginning of the function then within both While() statements added:
$currency=getCurrency($data['userid']);
$paymentmethod = $data["paymentmethod"];
$paymentmethod = $gatewaysarray[$paymentmethod];
And replaced both $data["paymentmethod"] with $paymentmethod