Skip to content

Commit 00b00fe

Browse files
Merge pull request #154 from bhekor/master
Added an option to add request data from controller
2 parents cc02add + eec5ecd commit 00b00fe

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,28 @@ class PaymentController extends Controller
219219
}
220220
```
221221

222+
```php
223+
/**
224+
* In the case where you need to pass the data from your
225+
* controller instead of a form
226+
* Make sure to send:
227+
* required: email, amount, reference, orderID(probably)
228+
* optionally: currency, description, metadata
229+
* e.g:
230+
*
231+
*/
232+
$data = array(
233+
"amount" => 700 * 100,
234+
"reference" => '4g4g5485g8545jg8gj',
235+
"email" => 'user@mail.com',
236+
"currency" => "NGN",
237+
"orderID" => 23456,
238+
);
239+
240+
return Paystack::getAuthorizationUrl($data)->redirectNow();
241+
242+
```
243+
222244
Let me explain the fluent methods this package provides a bit here.
223245
```php
224246
/**

src/Paystack.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private function setRequestOptions()
109109
* @return Paystack
110110
*/
111111

112-
public function makePaymentRequest( $data = null)
112+
public function makePaymentRequest($data = null)
113113
{
114114
if ( $data == null ) {
115115

@@ -205,9 +205,9 @@ private function setHttpResponse($relativeUrl, $method, $body = [])
205205
* Get the authorization url from the callback response
206206
* @return Paystack
207207
*/
208-
public function getAuthorizationUrl()
208+
public function getAuthorizationUrl($data = null)
209209
{
210-
$this->makePaymentRequest();
210+
$this->makePaymentRequest($data);
211211

212212
$this->url = $this->getResponse()['data']['authorization_url'];
213213

0 commit comments

Comments
 (0)