paymentic / php-sdk
Paymentic SDK for PHP
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/paymentic/php-sdk
Requires
- php: >=8.2
- ext-json: *
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0||^3.0
- guzzlehttp/guzzle: ^6.3||^7.0
- guzzlehttp/psr7: ^1.4||^2.0
- illuminate/contracts: ^11.0||^12.0
- illuminate/http: ^11.0||^12.0
- illuminate/support: ^11.0||^12.0
- orchestra/testbench: ^9.0||^10.0
- phpstan/phpstan: ^1.0||^2.0
- phpunit/phpunit: ^11.0||^12.0
- symfony/config: ^7.0||^8.0
- symfony/dependency-injection: ^7.0||^8.0
- symfony/http-client: ^7.0||^8.0
- symfony/http-kernel: ^7.0||^8.0
Suggests
- guzzlehttp/guzzle: For using Guzzle HTTP client implementation
- illuminate/http: Required for Laravel HTTP client integration (^10.0|^11.0)
- illuminate/support: Required for Laravel integration (^10.0|^11.0)
- symfony/config: Required for Symfony integration (^7.0|^8.0)
- symfony/dependency-injection: Required for Symfony integration (^7.0|^8.0)
- symfony/http-client: Required for Symfony HTTP client integration (^7.0|^8.0)
- symfony/http-kernel: Required for Symfony integration (^7.0|^8.0)
README
Official PHP SDK for Paymentic payment gateway.
Requirements
- PHP 8.2+
- PSR-18 HTTP Client (e.g., Guzzle)
Installation
composer require paymentic/php-sdk
For HTTP client, install Guzzle (recommended):
composer require guzzlehttp/guzzle guzzlehttp/psr7
Quick Start
Initialize the Client
use Paymentic\Sdk\PaymenticClientFactory; use Paymentic\Sdk\Environment; $client = PaymenticClientFactory::create('your-api-key') ->withSandbox() // or ->withProduction() ->build();
Create a Transaction
use Paymentic\Sdk\Payment\Application\DTO\CreateTransactionRequest; use Paymentic\Sdk\Shared\Enum\Currency; $request = new CreateTransactionRequest( amount: '100.00', title: 'Order #12345', currency: Currency::PLN, description: 'Payment for order', externalReferenceId: 'order-12345', ); $response = $client->payment()->transactions()->create( pointId: 'your-point-id', request: $request, ); // Redirect user to payment page $paymentUrl = $response->paymentUrl;
Get Transaction by ID
$transaction = $client->payment()->transactions()->get( pointId: 'your-point-id', transactionId: 'transaction-uuid', ); echo $transaction->status->value;
Get Available Payment Channels
$channels = $client->payment()->points()->getChannels( pointId: 'your-point-id', ); foreach ($channels as $channel) { echo $channel->name; }
Webhook Handling
Use PaymentWebhookHandlerFactory to process incoming webhooks securely:
use Paymentic\Sdk\Payment\Webhook\PaymentWebhookHandlerFactory; $handler = PaymentWebhookHandlerFactory::create('your-webhook-signature-key'); // Get headers and body from your framework (e.g., Laravel, Symfony) $headers = new WebhookHeaders( event: $request->header('X-Paymentic-Event'), notificationId: $request->header('X-Paymentic-Notification-Id'), time: $request->header('X-Paymentic-Time'), signature: $request->header('X-Paymentic-Signature'), userAgent: $request->header('User-Agent'), ); $rawBody = $request->getContent(); try { $webhook = $handler->handle($headers, $rawBody); // Access webhook data $event = $webhook->headers->event; $payload = $webhook->payload; // Handle based on event type match ($event) { \Paymentic\Sdk\Shared\Webhook\WebhookEvent::PAYMENT_TRANSACTION_STATUS_CHANGED => handleTransactionStatusChanged($payload), \Paymentic\Sdk\Shared\Webhook\WebhookEvent::PAYMENT_REFUND_STATUS_CHANGED => handleRefundStatusChanged($payload), default => null, }; } catch (\Paymentic\Sdk\Shared\Webhook\Exception\InvalidWebhookSignatureException $e) { // Invalid signature - reject the request return response('Unauthorized', 401); }
Framework Integration
Laravel
The SDK auto-registers via package discovery.
Configuration
Publish the config file:
php artisan vendor:publish --tag=paymentic-config
Add to your .env:
PAYMENTIC_API_KEY=your-api-key PAYMENTIC_SANDBOX=true PAYMENTIC_WEBHOOK_SECRET=your-webhook-secret
Using Dependency Injection (recommended)
use Paymentic\Sdk\PaymenticClient; use Paymentic\Sdk\Payment\Application\DTO\CreateTransactionRequest; class PaymentController extends Controller { public function __construct( private PaymenticClient $paymentic, ) { } public function createPayment() { $request = new CreateTransactionRequest( amount: '100.00', title: 'Order #12345', ); $response = $this->paymentic->payment()->transactions()->create( pointId: 'your-point-id', request: $request, ); return redirect($response->paymentUrl); } }
Using Container
use Paymentic\Sdk\PaymenticClient; // Via container $client = app(PaymenticClient::class); // Or using alias $client = app('paymentic'); // Then use normally $transaction = $client->payment()->transactions()->get( pointId: 'your-point-id', transactionId: 'transaction-uuid', );
Manual Instantiation (without container)
use GuzzleHttp\Client; use GuzzleHttp\Psr7\HttpFactory; use Paymentic\Sdk\PaymenticClient; use Paymentic\Sdk\Environment; $httpFactory = new HttpFactory(); $client = new PaymenticClient( apiKey: 'your-api-key', httpClient: new Client(), requestFactory: $httpFactory, streamFactory: $httpFactory, environment: Environment::SANDBOX, ); $channels = $client->payment()->points()->getChannels('your-point-id');
Webhook Controller Example
use Illuminate\Http\Request; use Paymentic\Sdk\Shared\Webhook\WebhookHandler; use Paymentic\Sdk\Shared\Webhook\WebhookEvent; class WebhookController extends Controller { public function __construct( private WebhookHandler $webhookHandler, ) { } public function handle(Request $request) { $webhook = $this->webhookHandler->handle( headers: $request->headers->all(), rawBody: $request->getContent(), ); match ($webhook->headers->event) { WebhookEvent::PAYMENT_TRANSACTION_STATUS_CHANGED => $this->handleTransactionStatusChanged($webhook->payload), default => null, }; return response()->statusText('OK'); } }
Symfony
Register the bundle in config/bundles.php:
Paymentic\Sdk\Integration\Symfony\PaymenticBundle::class => ['all' => true],
License
MIT License. See LICENSE for details.