This extension requires PSR-18 HTTP client and PSR-17 HTTP factories to be registered in your DI container.
The recommended implementation is Guzzle:
composer require guzzlehttp/guzzleYou need to register the PSR interfaces in your neon config:
services:
- GuzzleHttp\Client
- GuzzleHttp\Psr7\HttpFactoryRegister the extension:
extensions:
contributte.thepay: Contributte\ThePay\DI\ThePayExtensionList of all options:
contributte.thepay:
demo: true/false
merchantId: 'your-merchant-id'
projectId: (int)
apiPassword: ''
apiUrl: 'https://api.thepay.cz/'
gateUrl: 'https://gate.thepay.cz/'
language: 'cs'Minimal production configuration:
contributte.thepay:
merchantId: 'your-merchant-id'
projectId: (int)
apiPassword: ''Demo configuration:
contributte.thepay:
demo: true
merchantId: 'your-merchant-id'
projectId: (int)
apiPassword: ''When demo: true is set, apiUrl and gateUrl are automatically switched to demo endpoints.
ThePay\ApiClient\TheConfigThePay\ApiClient\Service\SignatureServiceThePay\ApiClient\Service\ApiService(implementsApiServiceInterface)ThePay\ApiClient\Service\GateService(implementsGateServiceInterface)ThePay\ApiClient\TheClient
use ThePay\ApiClient\TheClient;
use ThePay\ApiClient\Model\CreatePaymentParams;
use Nette\Application\UI\Presenter;
class OrderPresenter extends Presenter
{
public function __construct(
private TheClient $thePayClient,
)
{
parent::__construct();
}
public function actionPay(): void
{
$params = new CreatePaymentParams(10000, 'CZK', 'order-123');
$payment = $this->thePayClient->createPayment($params);
$this->redirectUrl($payment->getPayUrl());
}
}use ThePay\ApiClient\TheClient;
use ThePay\ApiClient\Model\CreatePaymentParams;
use Nette\Application\UI\Presenter;
class OrderPresenter extends Presenter
{
public function __construct(
private TheClient $thePayClient,
)
{
parent::__construct();
}
public function renderPaymentMethods(): void
{
$params = new CreatePaymentParams(10000, 'CZK', 'order-123');
$this->template->paymentButtons = $this->thePayClient->getPaymentButtons($params);
}
}use ThePay\ApiClient\TheClient;
use Nette\Application\UI\Presenter;
class OrderPresenter extends Presenter
{
public function __construct(
private TheClient $thePayClient,
)
{
parent::__construct();
}
public function actionConfirmation(string $paymentUid): void
{
$payment = $this->thePayClient->getPayment($paymentUid);
if ($payment->wasPaid()) {
// payment was successful
}
}
}