1. Go to this page and download the library: Download xultech/devpayr-php-sdk 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/ */
use DevPayr\DevPayr;
DevPayr::bootstrap([
'license' => $_ENV['LICENSE_KEY'],
'secret' => $_ENV['LICENSE_KEY'],
'injectablesPath' => __DIR__ . '/injectables',
'handleInjectables' => true,
'invalidBehavior' => 'modal', // or 'redirect', 'log', 'silent'
'customInvalidMessage' => 'Your license is invalid or has expired.',
]);
class MyCustomProcessor {
public static function handle(array $injectable, string $secret, string $basePath, bool $verify = true): string
{
// Decrypt and save however you want
$decrypted = CryptoHelper::decrypt($injectable['encrypted_content'], $secret);
// Example: save to cache or custom location
return '/custom/storage/path/' . $injectable['slug'];
}
}
use DevPayr\Services\LicenseService;
use DevPayr\Config\Config;
$config = new Config([...]);
$licenseService = new LicenseService($config);
$projectService = DevPayr::projects($config[
'per_page' =>50
]);
// List all projects
$projects = $projectService->list();
// Create a new project
$created = $projectService->create([
'name' => 'My Awesome App',
]);
// Update a project
$projectService->update($projectId, [
'name' => 'Updated Name',
]);
// Get a project
$projectService->get($projectId);
// Delete a project
$projectService->delete($projectId);
$licenseService = DevPayr::licenses($config);
// Issue a new license
$newLicense = $licenseService->create([
'project_id' => $projectId,
'expires_at' => '2025-12-31',
]);
// Delete an existing license
$licenseService->delete($projectId, $licenseId);
// Revoke a license
$licenseService->revoke($projectId, $licenseId);
// Reactivate a license
$licenseService->reactivate($projectId, $licenseId);
// Get a license
$licenseService->show($projectId, $licenseId);
// List all project's license
$licenseService->list($projectId);
$domainService = DevPayr::domains();
// List allowed domains for a project
$domains = $domainService->list($projectId);
// Get an allowed domain for a project
$domains = $domainService->show($projectId, $domainId);
// Add a domain
$domainService->create($projectId, [
'domain' => 'example.com',
]);
// Update a domain
$domainService->create($projectId, $domainId, [
'domain' => 'example.com',
]);
// Delete a domain
$domainService->delete($domainId);
$injectableService = DevPayr::injectables();
// List injectables for a project
$injectables = $injectableService->list($projectId);
// Get an injectables for a project
$injectables = $injectableService->list($projectId, $injectableId);
// Create a new injectable
$injectableService->create($projectId, [
'slug' => 'header-snippet',
'content' => '<?= "Hello World";
$paymentService = DevPayr::payments($config);
// Check if a license has been paid for
$paid = $paymentService->checkWithLicenseKey([
'license' => 'YOUR-LICENSE-KEY',
]);
// Check if a license has been paid for
$paid = $paymentService->checkWithApiKey($projectId);
if (!$paid) {
echo "⚠️ Payment
namespace DevPayr\Contracts;
/**
* Interface InjectableProcessorInterface
*
* Allows for custom processing of SDK injectables (e.g. decrypt, verify, and save elsewhere).
*/
interface InjectableProcessorInterface
{
/**
* Handle a single injectable payload.
*
* @param array $injectable Raw injectable data from API
* @param string $secret Shared secret (typically the license key)
* @param string $basePath Base path for writing (if file-based)
* @param bool $verifySignature Whether to verify HMAC signature
*
* @return string Path or identifier of the saved injectable
*/
public static function handle(array $injectable, string $secret, string $basePath, bool $verifySignature = true): string;
}
namespace App\Licensing;
use DevPayr\Contracts\InjectableProcessorInterface;
use DevPayr\Exceptions\DevPayrException;
use DevPayr\Support\CryptoHelper;
class CustomInjectableHandler implements InjectableProcessorInterface
{
public static function handle(array $injectable, string $secret, string $basePath, bool $verifySignature = true): string
{
$slug = $injectable['slug'];
$encrypted = $injectable['encrypted_content'] ?? $injectable['content'];
$decrypted = CryptoHelper::decrypt($encrypted, $secret);
// ✅ Save to a database, Redis, S3, or custom location
// Example: Save to temporary file
$path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "{$slug}.tmp";
if (file_put_contents($path, $decrypted) === false) {
throw new DevPayrException("Failed to store injectable: {$slug}");
}
return $path;
}
}