PHPackages                             nikolag/core - 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. nikolag/core

ActiveLaravel-package[Payment Processing](/categories/payments)

nikolag/core
============

Nikolag Core package for Laravel payment integrations that are not part of the Cashier

v3.0.1(5mo ago)335.3k↓32.5%63MITPHPPHP &gt;=8.2

Since Oct 5Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/NikolaGavric94/nikolag-core)[ Packagist](https://packagist.org/packages/nikolag/core)[ RSS](/packages/nikolag-core/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (23)Used By (3)

nikolag/core
============

[](#nikolagcore)

Core package for building additional payment gateway integrations with `nikolag` packages and `Laravel >=5.5`

Installation guide
------------------

[](#installation-guide)

`composer require nikolag/core`

---

Usage
-----

[](#usage)

This package contains all of the necessary code to get you started with building the additional integrations of payment gateways with `nikolag` packages. First of all there are couple of important layers and structure that you must follow:

1. [Configuration file](#1-configuration-file)
2. [Main service](#2-main-service)
3. [Dependency Injections](#3-dependency-injections)
4. [Migrations and Factories](#4-migrations-and-factories)
5. [Facades](#5-facades)
6. [Models](#6-models)
7. [Providers](#7-providers)
8. [Traits](#8-traits)
9. [Tests](#9-tests)
10. [Utility classes](#10-utility-classes)

### 1. Configuration file

[](#1-configuration-file)

Configuration file is the most important here since it'll contain all of the required pre-set options of your library. The file must be called **nikolag.php** and it must be inside of **src/config** folder.

```
return [
    /*
    |--------------------------------------------------------------------------
    | Nikolag Configuration
    |--------------------------------------------------------------------------
    |
    | This represents the default connection name that will be used when
    | u have multiple available connections. For all available connections
    | take a look a the code documentation of 'connections' just below.
    |
    */
    'default' => '{$default}',

    /*
    |--------------------------------------------------------------------------
    | Nikolag Connections
    |--------------------------------------------------------------------------
    |
    | Here you will find all available connections you have in your project.
    | For all available connections you can take a look at the link below.
    |
    | https://github.com/NikolaGavric94/nikolag-core/blob/master/DRIVERS.md
    |
    */
    'connections' => [
      /*
      |--------------------------------------------------------------------------
      | {$default} Configuration
      |--------------------------------------------------------------------------
      |
      | The {$default} configuration determines the default application_id
      | and {$default} token when doing any of the calls to {$default}. These values will
      | be used when there is no merchant provided as a seller. You have to change
      | these values.
      |
      */
      '{$default}' => [
        'namespace' => '{$namespace}',
        'application_id' => env('{$default}_APPLICATION_ID'),
        'access_token' => env('{$default}_TOKEN'),
        'sandbox' => env('{$default}_SANDBOX', false),

        /*
        |--------------------------------------------------------------------------
        | {$default} Merchant Configuration
        |--------------------------------------------------------------------------
        |
        | The {$default} merchant configuration determines the default namespace for
        | merchant model and it's identifier which will be used in various
        | relationships when retrieving models. You are encouraged to change these
        | values to better reflect your application.
        |
        */
        'user' => [
          'namespace' => env('{$default}_USER_NAMESPACE', '\App\User'),
          'identifier' => env('{$default}_USER_IDENTIFIER', 'id')
        ],

        /*
        |--------------------------------------------------------------------------
        | {$default} Order Configuration
        |--------------------------------------------------------------------------
        |
        | The {$default} order configuration determines the default namespace for
        | order model and it's identifier which CAN be used when charging a customer.
        | You can relate that model to a certain transaction. You are encouraged to
        | change these values to better reflect your application.
        |
        */
        'order' => [
          'namespace' => env('{$default}_ORDER_NAMESPACE', '\App\Order'),
          'identifier' => env('{$default}_ORDER_IDENTIFIER', 'id'),
          'service_identifier' => env('SQUARE_PAYMENT_IDENTIFIER', 'payment_service_id')
        ]
      ],
    ]
];
```

This is just a starter snippet which u can start adapting to your own library. There are couple of important `variables` that u gotta change and rules which you must follow. Change `{$default}` with the name of your package (paypal, payeer, payoneer, ...) and also include the fully qualified name (namespace) of your service instead of `{$namespace}`. You can check [nikolag.php](https://github.com/NikolaGavric94/laravel-square/blob/master/src/config/nikolag.php) example of how config file should look like. [SquareConfig.php](https://github.com/NikolaGavric94/laravel-square/blob/master/src/SquareConfig.php) is the example of how your configuration class should look like.

### 2. Main service

[](#2-main-service)

Your package must have at least 1 main service which is responsible for all communication between rest calls and your package. It also must extend **Nikolag\\Core\\Abstracts\\CorePaymentService** and it must implement **Nikolag\\Core\\Contracts\\PaymentServiceContract** thats explained in the next step. Example of that kind of class can be found [SquareService.php](https://github.com/NikolaGavric94/laravel-square/blob/master/src/SquareService.php).

### 3. Dependency Injections

[](#3-dependency-injections)

Your library must have at least 1 contract which should be named `{$serviceName}ServiceContract.php` where `{$serviceName}` is the name of service you are trying to integrate with nikolag packages and Laravel Also it must extends **Nikolag\\Core\\Contracts\\PaymentServiceContract**. **Any other contract which is not connected with your service file in any way mustn't extend the above contract**. Some examples of such name are `PaypalServiceContract.php`, `PayeerServiceContract.php`, `PayoneerServiceContract.php`. Example of the contract can be found [SquareContract.php](https://github.com/NikolaGavric94/laravel-square/blob/master/src/contracts/SquareContract.php).

### 4. Migrations and Factories

[](#4-migrations-and-factories)

All migrations and factories must be under `src/database` folder and each of them respectively will have it's own subfolder `src/database/factories` and `src/database/migrations`. This core package already has couple of migrations so you don't have to write them yourself, but you can extend on them if necessary.

### 5. Facades

[](#5-facades)

All facades are found under `src/facades` and your package must have at least 1 facade which must be alias for your main service class.

```
//Facades
$this->app->alias(SquareService::class, 'square');
```

### 6. Models

[](#6-models)

All models must be located under `src/models`. There are 2 core models: **Customer** and **Transaction**.

You must extend those 2 core models and create your own from them with all relationships available and also add

```
/**
 * The model's attributes.
 *
 * @var array
 */
protected $attributes = [
  //where `{$serviceName}` is the name of service you are trying to integrate with nikolag packages and Laravel
  //example: 'paypal', 'payoneer', 'payeer'
  'payment_service_type' => {$serviceName}
];
```

The above is only required for 2 base models, any other models u might make don't have to extend anything and you can create them normally. Example can be found [Customer.php](https://github.com/NikolaGavric94/laravel-square/blob/master/src/models/Customer.php).

### 7. Providers

[](#7-providers)

You can register multiple providers and they should be named respectively for their role in the library. You can find them under src/providers folder. Here are some examples: **ExceptionServiceProvider, MyServiceProvider, ExternalLibrariesProvider, etc..**

### 8. Traits

[](#8-traits)

All traits must be under `src/traits`.

### 9. Tests

[](#9-tests)

All your tests must be under `tests` and they are split into 2 types: `integration` and `unit` where each of them has it's own subfolder.

```
src/
tests/
  integration/
  unit/
```

### 10. Utility classes

[](#10-utility-classes)

All your utility classes must be under `src/utils` folder.

All available core methods
--------------------------

[](#all-available-core-methods)

### CoreService

[](#coreservice)

```
/**
 * Returns instance of the specified service
 *
 * @param string $driver
 * @return Nikolag\Core\Contracts\PaymentServiceContract
 */
public function use(string $driver) {}

/**
 * Returns instance of the default service
 *
 * @return Nikolag\Core\Contracts\PaymentServiceContract
 */
public function default() {}

/**
 * Returns all available drivers
 * which u have installed.
 *
 * @return array
 */
public function availableDrivers() {}
```

**CoreService examples**

Get access to the specific underyling driver for any installed payment API

```
$squareAPI = Nikolag\Core\Facades\CoreService::use('square');
$squareAPI->setCustomer($customer)->charge($options);

//or

$myServiceAPI = Nikolag\Core\Facades\CoreService::use('my-service');
$myServiceAPI->setCustomer($customer)->charge($options);
```

You can also charge the customer with your default driver

```
$api = Nikolag\Core\Facades\CoreService::default();

$api->setCustomer($customer)->charge($options);
```

You can also list all available drivers

```
$drivers = Nikolag\Core\Facades\CoreService::availableDrivers();

echo json_decode(json_encode($drivers));
//or Laravel specific helper method
dd($drivers);

//or plain php
var_dump($drivers);
die();
```

More examples
-------------

[](#more-examples)

For a complete example of how to build upon this core package you can take a look at [nikolag-core-starter](https://github.com/NikolaGavric94/nikolag-core-impl)

Contributing
------------

[](#contributing)

Everyone is welcome to contribute to this repository, simply open up an issue and label the request, whether it is an issue, bug or a feature. For any other enquiries send an email to

### Contributors

[](#contributors)

NameChangesDate[@viangela84](https://github.com/viangela84)Updated order\_product table [pull request #3](https://github.com/NikolaGavric94/nikolag-core/pull/3)2017-02-07License
-------

[](#license)

MIT License

Copyright (c) Nikola Gavrić

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.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance70

Regular maintenance activity

Popularity34

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~148 days

Recently: every ~174 days

Total

21

Last Release

175d ago

Major Versions

v1.0.2 → v2.0.02018-04-07

v1.1.0 → v2.3.02019-10-14

v2.9.0 → v3.0.02025-11-24

PHP version history (4 changes)v1.0.0PHP &gt;=7.0.0

v2.5.0PHP &gt;=7.0

v2.6.0PHP &gt;=8.1

2.8.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7a8c728d9b625d033ba937435e2426d2fc5225e4690dd2cac30c405de0ce150?d=identicon)[NikolaGavric94](/maintainers/NikolaGavric94)

---

Top Contributors

[![NikolaGavric94](https://avatars.githubusercontent.com/u/12602403?v=4)](https://github.com/NikolaGavric94 "NikolaGavric94 (70 commits)")[![Mrkbingham](https://avatars.githubusercontent.com/u/4382816?v=4)](https://github.com/Mrkbingham "Mrkbingham (2 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")[![viangela84](https://avatars.githubusercontent.com/u/36246650?v=4)](https://github.com/viangela84 "viangela84 (1 commits)")

---

Tags

laravellaravel-5-packagenikolagpackagepayment-integrationlaravelpaymentsfinancespayments laravel integration

### Embed Badge

![Health badge](/badges/nikolag-core/health.svg)

```
[![Health](https://phpackages.com/badges/nikolag-core/health.svg)](https://phpackages.com/packages/nikolag-core)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
