Skip to content

Commit bb95987

Browse files
committed
add split feature and allow package to support php 8 and laravel 8
1 parent 731358f commit bb95987

File tree

3 files changed

+101
-51
lines changed

3 files changed

+101
-51
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ Route::post('/pay', [
147147
'as' => 'pay'
148148
]);
149149
```
150+
OR
151+
152+
```php
153+
// Laravel 8
154+
Route::post('/pay', [App\Http\Controllers\PaymentController::class, 'redirectToGateway'])->name('pay');
155+
```
156+
150157

151158
```php
152159
Route::get('/payment/callback', 'PaymentController@handleGatewayCallback');
@@ -161,6 +168,13 @@ Route::get('payment/callback', [
161168
]);
162169
```
163170

171+
OR
172+
173+
```php
174+
// Laravel 8
175+
Route::get('/payment/callback', [App\Http\Controllers\PaymentController::class, 'handleGatewayCallback']);
176+
```
177+
164178
```php
165179
<?php
166180

composer.json

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,66 @@
11
{
2-
"name": "unicodeveloper/laravel-paystack",
3-
"description": "A Laravel Package for Paystack",
4-
"keywords": ["php","github", "laravel","Open Source","payments", "subscription", "paystack", "paystack.co","laravel 6", "laravel 7", "laravel 8"],
5-
"license": "MIT",
6-
"authors": [
7-
{
8-
"name": "unicodeveloper",
9-
"email": "prosperotemuyiwa@gmail.com"
10-
},
11-
{
12-
"name": "iamfunsho",
13-
"email": "info@devfunsho.com"
14-
}
15-
],
16-
"minimum-stability": "stable",
17-
"require": {
18-
"php": "^7.2",
19-
"illuminate/support": "~6|~7|~8",
20-
"guzzlehttp/guzzle": "~6|~7"
21-
},
22-
"require-dev": {
23-
"phpunit/phpunit" : "^8.4|^9.0",
24-
"scrutinizer/ocular": "~1.1",
25-
"php-coveralls/php-coveralls": "^2.0",
26-
"mockery/mockery": "^1.3"
27-
},
28-
"autoload": {
29-
"files": [
30-
"src/Support/helpers.php"
31-
],
32-
"psr-4": {
33-
"Unicodeveloper\\Paystack\\": "src/"
34-
}
35-
},
36-
"autoload-dev": {
37-
"psr-4": {
38-
"Unicodeveloper\\Paystack\\Test\\": "tests"
39-
}
2+
"name": "unicodeveloper/laravel-paystack",
3+
"description": "A Laravel Package for Paystack",
4+
"keywords": [
5+
"php",
6+
"github",
7+
"laravel",
8+
"Open Source",
9+
"payments",
10+
"subscription",
11+
"paystack",
12+
"paystack.co",
13+
"laravel 6",
14+
"laravel 7",
15+
"laravel 8"
16+
],
17+
"license": "MIT",
18+
"authors": [
19+
{
20+
"name": "unicodeveloper",
21+
"email": "prosperotemuyiwa@gmail.com"
4022
},
41-
"scripts": {
42-
"test": "vendor/bin/phpunit"
43-
},
44-
"extra": {
23+
{
24+
"name": "iamfunsho",
25+
"email": "info@devfunsho.com"
26+
}
27+
],
28+
"minimum-stability": "stable",
29+
"require": {
30+
"php": "^7.2|^8.0",
31+
"illuminate/support": "~6|~7|~8",
32+
"guzzlehttp/guzzle": "~6|~7|~8"
33+
},
34+
"require-dev": {
35+
"phpunit/phpunit": "^8.4|^9.0",
36+
"scrutinizer/ocular": "~1.1",
37+
"php-coveralls/php-coveralls": "^2.0",
38+
"mockery/mockery": "^1.3"
39+
},
40+
"autoload": {
41+
"files": [
42+
"src/Support/helpers.php"
43+
],
44+
"psr-4": {
45+
"Unicodeveloper\\Paystack\\": "src/"
46+
}
47+
},
48+
"autoload-dev": {
49+
"psr-4": {
50+
"Unicodeveloper\\Paystack\\Test\\": "tests"
51+
}
52+
},
53+
"scripts": {
54+
"test": "vendor/bin/phpunit"
55+
},
56+
"extra": {
4557
"laravel": {
46-
"providers": [
47-
"Unicodeveloper\\Paystack\\PaystackServiceProvider"
48-
],
49-
"aliases": {
50-
"Paystack": "Unicodeveloper\\Paystack\\Facades\\Paystack"
51-
}
58+
"providers": [
59+
"Unicodeveloper\\Paystack\\PaystackServiceProvider"
60+
],
61+
"aliases": {
62+
"Paystack": "Unicodeveloper\\Paystack\\Facades\\Paystack"
63+
}
5264
}
5365
}
5466
}

src/Paystack.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,43 @@ public function makePaymentRequest( $data = null)
124124
"last_name" => request()->last_name,
125125
"callback_url" => request()->callback_url,
126126
"currency" => (request()->currency != "" ? request()->currency : "NGN"),
127-
127+
128128
/*
129129
Paystack allows for transactions to be split into a subaccount -
130130
The following lines trap the subaccount ID - as well as the ammount to charge the subaccount (if overriden in the form)
131131
both values need to be entered within hidden input fields
132132
*/
133133
"subaccount" => request()->subaccount,
134134
"transaction_charge" => request()->transaction_charge,
135-
135+
136+
/**
137+
* Paystack allows for transaction to be split into multi accounts(subaccounts)
138+
* The following lines trap the split ID handling the split
139+
* More details here: https://paystack.com/docs/payments/multi-split-payments/#using-transaction-splits-with-payments
140+
*/
141+
"split_code" => request()->split_code,
142+
143+
/**
144+
* Paystack allows transaction to be split into multi account(subaccounts) on the fly without predefined split
145+
* form need an input field: <input type="hidden" name="split" value="{{ json_encode($split) }}" >
146+
* array must be set up as:
147+
* $split = [
148+
* "type" => "percentage",
149+
* "currency" => "KES",
150+
* "subaccounts" => [
151+
* { "subaccount" => "ACCT_li4p6kte2dolodo", "share" => 10 },
152+
* { "subaccount" => "ACCT_li4p6kte2dolodo", "share" => 30 },
153+
* ],
154+
* "bearer_type" => "all",
155+
* "main_account_share": 70,
156+
* ]
157+
* More details here: https://paystack.com/docs/payments/multi-split-payments/#dynamic-splits
158+
*/
159+
"split" => request()->split,
136160
/*
137161
* to allow use of metadata on Paystack dashboard and a means to return additional data back to redirect url
138162
* form need an input field: <input type="hidden" name="metadata" value="{{ json_encode($array) }}" >
139-
* array must be set up as:
163+
* array must be set up as:
140164
* $array = [ 'custom_fields' => [
141165
* ['display_name' => "Cart Id", "variable_name" => "cart_id", "value" => "2"],
142166
* ['display_name' => "Sex", "variable_name" => "sex", "value" => "female"],

0 commit comments

Comments
 (0)