Download the PHP package markette/gopay without Composer
On this page you can find all versions of the php package markette/gopay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package gopay
Website 🚀 contributte.org | Contact 👨🏻💻 f3l1x.io | Twitter 🐦 @contributte
Disclaimer
| :warning: | This project is no longer being maintained. Please use contributte/gopay-inline. |
|---|
| Composer | markette/gopay |
|---|---|
| Version | |
| PHP | |
| License |
About
This version used communication through SOAP. We recommend using contributte/gopay-inline which uses JSON REST API.
Installation
To install the latest version of markette/gopay use Composer.
Configuration
Register extension in DI:
Usage
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:
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:
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:
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:
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
You can register your custom payment channels for a single job:
You can also disable or enable any predefined (or even your custom) payment channel:
We can also make these settings in the configuration file:
If we want to allow to change channel on the GoPay page:
Make a payment
Payment can be made in the following steps. First you need to create new payment instance:
Second, set the addresses to which the Gopay payment gateway redirects the success of the payment or while error in payment proccess:
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:
The payment itself can be made in two ways:
Redirect after a payment
The pay() action returns an RedirectResponse, which redirects you to the Gopay gateway:
Inline payment
The payInline() action returns a field with the url and signature keys:
The payment gateway can be created using the form, which can be found in documentation.
Payment exception
Two things can go wrong when calling pay() or payInline():
- Bad parameters are provided somewhere
- 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:
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:
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
Making a recurring payment is very easy:
We will need $paymentSessionId to cancel the recurring payment:
Pre-authorized payments
Making a pre-authorized payment is very simple:
We will need $paymentSessionId to cancel the pre-authorized payment:
Versions
| State | Version | Branch | Nette | PHP |
|---|---|---|---|---|
| dev | ^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
This package was maintained by these authors.
Consider to support contributte development team. Also thank you for using this package.
All versions of gopay with dependencies
markette/gopay-api Version ^2.5.4
nette/forms Version ^3.1.0
nette/application Version ^3.1.0
nette/di Version ^3.0.8