File tree Expand file tree Collapse file tree
src/Dfcplc/PostcodeAnywhere
InternationalBankValidation Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Dfcplc \PostcodeAnywhere \InternationalBankValidation ;
3+
4+ class Validate
5+ {
6+
7+ //Credit: Thanks to Stuart Sillitoe (http://stu.so/me) for the original PHP that these samples are based on.
8+
9+ private $ Key ; //The key to use to authenticate to the service.
10+ private $ IBAN ; //The international bank account number to validate.
11+ private $ Data ; //Holds the results of the query
12+
13+ public function __construct ($ Key , $ IBAN )
14+ {
15+ $ this ->Key = $ Key ;
16+ $ this ->IBAN = $ IBAN ;
17+ }
18+
19+ public function MakeRequest ()
20+ {
21+ $ url = "http://services.postcodeanywhere.co.uk/InternationalBankValidation/Interactive/Validate/v1.00/xmla.ws? " ;
22+ $ url .= "&Key= " . urlencode ($ this ->Key );
23+ $ url .= "&IBAN= " . urlencode ($ this ->IBAN );
24+
25+ //Make the request to Postcode Anywhere and parse the XML returned
26+ $ file = simplexml_load_file ($ url );
27+
28+ //Check for an error, if there is one then throw an exception
29+ if ($ file ->Columns ->Column ->attributes ()->Name == "Error " )
30+ {
31+ throw new Exception ("[ID] " . $ file ->Rows ->Row ->attributes ()->Error . " [DESCRIPTION] " . $ file ->Rows ->Row ->attributes ()->Description . " [CAUSE] " . $ file ->Rows ->Row ->attributes ()->Cause . " [RESOLUTION] " . $ file ->Rows ->Row ->attributes ()->Resolution );
32+ }
33+
34+ //Copy the data
35+ if ( !empty ($ file ->Rows ) )
36+ {
37+ foreach ($ file ->Rows ->Row as $ item )
38+ {
39+ $ this ->Data [] = array ('IsCorrect ' =>$ item ->attributes ()->IsCorrect );
40+ }
41+ }
42+ }
43+
44+ public function HasData ()
45+ {
46+ if ( !empty ($ this ->Data ) )
47+ {
48+ return $ this ->Data ;
49+ }
50+ return false ;
51+ }
52+ }
Original file line number Diff line number Diff line change 11<?php
2- namespace Dfcplc \PostcodeAnywhere ;
2+ namespace Dfcplc \PostcodeAnywhere \ PostcodeAnywhere ;
33
44class Lookup
55{
Original file line number Diff line number Diff line change 11<?php
2- namespace Dfcplc \PostcodeAnywhere ;
2+ namespace Dfcplc \PostcodeAnywhere \ PostcodeAnywhere ;
33
44class FindByParts
55{
Original file line number Diff line number Diff line change 11<?php
2- namespace Dfcplc \PostcodeAnywhere ;
2+ namespace Dfcplc \PostcodeAnywhere \ PostcodeAnywhere ;
33
44class Retrieve
55{
You can’t perform that action at this time.
0 commit comments