@@ -65,4 +65,67 @@ public function transactions()
6565 {
6666 return new Transactions ($ this ->client );
6767 }
68+
69+ /**
70+ * Return paystack accepted banks
71+ */
72+ public function getAvailableBanks ($ options = [])
73+ {
74+ $ queryOptions = http_build_query ($ options );
75+ $ queryOptions = str_replace (['%5B ' , '%5D ' ], ['[ ' , '] ' ], $ queryOptions );
76+
77+ $ response = $ this ->client ->get ("/bank? $ queryOptions " );
78+
79+ if ($ response ->getStatusCode () !== 200 ) {
80+ throw new \Exception ('Failed to fetch banks from PayStack ' );
81+ }
82+
83+ $ data = json_decode ($ response ->getBody ()->getContents (), true );
84+
85+ if (isset ($ data ['data ' ])) {
86+ return $ data ['data ' ];
87+ }
88+
89+ return [];
90+ }
91+
92+ /**
93+ * Return all accepted countries
94+ */
95+ public function getAvailableCountries ($ options = [])
96+ {
97+ $ response = $ this ->client ->get ('/country ' );
98+
99+ if ($ response ->getStatusCode () !== 200 ) {
100+ throw new \Exception ('Failed to fetch countries from PayStack ' );
101+ }
102+
103+ $ data = json_decode ($ response ->getBody ()->getContents (), true );
104+
105+ if (isset ($ data ['data ' ])) {
106+ return $ data ['data ' ];
107+ }
108+
109+ return [];
110+ }
111+
112+ /**
113+ * Return paystack accepted regions/states
114+ */
115+ public function getAvailableRegions ($ country )
116+ {
117+ $ response = $ this ->client ->get ("/address_verification/states?country= $ country " );
118+
119+ if ($ response ->getStatusCode () !== 200 ) {
120+ throw new \Exception ('Failed to fetch states from PayStack ' );
121+ }
122+
123+ $ data = json_decode ($ response ->getBody ()->getContents (), true );
124+
125+ if (isset ($ data ['data ' ])) {
126+ return $ data ['data ' ];
127+ }
128+
129+ return [];
130+ }
68131}
0 commit comments