Download the PHP package devinweb/laravel-paytabs without Composer

On this page you can find all versions of the php package devinweb/laravel-paytabs. 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-paytabs

Laravel Paytabs

Latest Version on Packagist Total Downloads StyleCI Shield codecov GitHub Actions

Laravel Paytabs makes integration with PayTabs payment gateway easier for Laravel developers, and that's by offering a wide range of functions to consume the paytabs transactions API.

Requirements

This package requires php 7.4 or higher.

Installation

You can install the package via composer:

Database migration

This package provides a migration to handle the transactions. You need to publish the migration file after the installation.

Then, you need to migrate the transactions table.

Setup and configuration

You can also publish the config file using

After that, you can see the file in app/paytabs.php and update it. You might need to change the model variable to use your custom User model.

Paytabs Keys

Before being able to use this package, you should configure your paytabs environment in your application's .env file.

Usage

Transaction type enum

The transaction types that Paytabs supports are described by this abstract class. There are five different sorts of transactions: sale, auth, refund, void, and capture. This class makes it simple to find and use these values:

It can be used also to validate if the given type is a follow-up type or an initiate one.

Transaction class enum

TansactionClass describes the possible values that the transaction class could take, just like TransactionType does. The value may be recurring, ecom, or moto. This package currently only supports the ecom type.

You can use this static function to obtain the supported values.

Initiate a payment (Genarate a hosted payment page)

To create a paytabs transaction using this package, you need to initiate the payment first to generate the form link. Then you can visit the generated page or embed it in your app to finalize the payment. The process to do that and the options available are described in the following sections.

Set the customer details

To initiate a payment, you need to specify the user model using setCustomer method. The $user should be an instance of Illuminate\Database\Eloquent\Model and the used fields are: name, email and phone. The phone is optional. A value of type LaravelPaytabsFacade will be returned.

Set cart details

You need also to set the shopping cart details using the setCart function. A three-key array with the keys id, amount, and description should form $cart. A value of type LaravelPaytabsFacade will be returned.

Set redirect url

The redirect url must be included in your request. The user will be sent back to this URL after the payment has been processed.

⚠️ If you use one redirect url for all the payments inside your project, you can add it to the .env as explained above.

Framed Hosted Payment Page

To display the hosted payment page in an embed frame within the merchant website, you can call framedPage. A value of type LaravelPaytabsFacade will be returned.

Billing

If you want to display the billing section prefilled on the payment page, you can set the billing details by creating the billing class using this command. You can find all the billing files in app/Billing the folder.

then use

The getData method of the created class should return an array with keys: street1, city, state, country, zip and ip. If you added all this values, you can hide the billing section from the hosted payment page using hideBilling function.

Shipping

The same way as billing, you can use display the shipping section prefilled on the payment page. Create the shipping class and then add the shipping details.

You may occasionally include digital products among the services you offer to customers, in which case you won't require their shipping information. You can use hideShipping option to hide shipping details section from the generated Hosted payment page. A value of type LaravelPaytabsFacade will be returned.

⚠️️ If the billing details are already added, this function will hide the billing section as well.

Generate the hosted payment page

After setting all the payment page details and parameters, you need to use the initiate function to call the Paytabs Transactions Api and initiate your payment. The transaction type can be sale or auth.

If the payment page is created successfully, you will receive a response such as shown below including the payment page URL (redirect_url). A row with status=pending will be added to the transactions table and a TransactionInitiated event will be fired.

After visiting the generated URL and finalizing your payment, the transaction status will be changed to paid or failed and you will be redirected to your return url. A TransactionSucceed or a TransactionFail event will be fired. The payment result details will be posted to the redirect URL, as the example shown below:

You can visit the paytabs official documentation to learn more about other paytabs Response Code/Status.

Follow up a transaction

After initiating or finalizing your payment, you may need to do some operations on it.

Get a transaction by reference

You can use this function to retrieve the details of a transaction such as its status, type, etc. The transactionRef represents the reference of the transaction returned in the responses as tran_ref and stored in transactions table as transaction_ref.

⚠️ You can visit the paytabs official documentation to learn more about payment_result section.

Refund, Capture or Void transaction

Refund request is available for those Authenticated Sale transactions or Authenticated Capture transactions.

Capture request is available for successfully Authenticated Authorize Transactions

Void requests are available for Authenticated Authorize transactions that are not fully captured yet.

To perform a refund, void or capture action on transaction using LaravelPaytabs, you need to set the user model (setCustomer), the transaction reference (setTransactionRef) and the cart details (setCart) as shown below, and pass the action type and class to the followUpTransaction.

A TransactionSucceed or TransactionFail event will be fired.

Events handlers

This package fires three events during the process of transaction: TransactionInitiated, TransactionSucceed and TransactionFail. Event Description
Devinweb\LaravelPaytabs\Events\TransactionInitiated Transaction initiated
Devinweb\LaravelPaytabs\Events\TransactionSucceed Successful transaction
Devinweb\LaravelPaytabs\Events\TransactionFail Transaction fail

The content of the events is the response returned by the transaction api.

Listener exemple

Use this laravel command to create a new listener

Then register the event with your listener in app/Providers/EventServiceProvider.

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Paytabs Boilerplate

You can use this repository to check the integration of the package laravel-paytabs-boilerplate.


All versions of laravel-paytabs with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4|^8.0
guzzlehttp/guzzle Version ^7.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 devinweb/laravel-paytabs contains the following files

Loading the files please wait ....