PHPackages                             bewarhizirvan/fib-laravel-paik - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. bewarhizirvan/fib-laravel-paik

ActiveLibrary[Payment Processing](/categories/payments)

bewarhizirvan/fib-laravel-paik
==============================

Laravel SDK for integrating with the FIB payment system, enabling user authentication and payment transactions.

1.4.1(1y ago)03MITPHPPHP ^8.1

Since Apr 15Pushed 1y agoCompare

[ Source](https://github.com/bewarhizirvan/fib-laravel-paik)[ Packagist](https://packagist.org/packages/bewarhizirvan/fib-laravel-paik)[ RSS](/packages/bewarhizirvan-fib-laravel-paik/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

FIB Laravel Payment SDK
=======================

[](#fib-laravel-payment-sdk)

The FIB Laravel Payment SDK provides a seamless integration with the FIB payment system for Laravel applications, enabling secure and efficient payment transactions and refund handling.

**Table of Contents**

- [Features](#features)
- [Installation](#installation)
    - [Composer Installation](#composer-installation)
    - [Alternative Installation (Without Composer)](#alternative-installation-without-composer)
- [Registering the Service Provider and Running Migrations](#Registering-the-Service-Provider-and-Running-Migrations)
- [Usage](#usage)
    - [Creating a Payment](#creating-a-payment)
    - [Checking Payment Status](#checking-payment-status)
    - [Refunding a Payment](#refunding-a-payment)
    - [Cancelling a Payment](#cancelling-a-payment)
    - [Handling Payment Callbacks](#handling-payment-callbacks)
- [FIB Payment Documentation](#fib-payment-documentation)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)
- [Support](#support)
- [Acknowledgments](#acknowledgments)
- [Versioning](#versioning)
- [FAQ](#faq)

Features
--------

[](#features)

- **Payment Transactions**: Facilitate secure payments through the FIB payment system directly in your Laravel application.
- **Refund Processing**: Manage refunds through the FIB payment system with ease.
- **Payment Status Checking**: Retrieve the status of payments to ensure proper transaction tracking.
- **Payment Cancellation**: Cancel payments as needed through the FIB payment system.

Installation
------------

[](#installation)

To integrate the SDK into your Laravel project, install it via Composer:

```
composer require First-Iraqi-Bank/fib-laravel-payment-sdk
```

### Alternative Installation (Without Composer)

[](#alternative-installation-without-composer)

If you prefer not to use Composer, follow these steps:

- **Clone the Repository**: Clone the FIB Payment SDK repository:

    ```
    git clone https://github.com/First-Iraqi-Bank/fib-laravel-payment-sdk.git
    ```
- **Include in Your Project**: Move or copy the cloned `fib-laravel-payment-sdk` directory into your Laravel project.
- **Autoloading**: Ensure that the `src` directory of the SDK is included in your `composer.json` autoloader configuration if not using Composer:

    ```
    {
        "autoload": {
            "psr-4": {
                "FirstIraqiBank\\FIBPaymentSDK\\": "path/to/fib-laravel-payment-sdk/src"
            }
        }
    }
    ```
- **Usage**: After including the SDK, use its classes and functionality in your Laravel application.

Registering the Service Provider and Running Migrations
-------------------------------------------------------

[](#registering-the-service-provider-and-running-migrations)

### Step 1: Register the Service Provider

[](#step-1-register-the-service-provider)

Before using the SDK, ensure that you register the `FIBPaymentServiceProvider`. This service provider binds the SDK's services into the Laravel service container and loads necessary resources like routes, migrations, and configurations.

#### For Laravel 10 and Lower:

[](#for-laravel-10-and-lower)

In your config/app.php file, add the following to the providers array:

```
'providers' => [
    // Other Service Providers...

    FirstIraqiBank\FIBPaymentSDK\FIBPaymentServiceProvider::class,
],
```

#### For Laravel 11 and Higher:

[](#for-laravel-11-and-higher)

In Laravel 11, service providers are registered in the bootstrap/providers.php file. To register the FIBPaymentServiceProvider, add it to the returned array in the bootstrap/providers.php file like this:

```

return [
    // Other service providers...

    FirstIraqiBank\FIBPaymentSDK\FIBPaymentServiceProvider::class,
];

```

### Step 2: Publish the Configuration

[](#step-2-publish-the-configuration)

To customize the SDK's configuration, you need to publish the configuration file. Run the following Artisan command:

```
php artisan vendor:publish --tag=fib-payment-sdk-config
```

This will publish the SDK configuration file to your application's `config/fib.php` file, where you can modify the SDK's behavior according to your needs.

### Step 3: Running Migrations

[](#step-3-running-migrations)

The SDK comes with migration files that create the necessary database tables. To run these migrations, use the following Artisan command:

```
php artisan migrate
```

This command will execute the migration files located in the SDK's `database/migrations` directory and create the required database tables.

Add the following environment variables to your `.env` file:

- `FIB_API_KEY`: Your FIB payment API key.
- `FIB_API_SECRET`: Your FIB payment API secret.
- `FIB_BASE_URL`: The base URL for the FIB payment API (default: ).
- `FIB_GRANT_TYPE`: The grant type for authentication (default: client\_credentials).
- `FIB_REFUNDABLE_FOR`: The period for which transactions can be refunded (default: P7D).
- `FIB_CURRENCY`: The currency used for transactions (default: IQD).
- `FIB_CALLBACK_URL`: The callback URL for payment notifications.
- `FIB_ACCOUNT`: The FIB payment account identifier.

### Usage of the SDK

[](#usage-of-the-sdk)

#### Ensure Dependencies are Installed:

[](#ensure-dependencies-are-installed)

Install required dependencies using Composer:

```
composer install
```

#### Set Up Environment Variables:

[](#set-up-environment-variables)

Create a `.env` file in the root directory of your Laravel project and set the necessary environment variables.

#### Creating a Payment

[](#creating-a-payment)

Here's an example of how to create a payment:

```
