Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-tharwat committed Sep 24, 2022
0 parents commit e86dd37
Show file tree
Hide file tree
Showing 15 changed files with 1,040 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016-2020, maherelgamil packages,

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
164 changes: 164 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
ssssssss# Nafezly Payment Gateways
Payment Helper of Payment Gateways ( PayPal - Paymob - Fawry - Thawani - WeAccept - Kashier - Hyperpay )
![payment-gateways.png](https://github.com/nafezly/payments/blob/master/payment-gateways.png?raw=true)


## Supported gateways

- [PayPal](https://paypal.com/)
- [PayMob](https://paymob.com/)
- [WeAccept](https://paymob.com/)
- [Kashier](https://kashier.io/)
- [Fawry](https://fawry.com/)
- [HyperPay](https://www.hyperpay.com/)
- [Thawani](https://https://thawani.om/)

## Installation

```jsx
composer require nafezly/payments
```

## Publish Vendor Files

```jsx
php artisan vendor:publish --tag="nafezly-payments-config"
php artisan vendor:publish --tag="nafezly-payments-migrations"
```

## Migrate The Migration File

```jsx
php artisan migrate
//it will add status,payment_id,amount,process_data columns if not exists in orders table
```

### nafezly-payments.php file

```php
<?php
return [

#PAYMOB
'PAYMOB_API_KEY'=>env('PAYMOB_API_KEY'),
'PAYMOB_INTEGRATION_ID'=>env('PAYMOB_INTEGRATION_ID'),
'PAYMOB_IFRAME_ID'=>env('PAYMOB_IFRAME_ID'),
'PAYMOB_HMAC'=>env('PAYMOB_HMAC'),

#HYPERPAY
'HYPERPAY_BASE_URL'=>env('HYPERPAY_BASE_URL',"https://eu-test.oppwa.com"),
'HYPERPAY_URL'=>env('HYPERPAY_URL',env('HYPERPAY_BASE_URL')."/v1/checkouts"),
'HYPERPAY_TOKEN'=>env('HYPERPAY_TOKEN'),
'HYPERPAY_CREDIT_ID'=>env('HYPERPAY_CREDIT_ID'),
'HYPERPAY_MADA_ID'=>env('HYPERPAY_MADA_ID'),
'HYPERPAY_APPLE_ID'=>env('HYPERPAY_APPLE_ID'),
'HYPERPAY_CURRENCY'=>env('HYPERPAY_CURRENCY',"SAR"),

#KASHIER
'KASHIER_ACCOUNT_KEY'=>env('KASHIER_ACCOUNT_KEY'),
'KASHIER_IFRAME_KEY'=>env('KASHIER_IFRAME_KEY'),
'KASHIER_URL'=>env('KASHIER_URL',"https://checkout.kashier.io"),
'KASHIER_MODE'=>env('KASHIER_MODE',"test"), //live or test

#FAWRY
'FAWRY_URL'=>env('FAWRY_URL',"https://atfawry.fawrystaging.com/"),//or https://www.atfawry.com/ for production
'FAWRY_SECRET'=>env('FAWRY_SECRET'),
'FAWRY_MERCHANT'=>env('FAWRY_MERCHANT'),

#PayPal
'PAYPAL_CLIENT_ID'=>env('PAYPAL_CLIENT_ID'),
'PAYPAL_SECRET'=>env('PAYPAL_SECRET'),
'PAYPAL_CURRENCY'=>env('PAYPAL_CURRENCY',"USD"),

#THAWANI
'THAWANI_API_KEY'=>env('THAWANI_API_KEY','rRQ26GcsZzoEhbrP2HZvLYDbn9C9et'),
'THAWANI_URL'=>env('THAWANI_URL',"https://uatcheckout.thawani.om/"),
'THAWANI_PUBLISHABLE_KEY'=>env('THAWANI_PUBLISHABLE_KEY','HGvTMLDssJghr9tlN9gr4DVYt0qyBy')

];
```
## Put keys in .env File
```php



PAYMOB_API_KEY=
PAYMOB_INTEGRATION_ID=
PAYMOB_IFRAME_ID=
PAYMOB_HMAC=

HYPERPAY_BASE_URL=
HYPERPAY_URL=
HYPERPAY_TOKEN=
HYPERPAY_CREDIT_ID=
HYPERPAY_MADA_ID=
HYPERPAY_APPLE_ID=
HYPERPAY_CURRENCY=

KASHIER_ACCOUNT_KEY=
KASHIER_IFRAME_KEY=
KASHIER_URL=
KASHIER_MODE=

FAWRY_URL=
FAWRY_SECRET=
FAWRY_MERCHANT=

PAYPAL_CLIENT_ID=
PAYPAL_SECRET=
PAYPAL_CURRENCY=

THAWANI_API_KEY=
THAWANI_URL=
THAWANI_PUBLISHABLE_KEY=



```

## Web.php MUST Have Route with name “payment-verify”

```php
Route::get('/payments/verify/{payment?}',[FrontController::class,'payment_verify'])->name('payment-verify');
```

## How To Use

```jsx
use Nafezly\Payments\ThawaniPayment;

$payment = new PaymobPayment();
//pay
$payment->pay($order);
//verify
$payment->verify($request);

```

## Available Classes

```php

$payment = new \Nafezly\Payments\FawryPayment();
$payment = new \Nafezly\Payments\HyperPayPayment();
$payment = new \Nafezly\Payments\KashierPayment();
$payment = new \Nafezly\Payments\PaymobPayment();
$payment = new \Nafezly\Payments\PayPalPayment();
$payment = new \Nafezly\Payments\ThawaniPayment();
```

## Test Cards

```php
# Thawani
[https://docs.thawani.om/docs/thawani-ecommerce-api/ZG9jOjEyMTU2Mjc3-thawani-test-card](https://docs.thawani.om/docs/thawani-ecommerce-api/ZG9jOjEyMTU2Mjc3-thawani-test-card)

# Kashier
[https://developers.kashier.io/payment/testing](https://developers.kashier.io/payment/testing)

# Paymob
[https://docs.paymob.com/docs/card-payments](https://docs.paymob.com/docs/card-payments)

# Fawry
[https://developer.fawrystaging.com/docs/testing/testing](https://developer.fawrystaging.com/docs/testing/testing)
```
31 changes: 31 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "nafezly/payments",
"license": "MIT",
"description":"paymant helper for Paypal,Paymob,Kashier,Hyperpay,Fawry",
"autoload": {
"psr-4": {
"Nafezly\\Payments\\": "src/"
}
},
"require": {
"php": ">=7.0",
"laravel/framework": ">=6.0",
"paypal/paypal-checkout-sdk": "1.0.2"
},
"authors": [
{
"name": "nafezly.com",
"email": "[email protected]"
}
],
"extra": {
"laravel": {
"providers": [
"Nafezly\\Payments\\NafezlyPaymentsServiceProvider"
],
"aliases": {
"NafezlyPayments": "Nafezly\\Payments\\Facades"
}
}
}
}
65 changes: 65 additions & 0 deletions config/nafezly-payments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
return [


#PAYMOB
'PAYMOB_API_KEY'=>env('PAYMOB_API_KEY'),
'PAYMOB_INTEGRATION_ID'=>env('PAYMOB_INTEGRATION_ID'),
'PAYMOB_IFRAME_ID'=>env('PAYMOB_IFRAME_ID'),
'PAYMOB_HMAC'=>env('PAYMOB_HMAC'),





#HYPERPAY
'HYPERPAY_BASE_URL'=>env('HYPERPAY_BASE_URL',"https://eu-test.oppwa.com"),
'HYPERPAY_URL'=>env('HYPERPAY_URL',env('HYPERPAY_BASE_URL')."/v1/checkouts"),
'HYPERPAY_TOKEN'=>env('HYPERPAY_TOKEN'),
'HYPERPAY_CREDIT_ID'=>env('HYPERPAY_CREDIT_ID'),
'HYPERPAY_MADA_ID'=>env('HYPERPAY_MADA_ID'),
'HYPERPAY_APPLE_ID'=>env('HYPERPAY_APPLE_ID'),
'HYPERPAY_CURRENCY'=>env('HYPERPAY_CURRENCY',"SAR"),






#KASHIER
'KASHIER_ACCOUNT_KEY'=>env('KASHIER_ACCOUNT_KEY'),
'KASHIER_IFRAME_KEY'=>env('KASHIER_IFRAME_KEY'),
'KASHIER_URL'=>env('KASHIER_URL',"https://checkout.kashier.io"),
'KASHIER_MODE'=>env('KASHIER_MODE',"test"), //live or test






#FAWRY
'FAWRY_URL'=>env('FAWRY_URL',"https://atfawry.fawrystaging.com/"),//or https://www.atfawry.com/ for production
'FAWRY_SECRET'=>env('FAWRY_SECRET'),
'FAWRY_MERCHANT'=>env('FAWRY_MERCHANT'),





#PayPal
'PAYPAL_CLIENT_ID'=>env('PAYPAL_CLIENT_ID'),
'PAYPAL_SECRET'=>env('PAYPAL_SECRET'),
'PAYPAL_CURRENCY'=>env('PAYPAL_CURRENCY',"USD"),




#THAWANI
'THAWANI_API_KEY'=>env('THAWANI_API_KEY','rRQ26GcsZzoEhbrP2HZvLYDbn9C9et'),
'THAWANI_URL'=>env('THAWANI_URL',"https://uatcheckout.thawani.om/"),
'THAWANI_PUBLISHABLE_KEY'=>env('THAWANI_PUBLISHABLE_KEY','HGvTMLDssJghr9tlN9gr4DVYt0qyBy'),


'verify_route_name'=>"verify-payment"

];
42 changes: 42 additions & 0 deletions database/migrations/2030_09_29_154000_update_orders_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class UpdateOrdersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('orders', function (Blueprint $table) {
if(!$table->hasColumn('status'))
$table->string('status')->default("PENDING");
if(!$table->hasColumn('payment_id'))
$table->string('payment_id')->index()->nullable();
if(!$table->hasColumn('amount'))
$table->decimal('amount',8,3)->default(0.0);
if(!$table->hasColumn('process_data'))
$table->text('process_data')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('orders', function (Blueprint $table) {
$table->dropColumn('status');
$table->dropColumn('payment_id');
$table->dropColumn('amount');
$table->dropColumn('process_data');
});
}
}
Binary file added payment-gateways.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/Facades/NafezlyPaymentsFacade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Nafezly\Payments\Facades;

use Illuminate\Support\Facades\Facade;

class NafezlyPayments extends Facade
{
protected static function getFacadeAccessor()
{
return 'nafezly';
}
}
Loading

0 comments on commit e86dd37

Please sign in to comment.