Order payment by api

Solved
Highlighted
New Member
4 0 0

Hi! I am writing a mobile application for users that will interact with Shopify API.
The question is: The user finds the product they like and makes an order for it. An order is created through

POST /admin/api/#{api_version}/orders.json

, it appears in Shopify. Now I need the user to be able to pay for this order. How to do it? In response to creating an order, come a link to find out the status, but there is no Pay button. A payment system is attached to the store, but there’s absolutely no payment. Help me please! If you already have such a question, send a link to it, because I have not found it yet.

0 Likes

Success.

Shopify Staff
Shopify Staff
472 35 91

Hi @remarr,

 

Are you trying to build a sales channel app? If so check out the guide here.

 

On the other hand, are you simply trying to help the user find a product and then send the customer to a Shopify Checkout page in order to complete their payment? If so, your app needs to create a checkout rather than an order, and then redirect the user to the webUrl of the checkout.

 

Hope that helps,

Ryan

 

Developer Experience @ Shopify
0 Likes
New Member
4 0 0

Thank you, I really need to do this. I try to send a request to the address

 

https://{my-shop} .myshopify.com / admin / api / 2019-07 / checkouts.json

{ "checkout": { "line_items": [ { "variant_id": 3751859945549, "quantity": 1 } ] } }

 

passing there and in response I get 422

 

{ "errors":{ "line_items":{ "0":{ "variant_id":[{"code": "invalid", "message": "is invalid", "options":{} }…] } } } }

 

, although the product is published and available. If I send an empty request, then the answer comes along with the web_url but not the product. What could be the reason?

0 Likes
Shopify Staff
Shopify Staff
472 35 91

You can only create a checkout using the REST API if your app is a sales channel.  Otherwise you need to create the checkout using the Storefront API like in the document I linked in the original post.

Developer Experience @ Shopify
0 Likes
New Member
4 0 0

Thank! I made my application public and connected the sales channel. Then I installed the application in the store, received the store access token and try to create checkout. I use X-Shopify-Access-Token and  insert the shop access token, an example of the order is taken from here

https://help.shopify.com/en/api/guides/sell-through-the-checkout-api

My request: https://{shop}.myshopify.com/admin/checkouts.json

{
  "checkout":{
   "line_items": [{
    "variant_id": 30055225557046,
     "quantity": 1
    }]
 }
}
My response comes the same
422 "variant_id":[{"code": "invalid""message": "is invalid""options":{} }]

what am I doing wrong?

0 Likes