Download the PHP package thejano/fib-payment-laravel without Composer

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

thejano/fib-payment-laravel

Latest Version on Packagist Tests Total Downloads PHP Version Support License

A Laravel package for integrating with the First Iraqi Bank (FIB) online-shop payment API. Supports payment creation, status checks, cancellation, refunds, and typed error handling via OAuth2 client-credentials authentication.

Features

Feature ↔ API coverage

Feature Method FIB endpoint
Authenticate FibPayment::getToken() POST /auth/realms/fib-online-shop/protocol/openid-connect/token
Create payment FibPayment::create() POST /protected/v1/payments
Check status FibPayment::status() GET /protected/v1/payments/{id}/status
Cancel payment FibPayment::cancel() POST /protected/v1/payments/{id}/cancel
Refund payment FibPayment::refund() POST /protected/v1/payments/{id}/refund
Status callback (your route) FIB POSTs to FIB_PAYMENT_CALLBACK_URL

Requirements

The CI suite runs against Laravel 11, 12, and 13 on PHP 8.3 and 8.4 (see .github/workflows/tests.yml).

Installation

Install the package via Composer:

Publish the config file:

Configuration

Add the following variables to your .env file:

Variable Required Default Description
FIB_PAYMENT_ENV Yes stage Active environment: dev, stage, or production
FIB_PAYMENT_DEV_URL No https://fib.dev.fib.iq Base URL for the dev environment
FIB_PAYMENT_STAGE_URL No https://fib.stage.fib.iq Base URL for the stage environment
FIB_PAYMENT_PROD_URL No https://fib.prod.fib.iq Base URL for the production environment
FIB_PAYMENT_CLIENT_ID Yes OAuth2 client ID issued by FIB
FIB_PAYMENT_CLIENT_SECRET Yes OAuth2 client secret issued by FIB
FIB_PAYMENT_CALLBACK_URL Yes URL FIB will POST to when a payment status changes
FIB_PAYMENT_CURRENCY No IQD Default currency for payments

Usage

All operations are accessed through the FibPayment facade.

Lifecycle: you create() a payment and present its QR code / app links to the customer. The payment starts as UNPAID; once the customer pays it becomes PAID, and FIB calls your callback URL. A payment can be cancel()ed while unpaid, or refund()ed after it is paid (within the refundable window). At any point you can poll status() for the authoritative state.

Create a Payment

Response structure:

Field Description
paymentId Unique payment identifier — use this for status checks, cancellation, and refunds
readableCode Human-readable code the customer can enter manually if they cannot scan the QR code
qrCode Base64-encoded data URL of the QR code image for scanning with the FIB mobile app
validUntil ISO-8601 datetime when the payment expires
personalAppLink Deep link to the payment screen in the FIB Personal app
businessAppLink Deep link to the payment screen in the FIB Business app
corporateAppLink Deep link to the payment screen in the FIB Corporate app

Supported $options keys

Key Type Description
currency string Currency code (overrides FIB_PAYMENT_CURRENCY), e.g. IQD
callbackUrl string Per-payment callback URL (overrides FIB_PAYMENT_CALLBACK_URL)
expiresIn string ISO-8601 duration for payment expiry, e.g. PT12H (12 hours)
refundableFor string ISO-8601 duration during which the payment can be refunded, e.g. P7D (7 days)
category string Payment category, e.g. ECOMMERCE
redirectUri string URI the FIB app redirects to after the customer completes payment

Description is automatically trimmed to 50 characters (multibyte-safe).

Check Payment Status

Response structure:

Field Description
paymentId The payment's unique identifier
status One of PAID, UNPAID, or DECLINED
validUntil ISO-8601 datetime when the payment expires
amount Object with amount (number) and currency (string)
decliningReason null, or one of SERVER_FAILURE, PAYMENT_EXPIRATION, PAYMENT_CANCELLATION
declinedAt ISO-8601 datetime of decline, or null
paidBy null while unpaid; object with name and iban of the payer once paid

Cancel a Payment

Refund a Payment

Only PAID payments within the configured refundable window can be refunded.

Retrieve an Access Token

Handling Status-Change Callbacks (Webhooks)

When a payment's status changes, FIB sends a POST request to your FIB_PAYMENT_CALLBACK_URL (or the per-payment callbackUrl option). The request body contains two fields:

This package does not register a route for you — you own the endpoint so you can apply your own middleware, validation, and queueing. The recommended pattern is to treat the callback as a trigger and re-fetch the authoritative status from FIB rather than trusting the payload:

Remember to add the callback path to the CSRF exception list (VerifyCsrfToken::$except in Laravel 9–10, or $middleware->validateCsrfTokens(except: [...]) in Laravel 11+).

Using the Services Directly (Dependency Injection)

The facade is a thin wrapper over two container-resolvable services. If you prefer constructor injection — for example, to keep classes explicit and easy to test in isolation — resolve PaymentService and AuthService directly:

PaymentService exposes the same create(), status(), cancel(), and refund() methods as the facade; AuthService::getAccessToken() returns the raw token. Both are bound through the container, so Laravel autowires them anywhere dependency injection is available.

Error Handling

All methods throw TheJano\FibPayment\Exceptions\FibPaymentException on any 4xx or 5xx response. Use getStatusCode() to retrieve the HTTP status and getResponseBody() to inspect the API error payload.

Error-handling caveats

Network failures: FibPaymentException is thrown when the FIB API returns a response (4xx/5xx). A low-level network failure (DNS error, connection timeout, etc.) surfaces instead as Laravel's Illuminate\Http\Client\ConnectionException, which callers should also catch if needed.

No token caching: The OAuth2 access token is never cached or stored. Every create, status, cancel, refund, or getToken call performs a fresh client-credentials authentication against FIB.

Instance caching: The FibPayment facade resolves a singleton whose AuthService and PaymentService objects are constructed once per process (config is read at construction time). This caches the service instances only — not the token. It is not designed to pick up runtime config changes within a long-lived worker such as Laravel Octane. Re-deploy or restart the worker to apply config changes.

Testing

Run the package's own suite:

The test suite uses Pest and Orchestra Testbench.

Testing your integration

Because every request goes through Laravel's Http client, you can fake FIB entirely in your own application's tests — no network calls, no credentials:

License

The thejano/fib-payment-laravel package is open-source software licensed under the MIT License.

fib-payment-laravel


All versions of fib-payment-laravel with dependencies

PHP Build Version
Package Version
Requires ext-mbstring Version *
illuminate/http Version ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
php Version >=8.1
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 thejano/fib-payment-laravel contains the following files

Loading the files please wait ...