Service for managing Webhooks within the SDK Provides functionality for creating and configuring webhooks

Hierarchy (View Summary)

Constructors

Methods

  • Creates a new webhook subscription in the Coinbase Commerce platform

    Parameters

    Returns Promise<APIResponse<WebhookResponse>>

    A promise that resolves to the merchant data including the new webhook subscription

    const { data: merchantData } = await commerce.webhooks.createWebhook({
    url: 'https://example.com/webhooks/coinbase'
    });

    // Access the webhook subscriptions
    const webhooks = merchantData.data.settings.webhook_subscriptions;
    console.log(webhooks[webhooks.length - 1].id); // ID of the newly created webhook

    When the API request fails, URL validation fails, or other errors occur

  • Retrieves all webhook subscriptions for the merchant

    Returns Promise<APIResponse<WebhookResponse>>

    A promise that resolves to the merchant data including all webhook subscriptions

    const { data: merchantData } = await commerce.webhooks.getWebhooks();

    // Access all webhook subscriptions
    const webhooks = merchantData.data.settings.webhook_subscriptions;
    webhooks.forEach(webhook => {
    console.log(`Webhook ${webhook.id} pointing to ${webhook.url}`);
    });

    // Access other merchant settings
    console.log(`Webhook shared secret: ${merchantData.data.settings.webhook_shared_secret}`);

    When the API request fails or authentication fails

  • Updates an existing webhook subscription in the Coinbase Commerce platform

    Parameters

    • webhook_id: string

      The unique identifier of the webhook subscription to update

    • params: CreateWebhookParams

      The webhook update parameters

      • url: string

    Returns Promise<APIResponse<WebhookResponse>>

    A promise that resolves to the merchant data including the updated webhook subscription

    const { data: merchantData } = await commerce.webhooks.updateWebhook(
    'webhook-id-123',
    {
    url: 'https://example.com/webhooks/coinbase/new'
    }
    );

    // Access the updated webhook subscription
    const updatedWebhook = merchantData.data.settings.webhook_subscriptions
    .find(webhook => webhook.id === 'webhook-id-123');

    When the API request fails, webhook is not found, or URL validation fails