Skip to content

Commit 7510b54

Browse files
feat(paystack): Get all customers, plans and transactions
1 parent 15c9d33 commit 7510b54

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/Paystack.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ public function setResponse($relativeUrl)
127127
return $this;
128128
}
129129

130+
private function setGetResponse($relativeUrl)
131+
{
132+
$this->response = $this->client->get($this->baseUrl . $relativeUrl, []);
133+
134+
return $this;
135+
}
136+
130137
/**
131138
* Get the authorization url from the callback response
132139
* @return Unicodeveloper\Paystack\Paystack
@@ -220,4 +227,46 @@ public function genTranxRef()
220227
return TransRef::getHashedToken();
221228
}
222229

230+
/**
231+
* Get all the customers that have made transactions on your platform
232+
* @return array
233+
*/
234+
public function getAllCustomers()
235+
{
236+
$this->setRequestOptions();
237+
238+
return $this->setGetResponse("/customer")->getData();
239+
}
240+
241+
/**
242+
* Get all the plans that you have on Paystack
243+
* @return array
244+
*/
245+
public function getAllPlans()
246+
{
247+
$this->setRequestOptions();
248+
249+
return $this->setGetResponse("/plan")->getData();
250+
}
251+
252+
/**
253+
* Get all the transactions that have happened overtime
254+
* @return array
255+
*/
256+
public function getAllTransactions()
257+
{
258+
$this->setRequestOptions();
259+
260+
return $this->setGetResponse("/transaction")->getData();
261+
}
262+
263+
/**
264+
* Get the response from a get operation
265+
* @return array
266+
*/
267+
private function getData()
268+
{
269+
return $this->response->json()["data"];
270+
}
271+
223272
}

0 commit comments

Comments
 (0)