#Verify a #BankAccount via an #API
If you process large volumes of payments, then you will need to be able to quickly and cheaply check that the payment you are about to make is going to a valid bank account, or else it will delay payment to your supplier / employee / or affiliate, this API allows you to check each account for 3p / 4¢ – using the same technology as used by Stripe.
verifyBankAccount.com
Getting started
The API endpoint is located at https://verifybankaccount.com/api.asmx
It accepts GET / POST and SOAP requests, and returns either a HTTP 500 error with textual description on error, or JSON embedded in XML in the case of a valid response, similar to as follows:
<string xmlns=”http://verifybankaccount.com/”>
{ </string> |
Countries supported by this API are as follows;
Country code | |
US | USA |
IE | Ireland |
GB | United Kingdom |
AU | Australia |
CA | Canada |
DK | Denmark |
FI | Finland |
FR | France |
JP | Japan |
NO | Norway |
SG | Singapore |
ES | Spain |
SE | Sweden |
AT | Austria |
BE | Belgium |
DE | Germany |
HK | Hong Kong |
IT | Italy |
LU | Luxembourg |
NL | Netherlands |
PT | Portugal |
The API also includes an endpoint for programmatically retrieving the remaining credits associated with an API Key, called GetRemainingCredit returning data such as;
<int xmlns=”http://verifybankaccount.com/”>98</int> |
C# (.NET) implementation
Here is a step by step guide to writing a simple C# client
- Open Visual Studio
- Press File > New > Project
- Select Console Application – Visual C#
- Press OK
- Right Click on the project in Solution Explorer
- Select Add > Service Reference
- Click Advanced
- Click Add Web Reference
- Enter “https://www.verifybankaccount.com/api.asmx?wsdl” into the URL
- Press Add Reference
- Click Tools > NuGet Package Manager > Package Manager Console
- Type “Install-Package Newtonsoft.JSON” into the Package Manager Console window
- Now, enter the following code (Replacing the API KEY)
static void Main(string[] args)
{ var strAPIKey = “Your API key here“; var bank = new com.verifybankaccount.www.API(); Console.WriteLine(“Enter the 2 letter country code:”); var strCountry = Console.ReadLine(); Console.WriteLine(“Enter the Bank sort code:”); var strSortCode = Console.ReadLine(); Console.WriteLine(“Enter the Bank account number:”); var strAccountNumber = Console.ReadLine(); try { var strJson = bank.VerifyBankAccount(strCountry, strSortCode, strAccountNumber, strAPIKey); var jObject = Newtonsoft.Json.Linq.JObject.Parse(strJson); Console.WriteLine(“This bank is ” + jObject[“bank_name”]); } catch(Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); } |
PHP Implementation
The following implementation uses the HTTP GET version of the webservice, you could use $soapclient as an alternative implementation. Please note that you should never pass bank account details over an unsecure connection so this code should be run either on localhost or on a suitably secured HTTPS webserver.
You will have to replace the APIKey below
<?php
$country = $_GET[“country”]; $sortcode = $_GET[“sortcode”]; $accountNumber = $_GET[“accountNumber”]; $url = “https://www.verifybankaccount.com/api.asmx /VerifyBankAccount?”; $url .= “Country=” . $country; $url .= “&SortCode=” . $sortcode; $url .= “&AccountNumber=” . $accountNumber; $url .= “&ApiKey={{Your API Key}}“; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $xmlData = curl_exec($ch); libxml_use_internal_errors(true); $xml=simplexml_load_string($xmlData); if ($xml) { $json = json_decode($xml); print_r($json->bank_name); } else { print_r($xmlData); } ?> |