1. Go to this page and download the library: Download thepay/api-client 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/ */
/** @var \ThePay\ApiClient\TheConfig $theConfig */
// TheClient instance dependencies
$signatureService = new \ThePay\ApiClient\Service\SignatureService($theConfig);
/** @var \Psr\Http\Client\ClientInterface $httpClient some PSR-18 implementation */
/** @var \Psr\Http\Message\RequestFactoryInterface $requestFactory some PSR-17 implementation */
/** @var \Psr\Http\Message\StreamFactoryInterface $streamFactory some PSR-17 implementation */
// if you install suggested guzzle implementation you can use this:
// you MUST use RequestOptions::STREAM with true value!
// https://docs.guzzlephp.org/en/stable/request-options.html#stream
// $httpClient = new \GuzzleHttp\Client([\GuzzleHttp\RequestOptions::STREAM => true]);
// $requestFactory = $streamFactory = new \GuzzleHttp\Psr7\HttpFactory();
$apiService = new \ThePay\ApiClient\Service\ApiService(
$theConfig,
$signatureService,
$httpClient,
$requestFactory,
$streamFactory
);
$thePayClient = new \ThePay\ApiClient\TheClient(
$theConfig,
$apiService
);
/** @var \ThePay\ApiClient\TheClient $thePayClient */
/** @var \ThePay\ApiClient\Model\CreatePaymentCustomer $customer */
// Specify the payment parameters (100,- Kč) including it's unique identifier
$paymentParams = new \ThePay\ApiClient\Model\CreatePaymentParams(10000, 'CZK', 'uid123', $customer);
// Get the payment link and redirect the customer whenever you want
$payment = $thePayClient->createPayment($paymentParams);
$redirectLink = $payment->getPayUrl();
/** @var \ThePay\ApiClient\TheClient $thePayClient */
$payment = $thePayClient->getPayment($uid);
// check if the payment is paid
if ($payment->wasPaid()) {
// Check if the order isn't labeled as paid yet in your e-shop. If not, do so here.
// ...
}
/** @var \ThePay\ApiClient\TheClient $thePayClient */
$payment = $thePayClient->getPayment($uid);
// check if the payment is paid
if ($payment->wasPaid()) {
// Check if the order isn't labeled as paid yet. If not, do so here.
// ...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.