Skip to content

Commit 7551d1a

Browse files
Add helpers
1 parent 44cbc48 commit 7551d1a

File tree

5 files changed

+97
-4
lines changed

5 files changed

+97
-4
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ install: travis_retry composer install --no-interaction --prefer-source
1414

1515
script:
1616
- mkdir -p build/logs
17-
- php vendor/bin/phpunit -c phpunit.xml.dist
18-
- phpunit --coverage-text --coverage-clover=coverage.clover
19-
- phpunit --coverage-clover build/logs/clover.xml
17+
- vendor/bin/phpunit -c phpunit.xml.dist
18+
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
19+
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml
2020

2121
after_script:
2222
- wget https://scrutinizer-ci.com/ocular.phar

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ You'll then need to run `composer install` or `composer update` to download it a
3030

3131
Once Laravel Paystack is installed, you need to register the service provider. Open up `config/app.php` and add the following to the `providers` key.
3232

33+
```php
34+
'providers' => [
35+
...
36+
Unicodeveloper\Paystack\PaystackServiceProvider::class,
37+
...
38+
]
39+
```
40+
3341
> If you use **Laravel >= 5.5** you can skip this step and go to [**`configuration`**](https://github.com/unicodeveloper/laravel-paystack#configuration)
3442
3543
* `Unicodeveloper\Paystack\PaystackServiceProvider::class`
@@ -197,11 +205,16 @@ Let me explain the fluent methods this package provides a bit here.
197205
/**
198206
* This fluent method does all the dirty work of sending a POST request with the form data
199207
* to Paystack Api, then it gets the authorization Url and redirects the user to Paystack
200-
* Payment Page. I abstracted all of it, so you don't have to worry about that.
208+
* Payment Page. We've abstracted all of it, so you don't have to worry about that.
201209
* Just eat your cookies while coding!
202210
*/
203211
Paystack::getAuthorizationUrl()->redirectNow();
204212

213+
/**
214+
* Alternatively, use the helper.
215+
*/
216+
paystack()->getAuthorizationUrl()->redirectNow();
217+
205218
/**
206219
* This fluent method does all the dirty work of verifying that the just concluded transaction was actually valid,
207220
* It verifies the transaction reference with Paystack Api and then grabs the data returned from Paystack.
@@ -210,55 +223,104 @@ Paystack::getAuthorizationUrl()->redirectNow();
210223
*/
211224
Paystack::getPaymentData();
212225

226+
/**
227+
* Alternatively, use the helper.
228+
*/
229+
paystack()->getPaymentData();
230+
213231
/**
214232
* This method gets all the customers that have performed transactions on your platform with Paystack
215233
* @returns array
216234
*/
217235
Paystack::getAllCustomers();
218236

237+
/**
238+
* Alternatively, use the helper.
239+
*/
240+
paystack()->getAllCustomers();
241+
242+
219243
/**
220244
* This method gets all the plans that you have registered on Paystack
221245
* @returns array
222246
*/
223247
Paystack::getAllPlans();
224248

249+
/**
250+
* Alternatively, use the helper.
251+
*/
252+
paystack()->getAllPlans();
253+
254+
225255
/**
226256
* This method gets all the transactions that have occurred
227257
* @returns array
228258
*/
229259
Paystack::getAllTransactions();
230260

261+
/**
262+
* Alternatively, use the helper.
263+
*/
264+
paystack()->getAllTransactions();
265+
231266
/**
232267
* This method generates a unique super secure cryptograhical hash token to use as transaction reference
233268
* @returns string
234269
*/
235270
Paystack::genTranxRef();
236271

272+
/**
273+
* Alternatively, use the helper.
274+
*/
275+
paystack()->genTranxRef();
276+
277+
237278
/**
238279
* This method creates a subaccount to be used for split payments
239280
* @return array
240281
*/
241282
Paystack::createSubAccount();
242283

284+
/**
285+
* Alternatively, use the helper.
286+
*/
287+
paystack()->createSubAccount();
288+
243289

244290
/**
245291
* This method fetches the details of a subaccount
246292
* @return array
247293
*/
248294
Paystack::fetchSubAccount();
249295

296+
/**
297+
* Alternatively, use the helper.
298+
*/
299+
paystack()->fetchSubAccount();
300+
250301

251302
/**
252303
* This method lists the subaccounts associated with your paystack account
253304
* @return array
254305
*/
255306
Paystack::listSubAccounts();
256307

308+
/**
309+
* Alternatively, use the helper.
310+
*/
311+
paystack()->listSubAccounts();
312+
313+
257314
/**
258315
* This method Updates a subaccount to be used for split payments
259316
* @return array
260317
*/
261318
Paystack::updateSubAccount();
319+
320+
/**
321+
* Alternatively, use the helper.
322+
*/
323+
paystack()->updateSubAccount();
262324
```
263325

264326
A sample form will look like so:

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
"mockery/mockery": "^1.3"
2727
},
2828
"autoload": {
29+
"files": [
30+
"src/Support/helpers.php"
31+
],
2932
"psr-4": {
3033
"Unicodeveloper\\Paystack\\": "src/"
3134
}

src/Support/helpers.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
if (! function_exists("paystack"))
4+
{
5+
function paystack() {
6+
7+
return app()->make('laravel-paystack');
8+
}
9+
}

tests/HelpersTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Unicodeveloper\Paystack\Test;
4+
5+
use PHPUnit_Framework_TestCase;
6+
7+
class HelpersTest extends PHPUnit_Framework_TestCase {
8+
9+
/**
10+
* Tests that helper returns
11+
*
12+
* @test
13+
* @return void
14+
*/
15+
function it_returns_instance_of_paystack () {
16+
17+
$this->assertInstanceOf("Unicodeveloper\Paystack\Paystack", paystack());
18+
}
19+
}

0 commit comments

Comments
 (0)