1. Go to this page and download the library: Download trejjam/thepay library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
trejjam / thepay example snippets
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());
}
}
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);
}
}
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.
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.