WebhooksEntity: CDEK webhooks for Joomla and PHP

WT CDEK library - Documentation
Category: Libraries

WebhooksEntity in WT CDEK for Joomla covers webhook subscriptions and Joomla callback URLs. This reference explains its purpose, parameters and PHP examples for Joomla extensions.

WebhooksEntity manages CDEK webhook subscriptions and builds a Joomla incoming-webhook URL for the wtcdek system plugin.

Access the entity through the Cdek facade:

$webhooks = $cdek->webhooks();

getAllowedTypes()

Signature

public function getAllowedTypes(): array

REST API

No REST API call.

Purpose

Returns the webhook types known to the library without calling the API: ORDER_STATUS, ORDER_MODIFIED, PRINT_FORM, RECEIPT, PREALERT_CLOSED, ACCOMPANYING_WAYBILL, OFFICE_AVAILABILITY, DELIV_PROBLEM, DELIV_AGREEMENT, COURIER_INFO.

Parameters

No parameters.

Returns

Array of type strings.

Example

<?php

declare(strict_types=1);

use Webtolk\Cdekapi\Cdek;

defined('_JEXEC') or die;

$cdek = new Cdek();
$types = $cdek->webhooks()->getAllowedTypes();

getAll()

Signature

public function getAll(): array

REST API

  • GET /v2/webhooks

Purpose

Lists active webhook subscriptions.

Parameters

No parameters.

Returns

Subscription records.

Example

<?php

declare(strict_types=1);

use Webtolk\Cdekapi\Cdek;

defined('_JEXEC') or die;

$cdek = new Cdek();
$webhooks = $cdek->webhooks()->getAll();

create()

Signature

public function create(string $url, string $type): array

REST API

  • POST /v2/webhooks

Purpose

Creates a webhook subscription.

Parameters

$url: valid handler URL; $type: an allowed type from getAllowedTypes(). The library validates both.

Returns

Asynchronous subscription-creation response.

Example

<?php

declare(strict_types=1);

use Webtolk\Cdekapi\Cdek;

defined('_JEXEC') or die;

$cdek = new Cdek();

$result = $cdek->webhooks()->create(
    'https://example.com/index.php?option=com_ajax&plugin=wtcdek&group=system&format=raw&action=webhook',
    'ORDER_STATUS'
);

deleteByUuid()

Signature

public function deleteByUuid(string $uuid): array

REST API

  • DELETE /v2/webhooks/{uuid}

Purpose

Deletes a webhook subscription.

Parameters

$uuid: subscription UUID.

Returns

API response array.

Example

<?php

declare(strict_types=1);

use Webtolk\Cdekapi\Cdek;

defined('_JEXEC') or die;

$cdek = new Cdek();

$result = $cdek->webhooks()->deleteByUuid('11111111-1111-1111-1111-111111111111');

getByUuid()

Signature

public function getByUuid(string $uuid): array

REST API

  • GET /v2/webhooks/{uuid}

Purpose

Retrieves one webhook subscription.

Parameters

$uuid: subscription UUID.

Returns

Subscription data.

Example

<?php

declare(strict_types=1);

use Webtolk\Cdekapi\Cdek;

defined('_JEXEC') or die;

$cdek = new Cdek();

$result = $cdek->webhooks()->getByUuid('11111111-1111-1111-1111-111111111111');

getJoomlaWebhookUrl()

Signature

public function getJoomlaWebhookUrl(): string

REST API

No REST API call.

Purpose

Builds the com_ajax URL for incoming webhooks without calling the API.

Parameters

Requires enabled System - WT Cdek plugin and a configured webhook_token.

Returns

URL string, or an empty string if it cannot be built.

Example

<?php

declare(strict_types=1);

use Webtolk\Cdekapi\Cdek;

defined('_JEXEC') or die;

$cdek = new Cdek();
$url = $cdek->webhooks()->getJoomlaWebhookUrl();

Overview and getting started

WT CDEK 1.4.0 source code on GitHub

WebTolk Joomla Extensions

113 Extensions
12 Categories
587 Versions released
920737 Downloads