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

AbandonedArchivedLibrary[Payment Processing](/categories/payments)

markette/gopay
==============

Integrace platebního systému Gopay pro Nette Framework.

v3.3.0(5y ago)69104.9k231BSD-3-ClausePHPPHP &gt;=7.1

Since Jun 4Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/contributte/gopay)[ Packagist](https://packagist.org/packages/markette/gopay)[ Docs](https://github.com/contributte/gopay)[ Fund](https://contributte.org/partners.html)[ GitHub Sponsors](https://github.com/f3l1x)[ RSS](/packages/markette-gopay/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (10)Dependencies (11)Versions (22)Used By (1)

[![](https://camo.githubusercontent.com/65c20084bca5e64dca850239fed208c7a875e21d8fa2dc05698597e898e490b2/68747470733a2f2f686561746261646765722e76657263656c2e6170702f6769746875622f726561646d652f636f6e74726962757474652f676f7061792f3f646570726563617465643d31)](https://camo.githubusercontent.com/65c20084bca5e64dca850239fed208c7a875e21d8fa2dc05698597e898e490b2/68747470733a2f2f686561746261646765722e76657263656c2e6170702f6769746875622f726561646d652f636f6e74726962757474652f676f7061792f3f646570726563617465643d31)

 [![](https://camo.githubusercontent.com/a8b1cd856d7d396fdebbe46947cc3507490acc267a02361e5e53bb7b820c95c3/68747470733a2f2f62616467656e2e6e65742f62616467652f737570706f72742f6769747465722f6379616e)](https://bit.ly/ctteg) [![](https://camo.githubusercontent.com/86d6416fc04f8bcc3daa7bf881526b9953b9726b1164d05c157c8713e3a73418/68747470733a2f2f62616467656e2e6e65742f62616467652f737570706f72742f666f72756d2f79656c6c6f77)](https://bit.ly/cttfo) [![](https://camo.githubusercontent.com/5d170ab94e6d594609561e16fe0f9e4293968fbd4dfcfafc5e11efc1415ef09c/68747470733a2f2f62616467656e2e6e65742f62616467652f73706f6e736f722f646f6e6174696f6e732f463936383534)](https://contributte.org/partners.html)

 Website 🚀 [contributte.org](https://contributte.org) | Contact 👨🏻‍💻 [f3l1x.io](https://f3l1x.io) | Twitter 🐦 [@contributte](https://twitter.com/contributte)

Disclaimer
----------

[](#disclaimer)

⚠️This project is no longer being maintained. Please use [contributte/gopay-inline](https://github.com/contributte/gopay-inline).Composer[`markette/gopay`](https://packagist.org/packages/markette/gopay)Version[![](https://camo.githubusercontent.com/2cdb58a8d0bb5ea6b3361ee214cfae822c93aa346541b6082a5fe155590dd6b0/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f6d61726b657474652f676f706179)](https://camo.githubusercontent.com/2cdb58a8d0bb5ea6b3361ee214cfae822c93aa346541b6082a5fe155590dd6b0/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f6d61726b657474652f676f706179)PHP[![](https://camo.githubusercontent.com/6c26507773770b269ca4fe2a70a7d3c1038fb41773daf1412fed47829103cfe6/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f6d61726b657474652f676f706179)](https://camo.githubusercontent.com/6c26507773770b269ca4fe2a70a7d3c1038fb41773daf1412fed47829103cfe6/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f6d61726b657474652f676f706179)License[![](https://camo.githubusercontent.com/d8d05198acbde877cbcbb7c25ac4e86421c9ee7c441bd6b3c11a0d7c754c5053/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6963656e73652f636f6e74726962757474652f676f706179)](https://camo.githubusercontent.com/d8d05198acbde877cbcbb7c25ac4e86421c9ee7c441bd6b3c11a0d7c754c5053/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6963656e73652f636f6e74726962757474652f676f706179)About
-----

[](#about)

This version used communication through SOAP. We recommend using [contributte/gopay-inline](https://github.com/contributte/gopay-inline) which uses JSON REST API.

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

[](#installation)

To install the latest version of `markette/gopay` use [Composer](https://getcomposer.org).

```
composer require markette/gopay
```

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

[](#configuration)

Register extension in DI:

```
extensions:
	gopay: Markette\Gopay\DI\Extension

gopay:
	gopayId: ***
	gopaySecretKey: ***
	testMode: false
```

Usage
-----

[](#usage)

### Services

[](#services)

You can choose from three services:

- **PaymentService** (standard payments)
- **RecurrentPaymentService** (recurring payments)
- **PreAuthorizedPaymentService** (pre-authorized payments)

You can use `autowiring` and inject them into `Presenter`:

```
use Markette\Gopay\Service\PaymentService;
use Markette\Gopay\Service\RecurrentPaymentService;
use Markette\Gopay\Service\PreAuthorizedPaymentService;

/** @var PaymentService @inject */
public $paymentService;

/** @var RecurrentPaymentService @inject */
public $recurrentPaymentService;

/** @var PreAuthorizedPaymentService @inject */
public $preAuthorizedPaymentService;
```

### Before payment

[](#before-payment)

Before payment, you need to create a form with the corresponding payment buttons. Each payment channel is represented by one button. You can add buttons to the form simply via Binder with the `bindPaymentButtons()` method:

```
$binder->bindPaymentButtons($service, $form, [$this, 'submitForm']);

// or more callbacks

$gopay->bindPaymentButtons($form, [
	[$this, 'preProcessForm'],
	[$this, 'processForm'],
	[$this, 'postProcessForm'],
]);
```

The passed `callback` will be called after the successful submission of the form by one from the payment buttons (ie as after calling `->onClick[]` on the given button). The selected channel can be obtained from the button:

```
use Markette\Gopay\Form;

public function submittedForm(Form\PaymentButton $button)
{
	$channel = $button->getChannel();
}
```

If you want to render the form manually (eg using form maker), it is best to pass a list of used channels to the template and iterate over it:

```
$this->template->channels = $service->getChannels();
```

```
{foreach $channels as $channel}
    {input $channel->control}
{/foreach}
```

It's a good idea to wrap the `getChannels()` call by catching the `GopayFatalException` exception because for the first time it queries the Gopay server to get the default list.

#### Custom payment channels

[](#custom-payment-channels)

You can register your custom payment channels for a single job:

```
$service->addChannel(Gopay::METHOD_TRANSFER, 'My transfer channel', '/my-channel.png', NULL, NULL, []);
```

You can also disable or enable any predefined (or even your custom) payment channel:

```
$gopay->denyChannel($gopay::METHOD_TRANSFER);
$gopay->allowChannel($gopay::METHOD_GOPAY);
```

We can also make these settings in the configuration file:

```
gopay:
	payments:
		channels:
			gopay: 'Gopay - Elektronická peněženka'
			card_gpkb: 'Platba kartou - Komerční banka, a.s. - Global Payments'
```

If we want to allow to change **channel** on the GoPay page:

```
gopay:
	payments:
		changeChannel: yes
```

### Make a payment

[](#make-a-payment)

Payment can be made in the following steps. First you need to create new payment instance:

```
$payment = $service->createPayment([
	'sum'				=> $sum,      // placená částka
	'variable'			=> $variable, // variabilní symbol
	'specific'			=> $specific, // specifický symbol
	'productName'		=> $product,  // název produktu (popis účelu platby)
	'customer' => [
		'firstName'		=> $name,
		'lastName'		=> NULL,    // všechna parametry jsou volitelné
		'street'		=> NULL,    // pokud některý neuvedete,
		'city'			=> NULL,    // použije se prázdný řetězec
		'postalCode'	=> $postal,
		'countryCode'	=> 'CZE',
		'email'			=> $email,
		'phoneNumber'	=> NULL,
	],
]);
```

Second, set the addresses to which the Gopay payment gateway redirects the success of the payment or while error in payment proccess:

```
$service->setSuccessUrl($this->link('//success', ['orderId' => $orderId]));
$service->setFailureUrl($this->link('//failure', ['orderId' => $orderId]));
```

It is useful to make a note of the payment ID (for example if the payment is to be bound to an order etc.). This can be accomplished by passing the callback as the third parameter to the `pay()` method:

```
$storeIdCallback = function ($paymentId) use ($order) {
	$order->setPaymentId($paymentId);
};
```

The payment itself can be made in two ways:

### Redirect after a payment

[](#redirect-after-a-payment)

```
$response = $gopay->pay($payment, $gopay::METHOD_TRANSFER, $storeIdCallback);
```

The `pay()` action returns an RedirectResponse, which redirects you to the Gopay gateway:

```
$this->sendResponse($response);
```

### Inline payment

[](#inline-payment)

```
$response = $gopay->payInline($payment, $gopay::METHOD_TRANSFER, $storeIdCallback);
```

The `payInline()` action returns a field with the **url** and **signature** keys:

```
[
	"url" => "https://gate.gopay.cz/gw/v3/3100000099",
	"signature" => "25ee53a1ec­cc253a8310f5267d2de6b483f58a­f9676d883e26600ce3316ai"
];
```

The payment gateway can be created using the form, which can be found in [documentation](https://help.gopay.com/cs/tema/integrace-platebni-brany/integrace-nova-platebni-brany/integrace-nove-platebni-brany-pro-stavajici-zakazniky).

```

  Zaplatit

```

#### Payment exception

[](#payment-exception)

Two things can go wrong when calling `pay()` or `payInline()`:

1. Bad parameters are provided somewhere
2. The official Gopay payment gateway is broken

The first mistake should never occur. It means a mistake in your code.

The second can happen at any time, so it generates a slightly different exception that you need to catch and inform the customer according to it that the error is not on to Your side:

```
try {
	$gopay->pay($payment, $gopay::TRANSFER, $storeIdCallback);
	// nebo
	$gopay->payInline($payment, $gopay::TRANSFER, $storeIdCallback);
} catch (GopayException $e) {
	echo 'Platební služba Gopay bohužel momentálně nefunguje. Zkuste to
	prosím za chvíli.';
}
```

### After payment

[](#after-payment)

Your customer will perform the necessary actions on the Gopay payment gateway, and once the process is completed, he is redirected back to your application, either to `successUrl` or `failureUrl` address. Both will receive the following set of parameters from Gopay:

- paymentSessionId
- targetGoId
- orderNumber // varying number
- encryptedSignature

*Plus the parameters you specify in successUrl or failureUrl.*

The first parameter is identical to the one that we have saved in the previous chapter to our internal model representation of the order. So we can use it for reload.

We will then use all this data + data from the loaded order for payment object reassembly:

```
$order = $model->getOrderByPaymentId($paymentSessionId);

$payment = $service->restorePayment([
	'sum'			=> $order->price,
	'variable'		=> $order->varSymbol,
	'specific'		=> $order->specSymbol,
	'productName'	=> $order->product,
], [
	'paymentSessionId'		=> $paymentSessionId,
	'targetGoId'			=> $targetGoId,
	'orderNumber'			=> $orderNumber,
	'encryptedSignature'	=> $encryptedSignature,
]);
```

Two control methods can be called on a payment object: `isFraud()` and `isPaid()`. The first informs us whether the payment is genuine or not for fraud (internally, the four parameters passed from the payment system are checked by payment gate).

The second `isPaid()` then returns TRUE if the payment is actually paid. If yes, the process is over, we can mark that the order is paid and send for example, an email to the customer.

In case of unsuccessful payment, all four parameters are passed again, so it is possible to retrieve information about the related order. However there is no need to check anything, the information about the failure is quite clear from the character of the request.

### Recurring payments

[](#recurring-payments)

Making a recurring payment is very easy:

```
$service->payRecurrent(PreAuthorizedPayment $payment, $gopay::METHOD_TRANSFER, function($paymentSessionId) {});
```

We will need `$paymentSessionId` to cancel the recurring payment:

```
$service->cancelRecurrent($paymentSessionId);
```

### Pre-authorized payments

[](#pre-authorized-payments)

Making a pre-authorized payment is very simple:

```
$service->payPreAuthorized(PreAuthorizedPayment $payment, $gopay::METHOD_TRANSFER, function($paymentSessionId) {});
```

We will need `$paymentSessionId` to cancel the pre-authorized payment:

```
$service->cancelPreAuthorized($paymentSessionId);
```

Versions
--------

[](#versions)

StateVersionBranchNettePHPdev`^3.4.0``master``3.0+``>=7.1`stable`^3.3.0``master``3.0+``>=7.1`stable`^3.2.0``master``2.4``>=5.6`stable`^3.0.0``master``2.3``>=5.5`stable`^2.3.0``master``2.3``>=5.4`stable`^2.2.0``master``2.2``>=5.3.2`Development
-----------

[](#development)

This package was maintained by these authors.

[ ![](https://avatars2.githubusercontent.com/u/538058?v=3&s=80)](https://github.com/f3l1x)---

Consider to [support](https://contributte.org/partners.html) **contributte** development team. Also thank you for using this package.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance46

Moderate activity, may be stable

Popularity43

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~171 days

Recently: every ~291 days

Total

20

Last Release

1884d ago

Major Versions

v1.9.0 → v2.0.02014-10-17

v2.3.0 → v3.0.02015-12-17

v1.x-dev → v2.1.x-dev2018-02-22

v2.3.x-dev → v3.x-dev2018-02-22

PHP version history (5 changes)v1.0.0PHP &gt;=5.3.2

v2.3.0PHP &gt;=5.4

v3.0.0PHP &gt;=5.5

v3.1.0PHP &gt;=5.6

v3.3.0PHP &gt;=7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/538058?v=4)[Milan Šulc](/maintainers/f3l1x)[@f3l1x](https://github.com/f3l1x)

![](https://www.gravatar.com/avatar/920689f25a0fc31b2807556eddd47203f33c4318893bce98818cf2f3e627ee8e?d=identicon)[vojtechdobes](/maintainers/vojtechdobes)

---

Top Contributors

[![f3l1x](https://avatars.githubusercontent.com/u/538058?v=4)](https://github.com/f3l1x "f3l1x (107 commits)")[![vojtech-dobes](https://avatars.githubusercontent.com/u/415925?v=4)](https://github.com/vojtech-dobes "vojtech-dobes (90 commits)")[![hrach](https://avatars.githubusercontent.com/u/284263?v=4)](https://github.com/hrach "hrach (29 commits)")[![petrparolek](https://avatars.githubusercontent.com/u/6066243?v=4)](https://github.com/petrparolek "petrparolek (8 commits)")[![artemevsin](https://avatars.githubusercontent.com/u/12592377?v=4)](https://github.com/artemevsin "artemevsin (3 commits)")[![haltuf](https://avatars.githubusercontent.com/u/325759?v=4)](https://github.com/haltuf "haltuf (3 commits)")[![kraag22](https://avatars.githubusercontent.com/u/1721419?v=4)](https://github.com/kraag22 "kraag22 (3 commits)")[![pavelsmolka](https://avatars.githubusercontent.com/u/432997?v=4)](https://github.com/pavelsmolka "pavelsmolka (3 commits)")[![miso-belica](https://avatars.githubusercontent.com/u/1072330?v=4)](https://github.com/miso-belica "miso-belica (2 commits)")[![hranicka](https://avatars.githubusercontent.com/u/3034538?v=4)](https://github.com/hranicka "hranicka (2 commits)")[![martinsifra](https://avatars.githubusercontent.com/u/1210906?v=4)](https://github.com/martinsifra "martinsifra (1 commits)")[![mishak87](https://avatars.githubusercontent.com/u/276500?v=4)](https://github.com/mishak87 "mishak87 (1 commits)")[![ondrakub](https://avatars.githubusercontent.com/u/137948?v=4)](https://github.com/ondrakub "ondrakub (1 commits)")[![ondrs](https://avatars.githubusercontent.com/u/828362?v=4)](https://github.com/ondrs "ondrs (1 commits)")[![vitkutny](https://avatars.githubusercontent.com/u/4031169?v=4)](https://github.com/vitkutny "vitkutny (1 commits)")[![Attanon](https://avatars.githubusercontent.com/u/3205711?v=4)](https://github.com/Attanon "Attanon (1 commits)")[![camohub](https://avatars.githubusercontent.com/u/8393426?v=4)](https://github.com/camohub "camohub (1 commits)")[![radimvaculik](https://avatars.githubusercontent.com/u/461164?v=4)](https://github.com/radimvaculik "radimvaculik (1 commits)")[![romanmatena](https://avatars.githubusercontent.com/u/164995?v=4)](https://github.com/romanmatena "romanmatena (1 commits)")[![Honzy](https://avatars.githubusercontent.com/u/5048127?v=4)](https://github.com/Honzy "Honzy (1 commits)")

---

Tags

ecommercegopaymarkettenettepaymentsphpsoapnettepaymenteshopgopay

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[ublaboo/datagrid

DataGrid for Nette Framework: filtering, sorting, pagination, tree view, table view, translator, etc

2972.0M24](/packages/ublaboo-datagrid)[metisfw/paypal

PayPal SDK integration for Nette Framework

109.5k](/packages/metisfw-paypal)

PHPackages © 2026

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