The function that you are looking for have a specific name.
When you have a T1 ( I am not too familiar with E1), together with the call you get ANI (that is the number of the person calling you).
Since you are in a prepaid calling card , the ANI is not important, you do not care where they are calling you from.
The other piece of information that you get is the DIALED number. That is what number the caller dialed to call you. Is is used when you have a gateway with local phone numbers and also a 1800 number directed to the same ports.
Since you want to charge extra to the guy using the 1800 (toll free on the U.S.), you use the dialed number to charge that call a diferent rate.
Most half decent billing system will be able to apply diferent rates based on the DIALED number.