Okay, speaking with Eric offline (much appreciated!), I got it compiled and working.
1) there are a couple of typos in the script. Syx.Functions = Sys.Functions and UserDefindedFunctions = UserDefinedFunctions
2) You need to add "References" in the Solution Explorer in Visual Studio/SSDT/BIDS. I added System, System.Data, and System.Xml (you check them on the list, then OK).
Once I did that, I was able to Build/Compile/Publish the code to my database and call the procedure. Eric, this thing is awesome. Thanks!
1)@orderby needs to be called thusly:
set @orderBy = 'order by PayMethod'
2) Remember to insert into #temp!
3) The pivot column can't ever be null. Eric suggested adding it to the WHERE clause, aka "where mypivotcolumn is not null"