Re: ADMIN REST API Not getting payment url for created order

ADMIN REST API Not getting payment url for created order

ShivamShukla1
Visitor
2 0 0

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"
}
}
Status 201 created.
 
Checkout API
 
 
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."
}
 
So tried finding write_checkouts scope in Admin API configuration of my private app. But that scope is not listed in Admin API.

 

Payment Gateway used: Razor pay Secure.

 

Please suggest.

Replies 4 (4)

SBD_
Shopify Staff
1829 271 415

Hey @ShivamShukla1 

 

I think you'll want to use a Draft Order for this, which returns an invoice URL.

Scott | Developer Advocate @ Shopify 

ShivamShukla1
Visitor
2 0 0

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.

Liam
Shopify Staff
2873 312 820

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

SBD_
Shopify Staff
1829 271 415

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