Contains functions for verifying fulfillment service requests. See the [fulfillment service documentation](https://shopify.dev/docs/apps/fulfillment/fulfillment-service-apps) for more information.
import {type ActionFunctionArgs} from '@remix-run/node';
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();
};
Verifies requests coming from Shopify to fulfillment service apps
request: Request
export type AuthenticateFulfillmentService< ConfigArg extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources, > = ( request: Request, ) => Promise<FulfillmentServiceContext<ConfigArg, Resources>>;
An admin context for the fulfillment service request. Returned only if there is a session for the shop.
The payload from the fulfillment service request.
A session with an offline token for the shop. Returned only if there is a session for the shop.
Record<string, any> & { kind: string; }
Contains functions for verifying fulfillment service requests. See the [fulfillment service documentation](https://shopify.dev/docs/apps/fulfillment/fulfillment-service-apps) for more information.
import { ActionFunctionArgs } from "@remix-run/node";
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();
}
/app/routes/fulfillment_order_notification.ts
import { ActionFunction } from "@remix-run/node";
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();
import { ActionFunctionArgs } from "@remix-run/node";
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();
};