Skip to content

Commit

Permalink
Merge pull request #23 from ali-alharthi/master
Browse files Browse the repository at this point in the history
Major update (breaking changes)
  • Loading branch information
wshurafa committed Jun 14, 2022
2 parents 6dff41b + cd00f63 commit 269bd51
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 2,310 deletions.
135 changes: 89 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,67 @@ contribution.

You have to read the `Payfort` documentation very well before proceeding in using any package, the package author
will not write about `Payfort` operations, what and how to use.

## Install

You can install `Laravel Payfort` package to your laravel project via composer command:
```
$ composer require wshurafa/laravel-payfort
```

## Configuration

##### For Laravel < 5.5 (Package Auto Discovery : Skip the following two step for laravel 5.5+ )

After installing the `Laravel Payfort` library, register the `LaravelPayfort\Providers\PayfortServiceProvider`
in your `config/app.php` configuration file:

```php
'providers' => [
// Other service providers...
## Installation

LaravelPayfort\Providers\PayfortServiceProvider::class,
],
You can install the package via composer:
```bash
composer require wshurafa/laravel-payfort
```

Also, add the `Payfort` facade to the `aliases` array in your `app` configuration file:
```php
'Payfort' => LaravelPayfort\Facades\Payfort::class
You can publish the config file with:
```bash
php artisan vendor:publish --provider "LaravelPayfort\Providers\PayfortServiceProvider"
```
This is the contents of the file that will be published at `config/payfort.php` :

After that, run the following command to publish the configurations file:
```
$ php artisan vendor:publish --provider "LaravelPayfort\Providers\PayfortServiceProvider"
```
This will create a new config file named `payfort.php` in `config` folder. Then you have to add the following
constants in the `.env` file, you can find most of these values in your `Payfort` account.
```php
return [
/**
* Defines wether to activate the Payfort sandbox enviroment or not.
*/
'sandbox' => env('PAYFORT_USE_SANDBOX', false),

/**
* The Payfort merchant account identifier.
*/
'merchant_identifier' => env('PAYFORT_MERCHANT_IDENTIFIER'),

/**
* The Payfort account access code.
*/
'access_code' => env('PAYFORT_ACCESS_CODE'),

/**
* The Payfort account sha type (sha256/sha512).
*/
'sha_type' => env('PAYFORT_SHA_TYPE', 'sha256'),

/**
* The Payfort account sha request phrase.
*/
'sha_request_phrase' => env('PAYFORT_SHA_REQUEST_PHRASE'),

/**
* The Payfort account sha response phrase.
*/
'sha_response_phrase' => env('PAYFORT_SHA_RESPONSE_PHRASE'),

/**
* The default currency for you app. Currency ISO code 3.
*/
'currency' => env('PAYFORT_CURRENCY', 'USD'),

/**
* The URL to return after submitting Payfort forms.
*/
'return_url' => env('PAYFORT_RETURN_URL', '/')
];
```

### Then you have to add the following constants in the `.env` file:

```bash
PAYFORT_USE_SANDBOX=true # Defines wether to activate the payfort sandbox enviroment or not.
PAYFORT_MERCHANT_IDENTIFIER=s2b3rj1vrjrhc1x # The payfort merchant account identifier
PAYFORT_ACCESS_CODE=s31bpM1ebfNnwqo # The payfort account access code
Expand All @@ -58,9 +84,12 @@ PAYFORT_SHA_REQUEST_PHRASE=keljhgiergh # The payfort account sha request
PAYFORT_SHA_RESPONSE_PHRASE=lkejgoegj # The payfort account sha response phrase
PAYFORT_CURRENCY=USD # The default currency for you app. Currency ISO code 3.
PAYFORT_RETURN_URL=/payfort/handle # The url to return after submitting payfort forms.
```

## Basic Usage
```

You can find most of these values in your `Payfort` account


## Usage

Once all configuration steps are done, you are ready to use payfort operations in your app. Here is some examples on
how to use this package:
Expand All @@ -79,20 +108,19 @@ return Payfort::redirection()->displayRedirectionPage([
]);
```
Other optional parameters that can be passed to `displayRedirectionPage` method as follows:
* token_name
* payment_option
* sadad_olp
* eci
* order_description
* customer_ip
* customer_name
* merchant_extra
* merchant_extra1
* merchant_extra2
* merchant_extra3

`Payfort` page will be displayed and once user submits the payment form, the return url defined in the environment
configurations will be called.
* `token_name`
* `payment_option`
* `sadad_olp`
* `eci`
* `order_description`
* `customer_ip`
* `customer_name`
* `merchant_extra`
* `merchant_extra1`
* `merchant_extra2`
* `merchant_extra3`

`Payfort` page will be displayed and once user submits the payment form, the return url defined in the environment configurations will be called.

See [`Payfort` documentation](https://docs.payfort.com/docs/redirection/build/index.html#authorization-purchase-request) for more info.

Expand Down Expand Up @@ -135,7 +163,22 @@ See [`Payfort` documentation](https://docs.payfort.com/docs/redirection/build/in
#### Handling Direct Transaction Feedback

Same as handling payfort response except that you have to call `handlePayfortFeedback` instead of `handlePayfortCallback`



### Localization

The redirect page can be translated by simply using the json file of the language wihtin the `lang` directory of your app.

For example, `ar.json` file:
```
{
...
"Payment redirect page": "صفحة إعادة توجيه الدفع",
"Click here to proceed to payment if you are not automatically redirected": "انقر هنا لمتابعة الدفع إذا لم تتم إعادة توجيهك تلقائيًا",
...
}
```

## Contribution
Want to improve this package or found a bug ?. Open an issue or do this contribution by yourself and get this honor.

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=5.5.9",
"illuminate/support": "~5.0",
"nesbot/carbon": "~2.0",
"guzzlehttp/guzzle": "~5.0|~6.0"
"php": "^8.0",
"illuminate/support": "^8.50|^9.0",
"nesbot/carbon": "^2.0",
"guzzlehttp/guzzle": "^7.2"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"fabpot/goutte": "~3.2"
"phpunit/phpunit": "^9.3",
"fabpot/goutte": "^4.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 269bd51

Please sign in to comment.