diff --git a/.phpunit.result.cache b/.phpunit.result.cache
new file mode 100644
index 0000000..5c6751f
--- /dev/null
+++ b/.phpunit.result.cache
@@ -0,0 +1 @@
+{"version":1,"defects":[],"times":{"Unicodeveloper\\Paystack\\Test\\HelpersTest::it_returns_instance_of_paystack":0.213,"Unicodeveloper\\Paystack\\Test\\PaystackTest::testAllCustomersAreReturned":0.089,"Unicodeveloper\\Paystack\\Test\\PaystackTest::testAllTransactionsAreReturned":0.001,"Unicodeveloper\\Paystack\\Test\\PaystackTest::testAllPlansAreReturned":0.001}}
\ No newline at end of file
diff --git a/README.md b/README.md
index e98d9db..f57e23d 100644
--- a/README.md
+++ b/README.md
@@ -100,7 +100,7 @@ return [
Though there are multiple ways to pay an order, most payment gateways expect you to follow the following flow in your checkout process:
### 1. The customer is redirected to the payment provider
-After the customer has gone through the checkout process and is ready to pay, the customer must be redirected to site of the payment provider.
+After the customer has gone through the checkout process and is ready to pay, the customer must be redirected to the site of the payment provider.
The redirection is accomplished by submitting a form with some hidden fields. The form must send a POST request to the site of the payment provider. The hidden fields minimally specify the amount that must be paid, the order id and a hash.
@@ -111,7 +111,7 @@ The hash is calculated using the hidden form fields and a non-public secret. The
The customer arrives on the site of the payment provider and gets to choose a payment method. All steps necessary to pay the order are taken care of by the payment provider.
### 3. The customer gets redirected back to your site
-After having paid the order the customer is redirected back. In the redirection request to the shop-site some values are returned. The values are usually the order id, a paymentresult and a hash.
+After having paid the order the customer is redirected back. In the redirection request to the shop-site some values are returned. The values are usually the order id, a payment result and a hash.
The hash is calculated out of some of the fields returned and a secret non-public value. This hash is used to verify if the request is valid and comes from the payment provider. It is paramount that this hash is thoroughly checked.
@@ -147,6 +147,13 @@ Route::post('/pay', [
'as' => 'pay'
]);
```
+OR
+
+```php
+// Laravel 8 & 9
+Route::post('/pay', [App\Http\Controllers\PaymentController::class, 'redirectToGateway'])->name('pay');
+```
+
```php
Route::get('/payment/callback', 'PaymentController@handleGatewayCallback');
@@ -161,6 +168,13 @@ Route::get('payment/callback', [
]);
```
+OR
+
+```php
+// Laravel 8 & 9
+Route::get('/payment/callback', [App\Http\Controllers\PaymentController::class, 'handleGatewayCallback']);
+```
+
```php
redirectNow();
+ try{
+ return Paystack::getAuthorizationUrl()->redirectNow();
+ }catch(\Exception $e) {
+ return Redirect::back()->withMessage(['msg'=>'The paystack token has expired. Please refresh the page and try again.', 'type'=>'error']);
+ }
}
/**
@@ -200,6 +219,28 @@ class PaymentController extends Controller
}
```
+```php
+/**
+ * In the case where you need to pass the data from your
+ * controller instead of a form
+ * Make sure to send:
+ * required: email, amount, reference, orderID(probably)
+ * optionally: currency, description, metadata
+ * e.g:
+ *
+ */
+$data = array(
+ "amount" => 700 * 100,
+ "reference" => '4g4g5485g8545jg8gj',
+ "email" => 'user@mail.com',
+ "currency" => "NGN",
+ "orderID" => 23456,
+ );
+
+return Paystack::getAuthorizationUrl($data)->redirectNow();
+
+```
+
Let me explain the fluent methods this package provides a bit here.
```php
/**
@@ -264,7 +305,7 @@ Paystack::getAllTransactions();
paystack()->getAllTransactions();
/**
- * This method generates a unique super secure cryptograhical hash token to use as transaction reference
+ * This method generates a unique super secure cryptographic hash token to use as transaction reference
* @returns string
*/
Paystack::genTranxRef();
@@ -325,10 +366,27 @@ paystack()->updateSubAccount();
A sample form will look like so:
+```php
+ "percentage",
+ "currency" => "KES",
+ "subaccounts" => [
+ [ "subaccount" => "ACCT_li4p6kte2dolodo", "share" => 10 ],
+ [ "subaccount" => "ACCT_li4p6kte2dolodo", "share" => 30 ],
+ ],
+ "bearer_type" => "all",
+ "main_account_share" => 70
+];
+?>
+```
+
```html