ClassesBigCommerceWebhooksWebhook

Webhook

Sets up a webhook in the BigCommerce API to send event-based requests to the WP site.

  • Full name: \BigCommerce\Webhooks\Webhook
  • This class is an Abstract class

Constants

ConstantVisibilityTypeValue
VERSIONpublic1
NAMEpublic
SCOPEpublic
AUTH_HEADERpublic’X-WP-BigCommerce-Webhook-Auth-Header’
INPUT_AUTH_HEADERpublic’HTTP_X_WP_BIGCOMMERCE_WEBHOOK_AUTH_HEADER’
PASSWORD_ERROR_CODEpublic’bigcommerce_webhook_password_error’
VALIDATION_ERROR_CODEpublic’bigcommerce_webhook_validation_error’
WEBHOOKS_OPTIONpublic’bigcommerce_webhooks’
AUTH_KEY_OPTIONpublic’bigcommerce_webhook_key’

Methods

__construct

Webhook constructor

public __construct(\BigCommerce\Api\Webhooks_Api $api_client): mixed

Parameters:

ParameterTypeDescription
$api_client\BigCommerce\Api\Webhooks_ApiThe client for making requests.

get_name

public get_name(): mixed

get_auth_header

Returns the value of the auth header.

public get_auth_header(): string|bool|null

Return Value:

The value, or false or null if filter_input fails.


create

Sends a request to BigCommerce to create a webhook.

public create(array $args): array

Parameters:

ParameterTypeDescription
$argsarrayRequest arguments.

Return Value:

Webhook data or an error response on failure.


is_webhook_exist

Check by destination and scope if webhook is already added to BigCommerce.

public is_webhook_exist(): mixed|null

Returns the id of the webhook


update

Sends a request to the BC API to update a webhook. Creates it if it doesn’t exist.

public update(): mixed

update_webhook

Send API request to update the webhook data

public update_webhook(mixed $id, mixed $data): mixed

Parameters:

ParameterTypeDescription
$idmixed
$datamixed

destination

public destination(): mixed

scope

public scope(): mixed

delete

Deletes a webhook from the BigCommerce database.

public delete(int $webhook_id): mixed

Parameters:

ParameterTypeDescription
$webhook_idintThe BC ID for the webhook entry.

validate

Validates an incoming request.

public validate(array $request, string|bool|null $password = null): bool|\WP_Error

Parameters:

ParameterTypeDescription
$requestarrayRequest data.
$passwordstring|bool|nullThe password to authenticate with.

Return Value:

True on validation or a WP_Error if the request isn’t valid.


get_webhook_payload

Get JSON input submitted from BigCommerce.

public get_webhook_payload(): array

Return Value:

JSON data converted to an array.


receive

Handles a webhook request.

public receive(): mixed

trigger_action

Triggers an action based on the webhook type and the request payload

protected trigger_action(array $request): void
  • This method is abstract.

Parameters:

ParameterTypeDescription
$requestarray


Automatically generated on 2025-01-21