New order created via ruby shopify_api gem - how does customer pay?

Solved
New Member
1 0 0

Hello!

 

I am fairly new to the shopify experience, so bare with me if this question is stupid. Basically, my company is looking to adopt shopify for its ecommerce platform and I have been doing an investigation of it's processes. So far, so good. There is one aspect I have not been able to figure out however:

 

I am creating an order object, and saving an existing customer to it:

# query the customer
customer = ShopifyAPI::Customer.search(query: "email:email@example.com").first

# Find product
product = ShopifyAPI::Product.where(title: 'cool title').first

# Create new order
order = ShopifyAPI::Order.new(
    :line_items => [
        ShopifyAPI::LineItem.new(
            :quantity => 1,
            :variant_id => product.variants.first.id
        )
    ],
    :customer => customer
)

The order object is created successfully, webhooks working correctly indicating the order is placed. I receive the email saying the order has been placed - BUT i haven't entered any credit card/payment information. The order is marked as 'unfulfilled' in the admin dashboard. I had assumed the email I received would ask me to enter payment information, but it didn't.

 

Where/how does that happen?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
503 98 91

This is an accepted solution.

Hi @dpalazzari 

 

Creating an order is exactly as it reads, simply creating the order vs. a checkout. If you are using Shopify online store channel you would have the orders created automatically for you into the admin. If you needed to upload historical orders for example, you can use the Order API to do so. 

If you are looking to build a headless website or process payments through the API you need to look at our Storefront APIs: https://shopify.dev/docs/storefront-api

This is also noted at the top of the Order API docs for reference: 

You can't use the Order resource to create a new checkout for an individual store. To create a checkout, you need to use the Checkout API, or an SDK powered by the Storefront API, such as the JavaScript Buy SDK, iOS Buy SDK, or Android Buy SDK.

 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes