src/Paystack/Customer/UpdateCustomer.php 1 location
|
@@ 10-41 (lines=32) @@
|
| 7 |
|
use function GuzzleHttp\json_encode; |
| 8 |
|
use function GuzzleHttp\json_decode; |
| 9 |
|
|
| 10 |
|
class UpdateCustomer extends AbstractPlugin |
| 11 |
|
{ |
| 12 |
|
use VerifyHttpStatusResponseCode; |
| 13 |
|
|
| 14 |
|
const UPDATE_CUSTOMER_ENDPOINT = "/customer/:identifier"; |
| 15 |
|
|
| 16 |
|
protected $baseUrl; |
| 17 |
|
|
| 18 |
|
public function __construct(string $baseUrl) |
| 19 |
|
{ |
| 20 |
|
$this->baseUrl = $baseUrl; |
| 21 |
|
} |
| 22 |
|
|
| 23 |
|
public function getPluginAccessor(): string |
| 24 |
|
{ |
| 25 |
|
return "updateCustomer"; |
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
public function handle(string $customerIdentifier, array $data = []) |
| 29 |
|
{ |
| 30 |
|
$link = str_replace(":identifier", $customerIdentifier, $this->baseUrl . self::UPDATE_CUSTOMER_ENDPOINT); |
| 31 |
|
|
| 32 |
|
$response = $this->adapter->getHttpClient() |
| 33 |
|
->put($link, [ |
| 34 |
|
'body' => json_encode($data) |
| 35 |
|
]); |
| 36 |
|
|
| 37 |
|
$this->verifyResponse($response); |
| 38 |
|
|
| 39 |
|
return json_decode($response->getBody(), true)["data"]; |
| 40 |
|
} |
| 41 |
|
} |
| 42 |
|
|
src/Paystack/Plan/UpdatePlan.php 1 location
|
@@ 10-42 (lines=33) @@
|
| 7 |
|
use function GuzzleHttp\json_decode; |
| 8 |
|
use Gbowo\Plugin\AbstractPlugin; |
| 9 |
|
|
| 10 |
|
class UpdatePlan extends AbstractPlugin |
| 11 |
|
{ |
| 12 |
|
|
| 13 |
|
use VerifyHttpStatusResponseCode; |
| 14 |
|
|
| 15 |
|
const UPDATE_PLAN_ENDPOINT = "/plan/:identifier"; |
| 16 |
|
|
| 17 |
|
protected $baseUrl; |
| 18 |
|
|
| 19 |
|
public function __construct(string $baseUrl) |
| 20 |
|
{ |
| 21 |
|
$this->baseUrl = $baseUrl; |
| 22 |
|
} |
| 23 |
|
|
| 24 |
|
public function getPluginAccessor(): string |
| 25 |
|
{ |
| 26 |
|
return "updatePlan"; |
| 27 |
|
} |
| 28 |
|
|
| 29 |
|
public function handle(string $planIdentifier, array $data = []) |
| 30 |
|
{ |
| 31 |
|
$link = $this->baseUrl . str_replace(":identifier", $planIdentifier, self::UPDATE_PLAN_ENDPOINT); |
| 32 |
|
|
| 33 |
|
$response = $this->adapter->getHttpClient() |
| 34 |
|
->put($link, [ |
| 35 |
|
"body" => json_encode($data) |
| 36 |
|
]); |
| 37 |
|
|
| 38 |
|
$this->verifyResponse($response); |
| 39 |
|
|
| 40 |
|
return json_decode($response->getBody(), true)["status"]; |
| 41 |
|
} |
| 42 |
|
} |
| 43 |
|
|
src/Paystack/Subscription/GetAllSubscriptions.php 1 location
|
@@ 10-42 (lines=33) @@
|
| 7 |
|
use function Gbowo\toQueryParams; |
| 8 |
|
use Gbowo\Plugin\AbstractPlugin; |
| 9 |
|
|
| 10 |
|
class GetAllSubscriptions extends AbstractPlugin |
| 11 |
|
{ |
| 12 |
|
use VerifyHttpStatusResponseCode; |
| 13 |
|
|
| 14 |
|
const GET_ALL_SUBSCRIPTIONS_ENDPOINT = "/subscription"; |
| 15 |
|
|
| 16 |
|
protected $baseUrl; |
| 17 |
|
|
| 18 |
|
public function __construct(string $baseUrl) |
| 19 |
|
{ |
| 20 |
|
$this->baseUrl = $baseUrl; |
| 21 |
|
} |
| 22 |
|
|
| 23 |
|
public function getPluginAccessor(): string |
| 24 |
|
{ |
| 25 |
|
return "getAllSubscriptions"; |
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
public function handle(array $params = []) |
| 29 |
|
{ |
| 30 |
|
$queryParams = toQueryParams($params); |
| 31 |
|
|
| 32 |
|
$response = $this->adapter->getHttpClient() |
| 33 |
|
->get($this->baseUrl . self::GET_ALL_SUBSCRIPTIONS_ENDPOINT . $queryParams); |
| 34 |
|
|
| 35 |
|
$this->verifyResponse($response); |
| 36 |
|
|
| 37 |
|
return array_slice( |
| 38 |
|
json_decode($response->getBody(), true), |
| 39 |
|
2 |
| 40 |
|
); |
| 41 |
|
} |
| 42 |
|
} |
| 43 |
|
|
src/Paystack/Subscription/GetSubscription.php 1 location
|
@@ 9-39 (lines=31) @@
|
| 6 |
|
use Gbowo\Adapter\Paystack\Traits\VerifyHttpStatusResponseCode; |
| 7 |
|
use Gbowo\Plugin\AbstractPlugin; |
| 8 |
|
|
| 9 |
|
class GetSubscription extends AbstractPlugin |
| 10 |
|
{ |
| 11 |
|
|
| 12 |
|
use VerifyHttpStatusResponseCode; |
| 13 |
|
|
| 14 |
|
const GET_SUBSCRIPTION_ENDPOINT = "/subscription/:identifier"; |
| 15 |
|
|
| 16 |
|
protected $baseUrl; |
| 17 |
|
|
| 18 |
|
public function __construct(string $baseUrl) |
| 19 |
|
{ |
| 20 |
|
$this->baseUrl = $baseUrl; |
| 21 |
|
} |
| 22 |
|
|
| 23 |
|
public function getPluginAccessor(): string |
| 24 |
|
{ |
| 25 |
|
return "getSubscription"; |
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
public function handle(string $subscriptionIdentifier) |
| 29 |
|
{ |
| 30 |
|
$link = $this->baseUrl . str_replace(":identifier", $subscriptionIdentifier, self::GET_SUBSCRIPTION_ENDPOINT); |
| 31 |
|
|
| 32 |
|
$response = $this->adapter->getHttpClient() |
| 33 |
|
->get($link); |
| 34 |
|
|
| 35 |
|
$this->verifyResponse($response); |
| 36 |
|
|
| 37 |
|
return json_decode($response->getBody(), true)["data"]; |
| 38 |
|
} |
| 39 |
|
} |
| 40 |
|
|
src/Paystack/Transaction/GetTransaction.php 1 location
|
@@ 9-39 (lines=31) @@
|
| 6 |
|
use Gbowo\Plugin\AbstractPlugin; |
| 7 |
|
use function GuzzleHttp\json_decode; |
| 8 |
|
|
| 9 |
|
class GetTransaction extends AbstractPlugin |
| 10 |
|
{ |
| 11 |
|
|
| 12 |
|
use VerifyHttpStatusResponseCode; |
| 13 |
|
|
| 14 |
|
const SINGLE_TRANSACTION_ENDPOINT = "/transaction/:identifier"; |
| 15 |
|
|
| 16 |
|
protected $baseUrl; |
| 17 |
|
|
| 18 |
|
public function __construct(string $baseUrl) |
| 19 |
|
{ |
| 20 |
|
$this->baseUrl = $baseUrl; |
| 21 |
|
} |
| 22 |
|
|
| 23 |
|
public function getPluginAccessor(): string |
| 24 |
|
{ |
| 25 |
|
return "getTransaction"; |
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
public function handle(string $transactionId) |
| 29 |
|
{ |
| 30 |
|
$link = $this->baseUrl . str_replace(":identifier", $transactionId, self::SINGLE_TRANSACTION_ENDPOINT); |
| 31 |
|
|
| 32 |
|
$response = $this->adapter->getHttpClient() |
| 33 |
|
->get($link); |
| 34 |
|
|
| 35 |
|
$this->verifyResponse($response); |
| 36 |
|
|
| 37 |
|
return json_decode($response->getBody(), true)["data"]; |
| 38 |
|
} |
| 39 |
|
} |
| 40 |
|
|
src/Paystack/Bank/ListBanks.php 1 location
|
@@ 10-39 (lines=30) @@
|
| 7 |
|
use function Gbowo\toQueryParams; |
| 8 |
|
use Gbowo\Plugin\AbstractPlugin; |
| 9 |
|
|
| 10 |
|
class ListBanks extends AbstractPlugin |
| 11 |
|
{ |
| 12 |
|
use VerifyHttpStatusResponseCode; |
| 13 |
|
|
| 14 |
|
protected $baseUrl; |
| 15 |
|
|
| 16 |
|
const LIST_BANKS_ENDPOINT = "/bank"; |
| 17 |
|
|
| 18 |
|
public function __construct(string $baseUrl) |
| 19 |
|
{ |
| 20 |
|
$this->baseUrl = $baseUrl; |
| 21 |
|
} |
| 22 |
|
|
| 23 |
|
public function getPluginAccessor(): string |
| 24 |
|
{ |
| 25 |
|
return "listBanks"; |
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
public function handle(array $filter = []) |
| 29 |
|
{ |
| 30 |
|
$link = $this->baseUrl. self::LIST_BANKS_ENDPOINT . toQueryParams($filter); |
| 31 |
|
|
| 32 |
|
$response = $this->adapter->getHttpClient() |
| 33 |
|
->get($link); |
| 34 |
|
|
| 35 |
|
$this->verifyResponse($response); |
| 36 |
|
|
| 37 |
|
return json_decode($response->getBody(), true)["data"]; |
| 38 |
|
} |
| 39 |
|
} |
| 40 |
|
|
src/Paystack/Bank/GetCardBIN.php 1 location
|
@@ 10-39 (lines=30) @@
|
| 7 |
|
use function Gbowo\toQueryParams; |
| 8 |
|
use Gbowo\Plugin\AbstractPlugin; |
| 9 |
|
|
| 10 |
|
class GetCardBIN extends AbstractPlugin |
| 11 |
|
{ |
| 12 |
|
use VerifyHttpStatusResponseCode; |
| 13 |
|
|
| 14 |
|
protected $baseUrl; |
| 15 |
|
|
| 16 |
|
const RESOLVE_CARD_BIN_ENDPOINT = "/decision/bin/:bin"; |
| 17 |
|
|
| 18 |
|
public function __construct(string $baseUrl) |
| 19 |
|
{ |
| 20 |
|
$this->baseUrl = $baseUrl; |
| 21 |
|
} |
| 22 |
|
|
| 23 |
|
public function getPluginAccessor(): string |
| 24 |
|
{ |
| 25 |
|
return "getCardBIN"; |
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
public function handle(string $bin) |
| 29 |
|
{ |
| 30 |
|
$link = $this->baseUrl . str_replace(":bin", $bin, self::RESOLVE_CARD_BIN_ENDPOINT); |
| 31 |
|
|
| 32 |
|
$response = $this->adapter->getHttpClient() |
| 33 |
|
->get($link); |
| 34 |
|
|
| 35 |
|
$this->verifyResponse($response); |
| 36 |
|
|
| 37 |
|
return json_decode($response->getBody(), true)["data"]; |
| 38 |
|
} |
| 39 |
|
} |
| 40 |
|
|
src/Paystack/Customer/CheckPending.php 1 location
|
@@ 10-37 (lines=28) @@
|
| 7 |
|
use function GuzzleHttp\json_encode; |
| 8 |
|
use function GuzzleHttp\json_decode; |
| 9 |
|
|
| 10 |
|
class CheckPending extends AbstractPlugin |
| 11 |
|
{ |
| 12 |
|
use VerifyHttpStatusResponseCode; |
| 13 |
|
|
| 14 |
|
const GET_PENDING_CHARGE_ENDPOINT = "/charge/:ref"; |
| 15 |
|
|
| 16 |
|
protected $baseUrl; |
| 17 |
|
|
| 18 |
|
public function __construct(string $baseUrl) |
| 19 |
|
{ |
| 20 |
|
$this->baseUrl = $baseUrl; |
| 21 |
|
} |
| 22 |
|
|
| 23 |
|
public function getPluginAccessor(): string |
| 24 |
|
{ |
| 25 |
|
return "checkPending"; |
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
public function handle(string $reference) |
| 29 |
|
{ |
| 30 |
|
$response = $this->adapter->getHttpClient() |
| 31 |
|
->get($this->baseUrl . str_replace(":ref", $reference, self::GET_PENDING_CHARGE_ENDPOINT)); |
| 32 |
|
|
| 33 |
|
$this->verifyResponse($response); |
| 34 |
|
|
| 35 |
|
return json_decode($response->getBody(), true)["data"]; |
| 36 |
|
} |
| 37 |
|
} |
| 38 |
|
|