Fulfillment Serviceobject
object
Contains functions for verifying fulfillment service requests.
See the fulfillment service documentation for more information.
Verifies requests coming from Shopify to fulfillment service apps
Anchor to request
request
Request
required
Promise<>
Was this section helpful?
Consume a fulfillment service notification request
/app/routes/**.ts
import {type ActionFunctionArgs} from 'react-router';
import {authenticate} from '../shopify.server';
export const action = async ({request}: ActionFunctionArgs) => {
const {admin, payload} = await authenticate.fulfillmentService(request);
const kind = payload.kind;
if (kind === 'FULFILLMENT_REQUEST') {
const response = await admin?.graphql(
`#graphql
query {
shop {
assignedFulfillmentOrders(first: 10, assignmentStatus: FULFILLMENT_REQUESTED) {
edges {
node {
id
destination {
firstName
lastName
}
lineItems(first: 10) {
edges {
node {
id
productTitle
sku
remainingQuantity
}
}
}
merchantRequests(first: 10, kind: FULFILLMENT_REQUEST) {
edges {
node {
message
}
}
}
}
}
}
}
}`,
);
const fulfillments = await response.json();
console.log(fulfillments);
}
return new Response();
};
Anchor to examplesExamples
Anchor to example-shopify-session-for-the-fulfillment-service-requestShopify session for the fulfillment service request
Use the session associated with this request to use the Admin GraphQL API
Was this section helpful?
Shopify session for the fulfillment service request
/app/routes/fulfillment_order_notification.ts
import { ActionFunctionArgs } from "react-router";
import { authenticate } from "../shopify.server";
export async function action({ request }: ActionFunctionArgs) {
const { admin, session } = await authenticate.fulfillmentService(request);
console.log(session.id)
return new Response();
}
Anchor to example-payloadpayload
Anchor to example-fulfillment-service-request-payloadFulfillment service request payload
Get the request's POST payload.
Was this section helpful?
Fulfillment service request payload
Example
/app/routes/fulfillment_order_notification.ts
import { ActionFunction } from "react-router";
import { authenticate } from "../shopify.server";
export const action: ActionFunction = async ({ request }) => {
const { payload } = await authenticate.fulfillmentService(request);
if(payload.kind === 'FULFILLMENT_REQUEST') {
// handle fulfillment request
} else if (payload.kind === 'CANCELLATION_REQUEST') {
// handle cancellation request
};
return new Response();
Anchor to example-sessionsession
Anchor to example-shopify-session-for-the-fulfillment-service-notification-requestShopify session for the fulfillment service notification request
Use the session associated with this request.
Was this section helpful?
Shopify session for the fulfillment service notification request
/app/routes/fulfillment_service_notification.tsx
import { ActionFunctionArgs } from "react-router";
import { authenticate } from "../shopify.server";
export const action = async ({ request }: ActionFunctionArgs) => {
const { session, admin } = await authenticate.fulfillmentService(request);
console.log(session.id)
return new Response();
};