Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bfcb922

Browse filesBrowse files
Merge pull request unicodeveloper#147 from segun-paystack/iamraphson/add-split-feature
2 parents 731358f + e47e424 commit bfcb922
Copy full SHA for bfcb922

File tree

Expand file treeCollapse file tree

3 files changed

+121
-51
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+121
-51
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+34Lines changed: 34 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

@@ -330,6 +344,23 @@ paystack()->updateSubAccount();
330344

331345
A sample form will look like so:
332346

347+
```php
348+
<?php
349+
// more details https://paystack.com/docs/payments/multi-split-payments/#dynamic-splits
350+
351+
$split = [
352+
"type" => "percentage",
353+
"currency" => "KES",
354+
"subaccounts" => [
355+
[ "subaccount" => "ACCT_li4p6kte2dolodo", "share" => 10 ],
356+
[ "subaccount" => "ACCT_li4p6kte2dolodo", "share" => 30 ],
357+
],
358+
"bearer_type" => "all",
359+
"main_account_share" => 70
360+
];
361+
?>
362+
```
363+
333364
```html
334365
<form method="POST" action="{{ route('pay') }}" accept-charset="UTF-8" class="form-horizontal" role="form">
335366
<div class="row" style="margin-bottom:40px;">
@@ -347,6 +378,9 @@ A sample form will look like so:
347378
<input type="hidden" name="currency" value="NGN">
348379
<input type="hidden" name="metadata" value="{{ json_encode($array = ['key_name' => 'value',]) }}" > {{-- For other necessary things you want to add to your payload. it is optional though --}}
349380
<input type="hidden" name="reference" value="{{ Paystack::genTranxRef() }}"> {{-- required --}}
381+
382+
<input type="hidden" name="split_code" value="SPL_EgunGUnBeCareful"> {{-- to support transaction split. more details https://paystack.com/docs/payments/multi-split-payments/#using-transaction-splits-with-payments --}}
383+
<input type="hidden" name="split" value="{{ json_encode($split) }}"> {{-- to support dynamic transaction split. More details https://paystack.com/docs/payments/multi-split-payments/#dynamic-splits --}}
350384
{{ csrf_field() }} {{-- works only when using laravel 5.1, 5.2 --}}
351385

352386
<input type="hidden" name="_token" value="{{ csrf_token() }}"> {{-- employ this in place of csrf_field only in laravel 5.0 --}}

‎composer.json

Copy file name to clipboard
+60-48Lines 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

Copy file name to clipboardExpand all lines: src/Paystack.php
+27-3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.