Accepting credit cards, warehouses, and shipping and fulfilling orders
Hi!
I've developed a payment app extension, when a payment request initiated from shopify checkout and land in to given redirect URL we need line item details to proceed. Shopify initiates an HTTP POST request to payment gateway that contains information about the customer and the order see sample request in this link https://shopify.dev/docs/apps/payments/implementation/process-a-payment/offsite
Obviously, no line items are included in the request, and that is what the payment gateway requires before it can redirect to the payment gateway page. How can I get the order line items?
Hi @bhumika_dvb,
When Shopify initiates a payment request and redirects to your payment gateway, it doesn't include order line items in the HTTP POST request by default. To solve this issue, you can retrieve the order details, including line items, through Shopify's API.
Here's how you can get the order line items:
1. Use Shopify’s Admin API: Once Shopify triggers the redirect to your payment gateway, you can use the Shopify Admin API to fetch the order details, including the line items.
You can make a GET request to the orders endpoint using the order ID that is included in the initial request from Shopify.
Example request:
GET /admin/api/2023-01/orders/{order_id}.json
This will return all the details of the order, including the line items. In the response, you'll find a line_items array with all the product details.
Example response:
{
"order": {
"id": 123456789,
"line_items": [
{
"id": 987654321,
"variant_id": 123456,
"quantity": 2,
"price": "19.99",
"title": "Product Name",
"sku": "ABC123"
}
]
}
}
Ensure You Have API Permissions: Make sure that your payment app has the necessary API permissions to access order details. You may need read_orders permissions to fetch order details.
Handle the Delay: Since there may be a short delay between when the payment request is initiated and when you fetch the order details, ensure that your payment app can handle this latency. You might want to check if the order exists and retry if necessary.
This approach should allow you to get the order line items after the payment request is initiated and send them to the payment gateway.
Let me know if you need more details or further help!
Hi Bhumika,
After the order is created you can use payment ID that you received from Shopify in the very beginning and run and Admin GraphQL API query to obtain order ID and corresponding line items:
query {
orders(first: 1, query:"payment_id:your_paymnet_id_here") {
nodes {
id
name
lineItems(first:20) {
edges {
node {
id
name
}
}
}
}
}
}
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025