Skip to content

Commit d71949b

Browse files
committed
refactor:
1 parent 02278b6 commit d71949b

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,24 @@ Any package that implements [psr/http-client-implementation](https://packagist.o
3636
Simple usage looks like:
3737

3838
```php
39+
<?php
40+
41+
require_once "vendor/autoload.php";
42+
3943
use StarfolkSoftware\Flutterwave\Client as FlutterwaveClient;
4044

4145
$flutterwave = new FlutterwaveClient([
42-
'secretKey' => 'secret',
46+
'secretKey' => 'FLWSECK_TEST-8bfa3677596bd0967882c4a4c9603790-X',
4347
]);
4448

45-
$response = $flutterwave->plans()
46-
->create([
47-
'name' => 'Test Plan',
48-
'amount' => 100,
49-
'interval' => 'monthly'
50-
]);
49+
$response = $flutterwave
50+
->transactions
51+
->all([]);
52+
53+
var_dump($response['data'][0]);
5154

52-
echo $response;
55+
\\ dumps
56+
array(21) { ["id"]=> int(2654445) ["tx_ref"]=> string(44) "billing_inv_8eed889459f14cd0b2afadd485fe85fa" ["flw_ref"]=> string(41) "FLW-M03K-4bbacc878adb35c76cf37e95e61d26e4" ["device_fingerprint"]=> string(3) "N/A" ["amount"]=> float(8958.333333333332) ["currency"]=> string(3) "NGN" ["charged_amount"]=> float(8958.33) ["app_fee"]=> float(125.42) ["merchant_fee"]=> int(0) ["processor_response"]=> string(8) "Approved" ["auth_model"]=> string(6) "noauth" ["ip"]=> string(14) "52.209.154.143" ["narration"]=> string(23) "Sample tokenized charge" ["status"]=> string(10) "successful" ["payment_type"]=> string(4) "card" ["created_at"]=> string(24) "2021-11-26T11:14:11.000Z" ["amount_settled"]=> float(8832.91) ["card"]=> array(6) { ["type"]=> string(10) "MASTERCARD" ["country"]=> string(10) "NIGERIA NG" ["issuer"]=> string(18) "MASTERCARD CREDIT" ["first_6digits"]=> string(5) "55318" ["last_4digits"]=> string(4) "2950" ["expiry"]=> string(5) "09/32" } ["customer"]=> array(5) { ["id"]=> int(1450916) ["email"]=> string(18) "team-1@bizbooq.com" ["phone_number"]=> string(3) "N/A" ["name"]=> string(16) "Faruk's business" ["created_at"]=> string(24) "2021-11-24T21:17:04.000Z" } ["account_id"]=> int(779467) ["meta"]=> NULL }
5357
```
5458

5559
## Documentation

src/Client.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getHttpClient(): HttpMethodsClientInterface
6969
*
7070
* @return Plan
7171
*/
72-
public function plans(): Plan
72+
protected function plans(): Plan
7373
{
7474
return new Plan($this);
7575
}
@@ -79,7 +79,7 @@ public function plans(): Plan
7979
*
8080
* @return Subscription
8181
*/
82-
public function subscriptions(): Subscription
82+
protected function subscriptions(): Subscription
8383
{
8484
return new Subscription($this);
8585
}
@@ -89,7 +89,7 @@ public function subscriptions(): Subscription
8989
*
9090
* @return Charge
9191
*/
92-
public function charges(): Charge
92+
protected function charges(): Charge
9393
{
9494
return new Charge($this);
9595
}
@@ -99,8 +99,22 @@ public function charges(): Charge
9999
*
100100
* @return Transaction
101101
*/
102-
public function transactions(): Transaction
102+
protected function transactions(): Transaction
103103
{
104104
return new Transaction($this);
105105
}
106+
107+
/**
108+
* Read data from inaccessible (protected or private)
109+
* or non-existing properties.
110+
*
111+
* @param string $name
112+
* @return mixed
113+
*/
114+
public function __get(string $name)
115+
{
116+
if (method_exists($this, $name)) {
117+
return $this->{$name}();
118+
}
119+
}
106120
}

0 commit comments

Comments
 (0)