PHPackages                             mludvik/yii2-gopay - 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. mludvik/yii2-gopay

ActiveYii2-extension[Payment Processing](/categories/payments)

mludvik/yii2-gopay
==================

Yii2 integration for official \[GoPay's PHP SDK for Payments REST API\](https://github.com/gopaycommunity/gopay-php-api).

1.0.0(7y ago)13953MITPHP

Since Sep 9Pushed 7y agoCompare

[ Source](https://github.com/mludvik/yii2-gopay)[ Packagist](https://packagist.org/packages/mludvik/yii2-gopay)[ RSS](/packages/mludvik-yii2-gopay/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (2)Used By (0)

yii2-gopay
==========

[](#yii2-gopay)

Yii2 integration for official [GoPay's PHP SDK for Payments REST API](https://github.com/gopaycommunity/gopay-php-api).

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

[](#installation)

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

```
php composer.phar require mludvik/yii2-gopay:"~1.0"

```

or add

```
"mludvik/yii2-gopay": "~1.0"

```

to the require section of your `composer.json`.

Usage
-----

[](#usage)

Before you start using this extension, it is recommended to read [GoPay REST API documentation](https://doc.gopay.com/).

### GoPayComponent

[](#gopaycomponent)

`GoPayComponent` is thin wrapper over GoPay PHP SDK.

Enable it by adding respective component configuration.

```
'components' => [

  ...

  'goPay' => [
    'class' => 'mludvik\gopay\GoPayComponent',
    'config' => [
      'goid' => '...',
      'clientId' => '...',
      'clientSecret' => '...',
      'isProductionMode' => YII_ENV_PROD,
      'scope' => TokenScope::ALL,
      'language' => Language::ENGLISH,
      'timeout' => 30,
    ],
  ],

  ...
]

```

Then you can call any method you would call on [Payments](https://github.com/gopaycommunity/gopay-php-api/blob/3a9eb4b0480599fec687bdc594973b62bb9f8c33/src/Payments.php) object.

```
use Yii;

Yii::$app->goPay->createPayment([...]);
Yii::$app->goPay->getStatus(...);
...

```

### GoPayAsset

[](#gopayasset)

`GoPayAsset` imports front-end GoPay dependencies to your pages. It is sensitive to `YII_EVN` constant — loads production version when `YII_ENV === 'prod'`, test version otherwise. There are multiple ways how to use it.

1. To load it on all pages, register it in `AppAsset`.

```
class AppAsset extends AssetBundle {

  ...

  public $depends = [
    ...
    'mludvik\gopay\GoPayAsset',
  ];
}

```

2. To load it on specific page, register it in respective view.

```
use mludvik\gopay\GoPayAsset;

GoPayAsset::register($this);

```

3. When using `GoPayForm` described below, you do not need to register `GoPayAsset` at all. It will be registered automatically on pages where `GoPayForm` is rendered.

### GoPayForm

[](#gopayform)

`GoPayForm` is widget created to help you build checkout page. Use it if you like or develop your own widget with the help of `GoPayComponent` and `GoPayAsset`.

`GoPayForm` is basically `ActiveForm` with 2 differences.

- It uses asynchronous POST request to submit data to controller and then redirects user to payment gateway.
- It has static method `response`, which can be used in controller to build expected response to form submission.

Example
-------

[](#example)

First of all, you will need form to collect user payment preferences (eg. preferred payment method). It is also a good place to put some business logic in.

```
namespace app\models;

use Yii;
use yii\base\Model;

class CheckoutForm extends Model {

  public $paymentMethod;

  ...

  public function createPayment() {
    // Build request based on form's data.
    $request = [...];

    // Establish payment on GoPay side.
    return Yii::$app->goPay->createPayment($request);
  }
}

```

Then create checkout action.

```
namespace app\controllers;

use Yii;
use yii\web\Controller;
use mludvik\gopay\GoPayForm;
use app\models\CheckoutForm;

class PaymentController extends Controller {

  ...

  public function actionCheckout() {
    $model = CheckoutForm;

    if(Yii::$app->request->isAjax) {
      if($model->load(Yii::$app->request->post()) && $model->validate()) {
        $response = $model->createPayment();
        return GoPayForm::response($response);
      } else {
        return GoPayForm::response(null);
      }
    }

    return $this->render('checkout', ['model' => $model]);
  }
}

```

Finally, create the view.

```

  ...

```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Unknown

Total

1

Last Release

2803d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3527c02cdd8391da40cc38da7db7f0150e7988ecf678e739d5a45de246c77ffe?d=identicon)[mludvik](/maintainers/mludvik)

---

Tags

componentextensionpayment-gatewaywidgetyiiyii2extensionwidgetcomponentpayment gateway

### Embed Badge

![Health badge](/badges/mludvik-yii2-gopay/health.svg)

```
[![Health](https://phpackages.com/badges/mludvik-yii2-gopay/health.svg)](https://phpackages.com/packages/mludvik-yii2-gopay)
```

PHPackages © 2026

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