Download the PHP package thehocinesaad/laravel-chargily-epay without Composer

On this page you can find all versions of the php package thehocinesaad/laravel-chargily-epay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-chargily-epay

Laravel-Chargily-ePay

Laravel-Chargily-ePay is a Laravel package that provides an easy interface to Chargily Pay gateway.

Features

Installation

Step 1 - Require the package

composer require thehocinesaad/laravel-chargily-epay

Step 2: Publish migrations

php artisan vendor:publish --provider="TheHocineSaad\LaravelChargilyEPay\LaravelChargilyEPayServiceProvider" --tag="migrations"

Step 3: Run migrations

php artisan migrate

Step 4: Edit .env file

This package requires these keys:

Important: CHARGILY_EPAY_BACK_URL and CHARGILY_EPAY_WEBHOOK_URL should be real URLs, so you can't put http://127.0.0.1:8000, use Ngrok.

Step 5: Epayable trait

Add the Epayable trait to your User model:

Step 6 (optional): Publishing

Config File:

php artisan vendor:publish --provider="JohnDoe\BlogPackage\BlogPackageServiceProvider" --tag="config"

Models

php artisan vendor:publish --provider="TheHocineSaad\LaravelChargilyEPay\LaravelChargilyEPayServiceProvider" --tag="models"

Using the package

Creating an Epay Invoice

To create an Invoice, you can te use the static Make() function from the Epay_Invoice model:

The Make() function returns the checkout URL, where the user should be redirected to make a payment, If any error occurs, it will return to the home page, so make sure to check this before redirecting the user.

The Make() also creates an invoice in your database using the info from the provided $configurations array, so if you added columns to the migration file of the invoices table that comes with the package, you have to add the corresponding values as a second array, example:

As you saw in the example above, we added the value of product_id, that's because you may be added product_id field in the migration file.

Creating an Epay Invoice for a User

The other way (Recommended way) to create Epay Invoices is to use the charge() custom model method which is provided by the Epayable trait, this method will automatically add the name of the client, the email of the client, and the client_id foreign key:

The charge() method calls the Make() static function at a certain point, so they act the same way, it returns the checkout URL, or the home page URL if any error occurs.

Just like the Make() function, you can add a second array to pass any added columns to the invoices table.

Payment Webhook

After a user complete the payment of an invoice, Chargily ePay will notify you by sending a post request to your Webhook, so you can handle the things you would like to happen after a successful or a failed payment.

So, go ahead and create a POST Route (ex: "/webhook"), by the way, this is the URL you should add to the CHARGILY_EPAY_WEBHOOK_URL key in the .env file.

Important: You have to exclude this URL from CSRF verification, to do so, add it to the except method in your applications's App\Http\Middleware\VerifyCsrfToken middleware:

Here is the code you should put in this route as a starting point:

Note: You can access the ID of the Invoice by: $webhookHandler -> invoice['invoice_number']

Here is an example of the data that comes with the post request from Chargily Pay:

Testing your Webhook

I added an internal feature to simulate a payment of an invoice to test your webhook without the need to use Postman, after installing this package, you will automatically have a new route /epay-webhook-tester, navigate to it, put the ID of the invoice you want to simulate its payment and click on PAY.

Important: When you run your application using the local server php artisan serve, it will work on a single thread, so making post requests to itself will give you a timeout error, on a server, this is not a problem because it will use Apache or Nginx, the solution is to start another local server on another port (ex: 8001) and use this feature from there. Example:

  1. Run php artisan serve so you will have your app on http://127.0.0.1:8000.
  2. In another terminal instance, run php artisan serve --port=8001 then visit http://127.0.0.1:8001/epay-webhook-tester, not http://127.0.0.1:8000/epay-webhook-tester

Note: for security purposes, this feature works only on the local environment (APP_ENV=local), and am sure it's not needed in production.

Test Chargily Pay

Info

This Laravel package is built on top of this PHP package, so have a look at it to know more about what's happening under the hood.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

Laravel-Chargily-ePay project is open-sourced software licensed under the MIT license.


All versions of laravel-chargily-epay with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
chargily/epay-php Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package thehocinesaad/laravel-chargily-epay contains the following files

Loading the files please wait ....