Website 🚀 contributte.org | Contact 👨🏻💻 f3l1x.io | Twitter 🐦 @contributte
Nette integration for ThePay API client with DI configuration and ready-to-use payment services.
| State | Version | Branch | PHP |
|---|---|---|---|
| dev | ^5.0 | master | >= 8.2 |
| stable | ^4.1 | v4.x | >= 7.1 |
- Installation
- Requirements
- Configuration
- Services Available in DI Container
- Usage
- Official Documentation
- Development
To install the latest version of contributte/thepay use Composer.
composer require contributte/thepayThis 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/falsemerchantId:'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:truemerchantId:'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
useNette\Application\UI\Presenter;
useThePay\ApiClient\Model\CreatePaymentParams;
useThePay\ApiClient\TheClient;
class OrderPresenter extends Presenter
{
publicfunction__construct(
privateTheClient$thePayClient,
) {
parent::__construct();
}
publicfunctionactionPay(): void
{
$params = newCreatePaymentParams(10000, 'CZK', 'order-123');
$payment = $this->thePayClient->createPayment($params);
$this->redirectUrl($payment->getPayUrl());
}
}useNette\Application\UI\Presenter;
useThePay\ApiClient\Model\CreatePaymentParams;
useThePay\ApiClient\TheClient;
class OrderPresenter extends Presenter
{
publicfunction__construct(
privateTheClient$thePayClient,
) {
parent::__construct();
}
publicfunctionrenderPaymentMethods(): void
{
$params = newCreatePaymentParams(10000, 'CZK', 'order-123');
$this->template->paymentButtons = $this->thePayClient->getPaymentButtons($params);
}
}useNette\Application\UI\Presenter;
useThePay\ApiClient\TheClient;
class OrderPresenter extends Presenter
{
publicfunction__construct(
privateTheClient$thePayClient,
) {
parent::__construct();
}
publicfunctionactionConfirmation(string$paymentUid): void
{
$payment = $this->thePayClient->getPayment($paymentUid);
if ($payment->wasPaid()) {
// Payment was successful.
}
}
}See how to contribute to this package.
This package is currently maintained by these authors.
Consider to supportcontributte development team. Also thank you for using this package.