public function testApiKey() { $expectedApiKey = "sk_tst_111"; Paystack::setApiKey($expectedApiKey); $actualApiKey = Paystack::getApiKey(); $this->assertEquals($actualApiKey, $expectedApiKey); }
protected static function _get($url) { $response = (new Request())->setUrl(Paystack::api($url))->setType(IRequest::TYPE_GET)->send(); if ($response->getCode() === IResponse::CODE_VALIDATION_ERROR) { throw new \Exception($response->getBody()->message); } return new static($response->getBody()->data); }
/** * @param IRequest $request * @return IResponse */ public function sendRequest(IRequest $request) { $response = \Httpful\Request::init()->addHeader('Authorization', 'Bearer ' . Paystack::getApiKey())->uri($request->getUrl())->method($request->getType())->addHeaders($request->getHeaders())->body($request->getBody())->sendsJson()->send(); $iResponse = new Response($response->code, $response->body); return $iResponse; }
<?php require '../vendor/autoload.php'; \Paystack\Paystack::init('sk_test_19f3325a5a0abe546b508cd5926f3d6223d4e4d8'); try { // $customer = \Paystack\Customer::create([ // 'email' => '*****@*****.**', // 'first_name' => 'Perfecto', // 'last_name' => 'Makanjuo', // 'phone' => '08064474572' // ]); // // echo 'Customer\'s first name is: '.$customer->first_name; // $payment = \Paystack\Transaction::initialize([ // 'email' => '*****@*****.**', // 'amount' => '3000' // ]); $transaction = \Paystack\Transaction::verify('3beczdakli'); echo $transaction->amount; } catch (Exception $e) { echo $e->getMessage(); }