PHPackages                             orkhanahmadov/laravel-goldenpay - 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. orkhanahmadov/laravel-goldenpay

ActiveLibrary[Payment Processing](/categories/payments)

orkhanahmadov/laravel-goldenpay
===============================

Goldenpay package for Laravel

3.1.0(4y ago)139MITPHPPHP ^7.3|^8.0CI failing

Since Nov 23Pushed 4y ago2 watchersCompare

[ Source](https://github.com/orkhanahmadov/laravel-goldenpay)[ Packagist](https://packagist.org/packages/orkhanahmadov/laravel-goldenpay)[ Docs](https://github.com/orkhanahmadov/laravel-goldenpay)[ GitHub Sponsors](https://github.com/orkhanahmadov)[ RSS](/packages/orkhanahmadov-laravel-goldenpay/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (10)Versions (5)Used By (0)

💳 [GoldenPay](http://www.goldenpay.az) package for Laravel
==========================================================

[](#credit_card-goldenpay-package-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/46f00e07a82d3a48b119c50af4b55f110273f3f240d9d968b3efee6417b440d9/68747470733a2f2f706f7365722e707567782e6f72672f6f726b68616e61686d61646f762f6c61726176656c2d676f6c64656e7061792f762f737461626c65)](https://packagist.org/packages/orkhanahmadov/laravel-goldenpay)[![Latest Unstable Version](https://camo.githubusercontent.com/b545eee02577bd470a9632a5000592890bd686ec122360e087d231e455e1d84e/68747470733a2f2f706f7365722e707567782e6f72672f6f726b68616e61686d61646f762f6c61726176656c2d676f6c64656e7061792f762f756e737461626c65)](https://packagist.org/packages/orkhanahmadov/laravel-goldenpay)[![Total Downloads](https://camo.githubusercontent.com/aeec309ec0b56935470e0fc92f70530e9ee7d38e50f52ffa757e2a8381beffe5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f726b68616e61686d61646f762f6c61726176656c2d676f6c64656e706179)](https://packagist.org/packages/orkhanahmadov/laravel-goldenpay)[![GitHub license](https://camo.githubusercontent.com/e70b0ee9cc40556eff7d20d373e0aab808f0c2198e24ae1d789c632433f96cc3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f726b68616e61686d61646f762f6c61726176656c2d676f6c64656e7061792e737667)](https://github.com/orkhanahmadov/laravel-goldenpay/blob/master/LICENSE.md)

[![Build Status](https://camo.githubusercontent.com/20ca6b565f12b2a76937901278b6603f31dc02a9c5c2a3ab5cbaff9d0bf72b71/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6f726b68616e61686d61646f762f6c61726176656c2d676f6c64656e7061792e737667)](https://travis-ci.org/orkhanahmadov/laravel-goldenpay)[![Test Coverage](https://camo.githubusercontent.com/2374ef9abdcd08dfab767630db5f292cdb1691acef629e8701cfc13a88936088/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31303362646330383632396663383434623537302f746573745f636f766572616765)](https://codeclimate.com/github/orkhanahmadov/laravel-goldenpay/test_coverage)[![Maintainability](https://camo.githubusercontent.com/63d13c03fa3a4f65ae7016611f28b465473dcb84a25e8e6e2d0bcef3f09dc7af/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31303362646330383632396663383434623537302f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/orkhanahmadov/laravel-goldenpay/maintainability)[![Quality Score](https://camo.githubusercontent.com/6f7e19feb0a274849d6a9480cffa3abd6ccad6521fce5b8baeaabed4329f98c5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6f726b68616e61686d61646f762f6c61726176656c2d676f6c64656e7061792e737667)](https://scrutinizer-ci.com/g/orkhanahmadov/laravel-goldenpay)[![StyleCI](https://camo.githubusercontent.com/49620d1dd4fdc9b4c034893efaff107b1c09bf3610f064207334ff276a474637/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3232303835353939372f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/220855997)

Full-feature Laravel package for Goldenpay integration.

Table of Contents
=================

[](#table-of-contents)

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Usage](#usage)
4. [Controller](#controller)
5. [Models](#models)
6. [Commands](#commands)
7. [Events](#events)
8. [Configuration](#configuration)

Requirements
------------

[](#requirements)

PackagePHPLaravel1.0^7.25.8.\* or ^6.02.0^7.2^6.0 or ^7.03.0^7.3 or ^8.0^8.0Installation
------------

[](#installation)

You can install the package via composer:

```
composer require orkhanahmadov/laravel-goldenpay
```

Run this command to publish required migration file:

```
php artisan vendor:publish --provider="Orkhanahmadov\LaravelGoldenpay\LaravelGoldenpayServiceProvider" --tag=migrations
```

Usage
-----

[](#usage)

First, set your Goldenpay merchant name and auth key in `.env` file. You can get these from [Goldenpay Dashboard](https://rest.goldenpay.az/merchant/).

```
GOLDENPAY_AUTH_KEY=your-auth-key
GOLDENPAY_MERCHANT_NAME=your-merchant-name
```

To use Goldenpay service you need instance of `Orkhanahmadov\LaravelGoldenpay\Goldenpay`. You can instantiate this class using Laravel's service container, for example by injecting to your controller

```
use Orkhanahmadov\LaravelGoldenpay\Goldenpay;

class MyController
{
    public function index(Goldenpay $goldenpay)
    {
        //
    }
}
```

Or you can use Laravel's service resolver to create instance of the class:

```
use Orkhanahmadov\LaravelGoldenpay\Goldenpay;

class MyClass
{
    public function doSomething()
    {
        $goldenpay = app(Goldenpay::class);
        //
    }
}
```

### Available methods:

[](#available-methods)

### `payment()`

[](#payment)

Prepares payment based on passed credentials and accepts 4 arguments:

- `Amount` - Payment amount, only integer values accepted For example, for you want to create payment for 10.25, then pass it as 1025.
- `Card type` - Requires instance of `Orkhanahmadov\Goldenpay\Enums\CardType`. `CardType::VISA()` for VISA, `CardType::MASTERCARD()` for MasterCard
- `Description` - Payment description
- `Language` *(optional)* - Sets payment page interface language. Requires instance of `Orkhanahmadov\Goldenpay\Enums\Language`. `Language::EN()` for english, `Language::RU()` for russian, `Language::AZ()` for azerbaijani. If nothing passed service will use Laravel's active locale.

```
$goldenpay = app(Goldenpay::class);
$goldenpay->payment(1000, CardType::MASTERCARD(), 'my payment');
```

Method returns created instance of `Orkhanahmadov\LaravelGoldenpay\Models\Payment` model.

You can use `$payment_url` property to get unique payment URL and redirect user to this URL to start payment.

```
$payment = $goldenpay->payment(1000, CardType::MASTERCARD(), 'my payment');

$payment->payment_url; // redirect user to this URL to start payment
```

### `result()`

[](#result)

Checks payment result based on previous payment key. Accepts single argument:

- `Payment` - This is Goldenpay's payment key as a string, or instance of previously created `Orkhanahmadov\LaravelGoldenpay\Models\Payment` model.

```
$goldenpay = app(Goldenpay::class);
$paymentModel = $goldenpay->payment(1000, CardType::MASTERCARD(), 'my payment');

$result = $goldenpay->result($paymentModel);
// or
$result = $goldenpay->result('1234-ABCD-5678');
```

Method returns updated instance of `Orkhanahmadov\LaravelGoldenpay\Models\Payment` model with Goldenpay's response.

Controller
----------

[](#controller)

Goldenpay requires to have endpoints for successful and unsuccessful payment. For each of this endpoints Goldenpay sends GET request with `payment_key` query string attached. To get payment result you need to create a route to accept these requests and fetch result of the payment using received `payment_key`.

Package ships with a controller that helps to simplify this process. To get started, first create a GET route for successful or unsuccessful payments and add full URL in [Goldenpay Dashboard](https://rest.goldenpay.az/merchant/) to corresponding field.

```
Route::get('payments/successful', 'App\Http\Controllers\Payment\SuccessfulPaymentController@index');
```

Create a controller class for your route and extend `Orkhanahmadov\LaravelGoldenpay\Http\Controllers\GoldenpayController`.

```
use Orkhanahmadov\LaravelGoldenpay\Http\Controllers\GoldenpayController;

class SuccessfulPaymentController extends GoldenpayController
{
    public function index()
    {
        // return a view or JSON, totally up to you
    }
}
```

By extending `Orkhanahmadov\LaravelGoldenpay\Http\Controllers\GoldenpayController`, your controller will automatically check for payment result based on `payment_key` query string.

In your controller you can access to `$payment` property which will have payment results from Goldenpay.

```
public function index()
{
    $this->payment->status; // will return payment status
    $this->payment->successful; // will return true if payment was successful or false if unsuccessful
}
```

You can use same endpoint for both successful and unsuccessful payments and decide what you want to show user based on `$this->payment->successful` state or you create separate endpoints and controllers and extend `Orkhanahmadov\LaravelGoldenpay\Http\Controllers\GoldenpayController` in both controllers.

Models
------

[](#models)

Package ships with `Orkhanahmadov\LaravelGoldenpay\Models\Payment` Eloquent model. Model stores following information for each payment:

- `payment_key` - string, unique payment key provided by Goldenpay
- `amount` - integer, payment amount
- `card_type` - enum, "m" for MasterCard, "v" for VISA
- `language` - enum, "en" for English, "ru" for Russian, "lv" for Azerbaijani
- `description` - string, payment description
- `status` - integer, payment status code
- `message` - string, payment status message
- `reference_number` - string, payment reference number
- `card_number` - string, encrypted, card number used for payment
- `payment_date` - datetime, payment date
- `checks` - integer, payment check count

Besides usual Eloquent functionality this model also has specific accessors, scopes and relationship abilities which you can utilize.

### Accessors

[](#accessors)

- `successful` - Returns `true` if payment marked as successful, `false` otherwise
- `payment_url` - Returns payment page url. Returns `null` if payment marked as successful
- `formatted_amount` - Returns "amount" in decimal form
- `card_number_decrypted` - Returns decrypted "card\_number" value. Returns `null` if card number encrypting is turned off

### Scopes

[](#scopes)

- `whereSuccessful()` - Filters "successful" payments only
- `wherePending()` - Filters "pending" payments only. Pending payments are the payments that not successful and either created within 30 minutes or have less than 3 payment checks.

### Relationship

[](#relationship)

You can make any existing Eloquent model "payable" and attach Goldenpay payments to it. Use `Orkhanahmadov\LaravelGoldenpay\Traits\Payable` trait in your existing model to establish direct model relationship. Trait usage requires to have `amount()` `description()` methods to be defined in your model:

- `amount()` - Must return payment amount in integer
- `description()` - Must return description for payment instance

```
use Illuminate\Database\Eloquent\Model;
use Orkhanahmadov\LaravelGoldenpay\Traits\Payable;

class Product extends Model
{
    use Payable;

    protected $fillable = [
        'name',
        'color',
        'size',
        'price',
    ];

    protected $casts = [
        'price' => 'float', // lets image that you store price as float, like "15.70" in "products" table
    ];

    protected function amount(): int
    {
        // this method needs to return integer value of price
        return $this->price * 100;
    }

    protected function description(): string
    {
        // this method needs to return description for payment instance
        // try to use both unique and easy to read identifier
        return $this->id . ' - ' . $this->name . ' - ' . $this->color;
    }
}
```

Now `Product` model has direct relationship with Goldenpay payments. By using `Payable` your model also gets access to payment related relationships and payment methods.

#### `createPayment()`

[](#createpayment)

```
$product = Product::find(1);

$product->createPayment(CardType::VISA()); // uses product amount() and description() to create new payment instance
```

You can also override `amount` and `description()` for specific payment:

```
$product->createPayment(CardType::VISA(), 2599, 'my custom description');
```

Method accepts following arguments:

- `Card type` - Instance of `Orkhanahmadov\Goldenpay\Enums\CardType`
- `Amount` *(optional)* - When used overrides `amount()` method value in model
- `Description` *(optional)* - When used overrides `description()` method value in model
- `Language` *(optional)* - When skipped will use Laravel's locale. Instance of `Orkhanahmadov\Goldenpay\Enums\Language`.

Method returns created instance of `Orkhanahmadov\LaravelGoldenpay\Models\Payment`.

#### `payments()`

[](#payments)

Eloquent relationship method. Return all related payments to model.

```
$product = Product::find(1);
$product->payments; // returns collection of related Payment models
$product->payments()->where('amount', '>=', 10000); // use it as regular Eloquent relationship
```

#### `successfulPayments()`

[](#successfulpayments)

Eloquent relationship method. Return all related successful payments to model.

```
$product = Product::find(1);
$product->successfulPayments; // returns collection of related Payment models
$product->successfulPayments()->where('amount', '>=', 10000); // use it as regular Eloquent relationship
```

Commands
--------

[](#commands)

Package ships with artisan command for checking payment results.

```
php artisan goldenpay:result
```

Executing above command will loop through all "pending" payments and update their results.

Command also accepts payment key as an argument to check single payment result.

```
php artisan goldenpay:result 1234-ABCD-5678
```

Goldenpay requires manual check for payments to determine their final status. For example, user might go to payment page then close browser window without entering anything. These kind payment cases needs to be checked manually to finalize their status. You can use Laravel's [Task Scheduling](https://laravel.com/docs/master/scheduling)for running `goldenpay:result` command on Cron job.

```
protected function schedule(Schedule $schedule)
{
    $schedule->command('goldenpay:result')->everyFiveMinutes();
}
```

Because Goldenpay states that each payment session is active only for 15 minutes, it is recommended to keep frequency to 5 or 10 minutes.

Events
------

[](#events)

Package ships with Laravel events which gets fired on specific conditions.

Available event classes:

- `Orkhanahmadov\LaravelGoldenpay\Events\PaymentCreatedEvent` - gets fired when new payment is created
- `Orkhanahmadov\LaravelGoldenpay\Events\PaymentCheckedEvent` - gets fired when payment is checked for result
- `Orkhanahmadov\LaravelGoldenpay\Events\PaymentSuccessfulEvent` - gets fired when payment finalized as successful

Each event receives instance of `Orkhanahmadov\LaravelGoldenpay\Models\Payment` Eloquent model as public `$payment` property.

You can set up event listeners to trigger when specific payment event gets fired.

```
protected $listen = [
    'Orkhanahmadov\LaravelGoldenpay\Events\PaymentSuccessfulEvent' => [
        'App\Listeners\SendPaymentInvoice',
        'App\Listeners\SendProductLicense',
    ],
];
```

Configuration
-------------

[](#configuration)

Run this command to publish package config file:

```
php artisan vendor:publish --provider="Orkhanahmadov\LaravelGoldenpay\LaravelGoldenpayServiceProvider" --tag=config
```

Config file contains following settings:

- `auth_key` - Defines Goldenpay "auth key", defaults to `.env` variable
- `merchant_name` - Defines Goldenpay "merchant name", defaults to `.env` variable
- `table_name` - Defines name for Goldenpay payments database table. Default: "goldenpay\_payments"
- `encrypt_card_numbers` - Defines if "card\_number" field needs to be automatically encrypted when when creating payments or getting payment results. Default is `true`, change to `false` if you want to disable automatic encryption. Recommended to leave it `true` for extra layer of security. **Warning!** If you already have records in Payments table, changing this value will break encryption/decryption. Old values won't be encrypted/decrypted automatically, you need to do it manually.
- `payment_events` - Payment events related settings
    - `enabled` - Defines if payment events are enabled. Set to `false` to disable all payment events
    - `checked` - "Payment checked" event class. By default uses `Orkhanahmadov\LaravelGoldenpay\Events\PaymentCreatedEvent` class
    - `created` - "Payment created" event class. By default uses `Orkhanahmadov\LaravelGoldenpay\Events\PaymentCheckedEvent` class
    - `successful` - "Payment successful" event class. By default uses `Orkhanahmadov\LaravelGoldenpay\Events\PaymentSuccessfulEvent` class

If you want to use your own event class for specific payment event you can replace class namespace with your class namespace. Each payment event receives instance of `Orkhanahmadov\LaravelGoldenpay\Models\Payment` Eloquent model. Because of this, make sure you add payment model as dependency to your event class constructor signature or you can extend `Orkhanahmadov\LaravelGoldenpay\Events\PaymentEvent` class which already has payment model as dependency.

Setting specific payment event to `null` disables that event without interrupting others.

### Testing

[](#testing)

```
composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

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

Credits
-------

[](#credits)

- [Orkhan Ahmadov](https://github.com/orkhanahmadov)
- [All Contributors](../../contributors)

Support me
----------

[](#support-me)

If you like my work, if my open-source contributions help you or your company, please consider supporting me through [Github Sponsors](https://github.com/sponsors/orkhanahmadov).

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~205 days

Total

4

Last Release

1746d ago

Major Versions

1.0.0 → 2.02020-09-15

2.0 → 3.02020-09-15

PHP version history (3 changes)1.0.0PHP ^7.2

3.0PHP ^7.3

3.1.0PHP ^7.3|^8.0

### Community

Maintainers

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

---

Top Contributors

[![orkhanahmadov](https://avatars.githubusercontent.com/u/7041590?v=4)](https://github.com/orkhanahmadov "orkhanahmadov (115 commits)")

---

Tags

goldenpaygoldenpay-paymentspaymentorkhanahmadovlaravel-goldenpay

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/orkhanahmadov-laravel-goldenpay/health.svg)

```
[![Health](https://phpackages.com/badges/orkhanahmadov-laravel-goldenpay/health.svg)](https://phpackages.com/packages/orkhanahmadov-laravel-goldenpay)
```

###  Alternatives

[laravel/pulse

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

1.7k12.1M99](/packages/laravel-pulse)[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)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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