简体   繁体   中英

How can I checkout my Shopify order using API?

I am using Shopify API to create products and orders. But I can't find a way to checkout my order through api call.

    $request = new CURLCall();
    $line_items = array("line_items" =>
        array(array(
                "variant_id" => 123456789,
                "quantity" => 5))
    );
    $data = json_encode(array("checkout" => $line_items));
    $url = "https://{API_KEY}:{Password}@shop.myshopify.com/admin/checkouts.json";

    // Initialize CURL for PHP
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen($data),
        'Accept: application/json')
    );
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    $response = curl_exec($curl);
    print_r($response);

Code above returns this message,

{"errors":"Not Found"}

Thank you.

First off, you cannot checkout an order with the API. Secondly, you can read the abandoned checkouts with your call to the checkouts endpoint.

If you want to actually cash in an order you create, you would want to create a transaction for the order, not a checkout. You can create capture transactions for example. You can never actually transact money this way though... your customer has to enter their credit card details to turn API created orders into real ones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM