Given the following URL (working, try it!)
https://select-test.wp3.rbsworldpay.com/wcc/purchase?instId=151711&cartId=28524¤cy=GBP&am
Try using %0A in the URL, just like you've used %20 instead of the space character.
late to the party, but if anyone comes across this, javascript has a encodeURI method
Try to replace the \n with %0A just like you have spaces replaced with %20.
Use %0A (URL encoding) instead of \n (C encoding).