Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Added the support for AWS EventBridge Shopify Webhook #1114

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions src/Services/ApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,34 +366,52 @@ public function getWebhooks(array $params = []): ResponseAccess
*/
public function createWebhook(array $payload): ResponseAccess
{
$query = '
mutation webhookSubscriptionCreate(
$topic: WebhookSubscriptionTopic!,
$webhookSubscription: WebhookSubscriptionInput!
) {
webhookSubscriptionCreate(
topic: $topic
webhookSubscription: $webhookSubscription
) {
userErrors {
$addressType = Util::getShopifyConfig('webhook_address_type');
if($addressType === "arn"){
$query = '
mutation eventBridgeWebhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: EventBridgeWebhookSubscriptionInput!) {
eventBridgeWebhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {
userErrors {
field
message
}
webhookSubscription {
}
webhookSubscription {
id
topic
}
}
}
';
}else{
$query = '
mutation webhookSubscriptionCreate(
$topic: WebhookSubscriptionTopic!,
$webhookSubscription: WebhookSubscriptionInput!
) {
webhookSubscriptionCreate(
topic: $topic
webhookSubscription: $webhookSubscription
) {
userErrors {
field
message
}
webhookSubscription {
id
topic
}
}
}
';
}
';

// Change REST-format topics ("resource/event")
// to GraphQL-format topics ("RESOURCE_EVENT"), for pre-v17 compatibility
$topic = Util::getGraphQLWebhookTopic($payload['topic']);
$variables = [
'topic' => $topic,
'webhookSubscription' => [
'callbackUrl' => $payload['address'],
$addressType => $payload['address'],
'format' => 'JSON',
],
];
Expand Down
16 changes: 16 additions & 0 deletions src/resources/config/shopify-app.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,22 @@

'billing_redirect' => env('SHOPIFY_BILLING_REDIRECT', '/billing/process'),

/*
|--------------------------------------------------------------------------
| Shopify Webhooks Address Type
|--------------------------------------------------------------------------
|
| This option is for defining webhooks type.
| `callbackUrl` it's use https:// route.
| `arn` it's use arn route.
|
| This documentation will helps you
| https://shopify.dev/apps/webhooks/configuration/eventbridge
|
*/

'webhook_address_type' => env('SHOPIFY_WEBHOOK_ADDRESS_TYPE', 'arn'),
veed76 marked this conversation as resolved.
Show resolved Hide resolved

/*
|--------------------------------------------------------------------------
| Shopify Webhooks
Expand Down