PHP code example of kennzeichenservices / dropshipping-sdk
1. Go to this page and download the library: Download kennzeichenservices/dropshipping-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/ */
kennzeichenservices / dropshipping-sdk example snippets
use Dropshipping\Configuration\DropshippingConfig;
$config = new DropshippingConfig(
host: 'api.example.com',
dropshippingClientId: 123,
username: 'your-username',
password: 'your-password',
webhookSignatureSecret: 'your-webhook-secret', // optional
);
use Dropshipping\Client\ApiClient;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;
$httpClient = new Client();
$factory = new HttpFactory();
$client = new ApiClient(
config: $config,
httpClient: $httpClient,
psrRequestFactory: $factory,
streamFactory: $factory,
);
use Dropshipping\Contracts\WebhookHandlerInterface;
use Dropshipping\DTO\Webhooks\{VehicleDeregistrationXkfzEvent, WebhookEventInterface};
use Dropshipping\Enums\WebhookEventType;
class DeregistrationXkfzHandler implements WebhookHandlerInterface
{
public function __construct(private readonly ApiClient $client) {}
public function supports(WebhookEventInterface $event): bool
{
return $event->getEventType() === WebhookEventType::VehicleDeregistrationXkfzEvent;
}
public function handle(WebhookEventInterface $event): void
{
/** @var VehicleDeregistrationXkfzEvent $event */
echo "Order {$event->order->id} status: {$event->status->value} ({$event->derivedStatus})\n";
foreach ($event->messages ?? [] as $message) {
echo "[{$message->type}] {$message->text}\n";
}
foreach ($event->files ?? [] as $file) {
$content = $this->client->vehicleDeregistrations->downloadFileContent($file->fileAccessKey);
file_put_contents("{$file->purposeType->value}.pdf", $content);
}
}
}
use Dropshipping\Contracts\WebhookHandlerInterface;
use Dropshipping\DS;
use Dropshipping\DTO\Webhooks\WebhookEventInterface;
use Dropshipping\Enums\WebhookEventType;
// Implement a handler
class ShipmentHandler implements WebhookHandlerInterface
{
public function supports(WebhookEventInterface $event): bool
{
return $event->getEventType() === WebhookEventType::DeliveryShipment;
}
public function handle(WebhookEventInterface $event): void
{
echo "Order {$event->order->id} shipped, tracking: {$event->delivery->trackingCode}\n";
}
}
// Wire up pipeline and dispatcher
$dispatcher = DS::webhookDispatcher(DS::webhookPipeline($config->getWebhookSignatureSecret()));
$dispatcher->registerHandler(new ShipmentHandler());
// Receive a webhook (e.g. in a controller)
$dispatcher->dispatch(DS::incomingWebhook());
use Dropshipping\Contracts\WebhookQueueInterface;
use Dropshipping\DS;
// Implement WebhookQueueInterface with your queue backend (Redis, RabbitMQ, database, etc.)
$queue = new YourQueueImplementation();
// In your HTTP controller: enqueue instead of processing inline
DS::queueWebhookDispatcher($queue)->dispatch(DS::incomingWebhook());
// In a background worker process
$processed = DS::webhookWorker($queue, $dispatcher)->run(maxMessages: 100);
// Throws: Field "firstName" must be between 1 and 100 characters, got 110
new Address(firstName: str_repeat('x', 110), ...);
// Throws: Field "email" must be a valid email address
new OrderCreationRequest(email: 'not-an-email', ...);
// Throws: Field "seasonStartMonth" must be between 1 and 12, got 0
new LicensePlateReservationCustomization(seasonStartMonth: 0, ...);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.