Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopify: Add new sources for fulfillment orders (request accepted/rejected) #7122

Closed
wants to merge 2 commits into from

Conversation

colinmollenhour
Copy link

WHAT

This adds constants for the many new webhook event topics that were added in Shopify with the Fulfillment Order update. It also adds two new sources for when a fulfillment order is rejected or accepted.

WHY

The event topics are useful in cases where a user wants to perform an action when a fulfillment request is rejected (an error condition prevents the order from being accepted) or accepted (in which case take another follow-up action like update the status or send an email).

HOW

  1. Set up a fulfillment service
  2. Request fulfillment for an order
  3. Query new pending fulfillment requests
  4. Accept or reject the fulfillment request using the Shopify REST API
  5. Shopify will then fire this webohook. The event topics are documented here

Example payload:

{
  "fulfillment_order": {
    "id": "gid://shopify/FulfillmentOrder/1",
    "status": "in_progress",
    "request_status": "accepted"
  },
  "message": "We will ship the item tomorrow."
}

I don't know how to test this code exactly.. Looks very straightofrward so will test after it is merged unless there is another way to test sources but there is a lot of setup involved.

@vercel
Copy link

vercel bot commented Jul 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pipedream-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2023 5:55pm
pipedream-docs-redirect-do-not-edit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2023 5:55pm

@dylburger dylburger added the User submitted Submitted by a user label Jul 3, 2023
@dylburger dylburger added the triaged For maintainers: This issue has been triaged by a Pipedream employee label Jul 3, 2023
@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:

Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @colinmollenhour. Thanks for your contribution! LGTM!

Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @colinmollenhour. Thanks for your contribution! LGTM!

@vunguyenhung
Copy link
Collaborator

Hi @colinmollenhour, I got errors while creating the sources as below:

Fulfillment Request Accepted (Instant)
image

Fulfillment Request Rejected (Instant)
image

Would you mind checking again?

@colinmollenhour
Copy link
Author

@vunguyenhung These topics were added in API version 2023-01 but based on here it appears Pipedream is using 2023-04 already so that shouldn't be a problem.

The docs indicate that you need certain scopes, perhaps your app or API key is lacking these?
image

I tested adding a webhook for that topic to my own test store with an HTTP client and it worked without issue:

POST https://colin-tests.myshopify.com/admin/api/2023-04/webhooks.json
Content-Type: application/json
...

{"webhook":{"address":"****","topic":"fulfillment_orders/fulfillment_request_accepted","format":"json"}}

HTTP/1.1 201 Created
Date: Thu, 06 Jul 2023 22:18:45 GMT
Content-Type: application/json; charset=utf-8
X-Shopify-API-Version: 2023-04
...

{
  "webhook": {
    "id": 1236492583062,
    "address": "****",
    "topic": "fulfillment_orders\/fulfillment_request_accepted",
    "created_at": "2023-07-06T18:18:45-04:00",
    "updated_at": "2023-07-06T18:18:45-04:00",
    "format": "json",
    "fields": [],
    "metafield_namespaces": [],
    "api_version": "2021-04",
    "private_metafield_namespaces": []
  }
}

@vunguyenhung
Copy link
Collaborator

Hi @colinmollenhour, I have authorized pipedream to have full permission to Shopify. Did you tried to create the source with your shopify account?

@vunguyenhung vunguyenhung added the question Further information is requested label Jul 7, 2023
@colinmollenhour
Copy link
Author

I've not tried the code in this PR, not sure how to run it myself?

@michelle0927
Copy link
Collaborator

I've not tried the code in this PR, not sure how to run it myself?

Hi @colinmollenhour. You can test out the components using the Pipedream CLI.

@dylburger
Copy link
Contributor

Without more information, I'm going to close this issue. Feel free to reopen and add more details, if you'd like.

@dylburger dylburger closed this Jul 24, 2023
@colinmollenhour
Copy link
Author

colinmollenhour commented Jul 25, 2023

I did some debugging, it appears this is due to the node library used for Shopify is missing a lot of webhook topics in it's enum. I opened a PR here: MONEI/Shopify-api-node#621

Can you re-open and once it is updated I will continue testing?

@colinmollenhour
Copy link
Author

The node library was updated but I still get the same error.. Not able to look into it further at this time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested triaged For maintainers: This issue has been triaged by a Pipedream employee User submitted Submitted by a user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants