A2B: Quick start guide to wholesale with A2Billing
This guide is aimed at the SysAdminMan A2B100 template. More details about this template can be found here – http://sysadminman.net/a2billing-hosting.html
In this guide I am going to create an A2Billing wholesale account that could be used to sell SIP termination. I’ll be using VOIP.MS as my call provider.
SETTING UP AN OUTBOUND TRUNK
First we need to create an outbound call trunk. This will be used to ultimately terminate the call. See here for setting up a trunk in A2Billing – http://sysadminman.net/blog/2011/a2b100-setting-up-a-trunk-in-a2billing-3089
SETTING UP A RATECARD/CALLPLAN
Before starting we want to make sure that the base currency in A2Billing is set to the currency that we are going to have our ratecards in. VOIP.MS are in USD so I’m going to go to SYSTEM SETTINGS, Global List, Global and change “base_currency” to USD.
Next we need to create a call plan and rate card. In A2Billing a rate card holds the rate cost for dialling a particular number. That rate card is assigned to a call plan. The call plan is then assigned to a customer. Each call plan can include many rate cards. Sounds complicated but is easier once you start playing with it.
The best way to create a rate card is to import a rate file from your provider. I wrote a script to do this automatically (see here), but here we’re going to manually download and import the file.
On the VOIP.MS website we go to “Rates” and “Download CSV”. You should see the screen below –
Click GO and right click on the download link and save the file somewhere.
A2Billing requires that the first 3 columns in the CSV file are in a particular order before we can import it. These need to be “dial prefix”, “destination”, “selling rate”. Unfortunately our voip.ms CSV is not in this order.
To change the order of the columns I’m going to use CSVed, a free program you can find here – http://download.cnet.com/CSVed/3000-2351_4-52868.html. I would recommend not using Excel doesn’t save CSV files very well.
In our CSV the “dial prefix” is in column 3 so we need to move that to column 1, easy with CSVed. Load the file then at the bottom of the screen select the “Column Edit” tab. Then move column 3 to column 1. We also need to move the “selling rate” which is in column 4 to column 3.
We also want to copy the rate (column 3) to column 4 as we will use this value twice (once for the buy rate and once for the sell rate). So you should end up with a file looking something like this –
What you need to move will depend on your providers CSV file. You can also import other fields such as the billing duration, connection charge, etc.
Save the edited file but save it with the extension .txt. Loading files called .csv in to A2Billing can fail in firefox.
Now we need to create a blank rate card in A2Billing to import these rates in to. Select RATES, RateCards, Add RateCard.
Give the RateCard a name, I always include the date I created it in the name. The RateCard will default to use the trunk we created earlier –
Now we are going to import the ratecard so choose RATES, Import.
Choose the ratecard and the trunk you created earlier. The first 3 fields to import are fixed for us. I’m just going to add “buyrate” as an addition field to import. Select the CSV file to import (that has the .txt extension) and select Import Ratecard –
You should now see a sample rate that will be imported. If you don’t, or if it looks incorrect, there is something wrong with your CSV file –
So that gives us a rate card, but with the buy and sell rate the same. Not very good for making a profit! I’m going to use Batch Update to add 20% to my sell rate. Select the menu RATES, Rates and then click on Batch Update. Ensure you have only the rates you want to modify select when you do this. Tick “sellrate” and select add 20% as shown below –
Now we just need to create a Call Plan and assign the new ratecard to it. Select RATES, Call Plan and Add Callplan. I’m going to select Yes to remove Inter Prefix as my rates do not have the international prefix on the (00, 001, etc) so when matching the rate card I want the number passed without any international prefix the customer may have dialled –
Next, and this is a step many people miss, you need to go in to the Call Plan and assign the rate card to it –
CREATING A SIP CUSTOMER
Now that we have our rates in place we just need to create a SIP customer.
From the CUSTOMERS, Add:Search screen choose Add Customer.
At the very least enter a Balance, Last Name, First Name, Time Zone, and ensure Create SIP Config is set to Yes. The customer will be assigned to the only call plan, that we created earlier –
Now if we go back in to that customers account we can click on “GO TO CUSTOMER ACCOUNT”. That will log us in to the A2Billing customer portal as that customer. Then click on SIP/IAX INFO and we will see the connection details the customer should use when setting up their trunk to us –
The VPSIPADDRESS is a field being picked up from the A2Billing config. This can be found under “SETTINGS, Global List, sip-iax info, Host” and should you should change this to match the IP address of your VPS.
USING THE NEW TRUNK
Now that we have the trunk details we can use that in Asterisk or FreePBX. Here is the trunk being used on a remote FreePBX server –
And here we can see the CDR report in A2Billing –
It seems like a lot of set up looking at the long post I’ve written!, but there are only really a few steps. Set up your outbound trunk, configure you rate cards and create the customer.
I should point out that the A2B100 template is configured to use Asterisk RealTime so there is no need to generate SIP/IAX configuration files, all of the settings are stored, and pulled from, the MySQL database.