Solved

Order payment by api

remarr
Shopify Partner
4 0 2

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.

Accepted Solution (1)

Ryan
Shopify Staff
499 42 120

This is an accepted solution.

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

 

Ryan | 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 the Shopify Help Center or the Shopify Blog

View solution in original post

Replies 7 (7)

Ryan
Shopify Staff
499 42 120

This is an accepted solution.

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

 

Ryan | 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 the Shopify Help Center or the Shopify Blog

remarr
Shopify Partner
4 0 2

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?

Ryan
Shopify Staff
499 42 120

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.

Ryan | 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 the Shopify Help Center or the Shopify Blog

remarr
Shopify Partner
4 0 2

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?

developer_2020
Shopify Partner
60 0 7

I'm trying to do the same thing. Is this at all possible without creating a sales channel?

tolgapaksoy
Shopify Partner
105 7 64

Have you published the product to your Sales Channel?

 

You need to do this for all products. By default, a new Sales Channel will be unable to use any products until you publish these products for your Sales Channel.

sehajdeepsingh
Shopify Partner
6 0 0

Curious, if there is a way to ALSO collect the payment via API?

Basically the use case is, to simply click a button and the checkout is created, payment is collected, checkout is marked complete AND an order is created. All of it is in the background via APIs. My app is able to create a checkout without having to convert my app into a sales channel. I am not able to figure out how to get the session ID from the vault, and then actually charge the customer the said amount, any help? I shall be thankful.