Discussing APIs and development related to customers, discounts, and order management.
Hi I am trying to create an order using Rest Admin API. Order creation was success but didn't receive payment URL for the order in response.
Following API are used.
order API
POST : https://shop.myshopify.com/admin/api/2023-04/orders.json BODY: { "order": { "line_items": [ { "variant_id": 44598046785811, "quantity": 1 } ], "customer": { "email": "madhana.sohan@gmail.com" }, "financial_status": "pending" } }
POST https://shop.myshopify.com/admin/api/2023-04/checkouts.json BODY: { "checkout": { "line_items": [ { "variant_id": 44598046785811, "quantity": 1 } ], "email": "dummy@email.com", "presentment_currency": "INR" } } RESPONSE { "errors": "[API] This action requires merchant approval for write_checkouts scope." }
Payment Gateway used: Razor pay Secure.
Please suggest.
Hey @ShivamShukla1
I think you'll want to use a Draft Order for this, which returns an invoice URL.
Scott | Developer Advocate @ Shopify
Thank you for your response Scott. I also tried using Draft Order API. But the invoice URL needs authentication. Invoice URL is redirected to login page and the user has to login for continuing to checkout page. Is there a way to bypass it.
Hi ShivamShukla1,
In order to create checkouts, your app needs to have the `write_checkouts` access scope, which is available for apps which are Sales Channels. You can follow this guide to create a Sales Channel which will open up the read and write checkouts scopes.
Hope this helps,
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
You might have this setting or this setting enabled.
I forgot to mention there's also the Storefront API which allows you to create carts and send customers to checkout. You can generate a token with the admin API.
Scott | Developer Advocate @ Shopify