From 8ff043ba31296a729d08322e492b1e4401d55b05 Mon Sep 17 00:00:00 2001 From: Oh My Felix Date: Mon, 22 Jun 2026 18:54:04 +0000 Subject: [PATCH] Docs: move documentation to README Co-authored-by: Felix --- .docs/README.md | 166 ---------------------------------------- README.md | 198 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 177 insertions(+), 187 deletions(-) delete mode 100755 .docs/README.md diff --git a/.docs/README.md b/.docs/README.md deleted file mode 100755 index f718443..0000000 --- a/.docs/README.md +++ /dev/null @@ -1,166 +0,0 @@ -# ThePay - -## Content - -- [Requirements](#requirements) -- [Configuration](#configuration) -- [Services available in DI container](#services-available-in-di-container) -- [Usage](#usage) - -## Requirements - -This extension requires PSR-18 HTTP client and PSR-17 HTTP factories to be registered in your DI container. - -The recommended implementation is [Guzzle](https://github.com/guzzle/guzzle): - -```bash -composer require guzzlehttp/guzzle -``` - -You need to register the PSR interfaces in your neon config: - -```neon -services: - - GuzzleHttp\Client - - GuzzleHttp\Psr7\HttpFactory -``` - -## Configuration - -Register the extension: - -```neon -extensions: - contributte.thepay: Contributte\ThePay\DI\ThePayExtension -``` - -List of all options: - -```neon -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: - -```neon -contributte.thepay: - merchantId: 'your-merchant-id' - projectId: (int) - apiPassword: '' -``` - -Demo configuration: - -```neon -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. - -## Services available in DI container - -- `ThePay\ApiClient\TheConfig` -- `ThePay\ApiClient\Service\SignatureService` -- `ThePay\ApiClient\Service\ApiService` (implements `ApiServiceInterface`) -- `ThePay\ApiClient\Service\GateService` (implements `GateServiceInterface`) -- `ThePay\ApiClient\TheClient` - -## Usage - -### Create a payment - -```php -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()); - } - -} -``` - -### Render payment buttons - -```php -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); - } - -} -``` - -### Verify a payment - -```php -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 - } - } - -} -``` - -## Official documentation - -- [ThePay API Client](https://github.com/ThePay/api-client) -- [ThePay API Documentation](https://thepay.docs.apiary.io/) diff --git a/README.md b/README.md index 6da0f04..35e20e4 100755 --- a/README.md +++ b/README.md @@ -1,24 +1,43 @@ ![](https://heatbadger.now.sh/github/readme/contributte/thepay/)

- - - - + + + +

- - - - - + + + + +

Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte

-## Usage +Nette integration for [ThePay](https://www.thepay.cz/) API client with DI configuration and ready-to-use payment services. + +## Versions + +| State | Version | Branch | PHP | +|--------|---------|----------|----------| +| dev | `^5.0` | `master` | `>= 8.2` | +| stable | `^4.1` | `v4.x` | `>= 7.1` | + +## Contents + +- [Installation](#installation) +- [Requirements](#requirements) +- [Configuration](#configuration) +- [Services Available in DI Container](#services-available-in-di-container) +- [Usage](#usage) +- [Official Documentation](#official-documentation) +- [Development](#development) + +## Installation To install the latest version of `contributte/thepay` use [Composer](https://getcomposer.org). @@ -26,29 +45,166 @@ To install the latest version of `contributte/thepay` use [Composer](https://get composer require contributte/thepay ``` -## Documentation +## Requirements -For details on how to use this package, check out our [documentation](.docs). +This extension requires PSR-18 HTTP client and PSR-17 HTTP factories to be registered in your DI container. -## Versions +The recommended implementation is [Guzzle](https://github.com/guzzle/guzzle): + +```bash +composer require guzzlehttp/guzzle +``` + +You need to register the PSR interfaces in your neon config: + +```neon +services: + - GuzzleHttp\Client + - GuzzleHttp\Psr7\HttpFactory +``` + +## Configuration + +Register the extension: + +```neon +extensions: + contributte.thepay: Contributte\ThePay\DI\ThePayExtension +``` + +List of all options: + +```neon +contributte.thepay: + demo: true/false + merchantId: 'your-merchant-id' + projectId: (int) + apiPassword: '' + apiUrl: 'https://api.thepay.cz/' + gateUrl: 'https://gate.thepay.cz/' + language: 'cs' +``` -| State | Version | Branch | PHP | -|-------------|---------|----------|----------| -| dev | `^5.0` | `master` | `>= 8.2` | -| stable | `^4.1` | `v4.x` | `>= 7.1` | +Minimal production configuration: + +```neon +contributte.thepay: + merchantId: 'your-merchant-id' + projectId: (int) + apiPassword: '' +``` + +Demo configuration: + +```neon +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. + +## Services Available in DI Container + +- `ThePay\ApiClient\TheConfig` +- `ThePay\ApiClient\Service\SignatureService` +- `ThePay\ApiClient\Service\ApiService` (implements `ApiServiceInterface`) +- `ThePay\ApiClient\Service\GateService` (implements `GateServiceInterface`) +- `ThePay\ApiClient\TheClient` + +## Usage + +### Create a Payment + +```php +use Nette\Application\UI\Presenter; +use ThePay\ApiClient\Model\CreatePaymentParams; +use ThePay\ApiClient\TheClient; + +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()); + } +} +``` + +### Render Payment Buttons + +```php +use Nette\Application\UI\Presenter; +use ThePay\ApiClient\Model\CreatePaymentParams; +use ThePay\ApiClient\TheClient; + +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); + } +} +``` + +### Verify a Payment + +```php +use Nette\Application\UI\Presenter; +use ThePay\ApiClient\TheClient; + +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. + } + } +} +``` + +## Official Documentation + +- [ThePay API Client](https://github.com/ThePay/api-client) +- [ThePay API Documentation](https://thepay.docs.apiary.io/) ## Development See [how to contribute](https://contributte.org/contributing.html) to this package. -This package is currently maintaining by these authors. - +This package is currently maintained by these authors. - + - + -----