curl --request POST \
--url {protocol}://{host}/wp-json/cocart/preview/checkout \
--header 'Content-Type: application/json' \
--data '
{
"billing_address": {
"first_name": "<string>",
"last_name": "<string>",
"company": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"state": "<string>",
"postcode": "<string>",
"country": "<string>",
"phone": "<string>",
"email": "jsmith@example.com"
},
"shipping_address": {
"first_name": "<string>",
"last_name": "<string>",
"company": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"state": "<string>",
"postcode": "<string>",
"country": "<string>"
},
"use_different_billing": true,
"payment_method": "<string>",
"payment_data": [
{
"key": "wc-stripe-payment-token",
"value": "<string>"
}
],
"shipping_method": "<string>",
"currency": "USD",
"create_account": false,
"customer_password": "<string>",
"customer_note": "<string>"
}
'import requests
url = "{protocol}://{host}/wp-json/cocart/preview/checkout"
payload = {
"billing_address": {
"first_name": "<string>",
"last_name": "<string>",
"company": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"state": "<string>",
"postcode": "<string>",
"country": "<string>",
"phone": "<string>",
"email": "jsmith@example.com"
},
"shipping_address": {
"first_name": "<string>",
"last_name": "<string>",
"company": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"state": "<string>",
"postcode": "<string>",
"country": "<string>"
},
"use_different_billing": True,
"payment_method": "<string>",
"payment_data": [
{
"key": "wc-stripe-payment-token",
"value": "<string>"
}
],
"shipping_method": "<string>",
"currency": "USD",
"create_account": False,
"customer_password": "<string>",
"customer_note": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
billing_address: {
first_name: '<string>',
last_name: '<string>',
company: '<string>',
address_1: '<string>',
address_2: '<string>',
city: '<string>',
state: '<string>',
postcode: '<string>',
country: '<string>',
phone: '<string>',
email: 'jsmith@example.com'
},
shipping_address: {
first_name: '<string>',
last_name: '<string>',
company: '<string>',
address_1: '<string>',
address_2: '<string>',
city: '<string>',
state: '<string>',
postcode: '<string>',
country: '<string>'
},
use_different_billing: true,
payment_method: '<string>',
payment_data: [{key: 'wc-stripe-payment-token', value: '<string>'}],
shipping_method: '<string>',
currency: 'USD',
create_account: false,
customer_password: '<string>',
customer_note: '<string>'
})
};
fetch('{protocol}://{host}/wp-json/cocart/preview/checkout', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "{protocol}://{host}/wp-json/cocart/preview/checkout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'billing_address' => [
'first_name' => '<string>',
'last_name' => '<string>',
'company' => '<string>',
'address_1' => '<string>',
'address_2' => '<string>',
'city' => '<string>',
'state' => '<string>',
'postcode' => '<string>',
'country' => '<string>',
'phone' => '<string>',
'email' => 'jsmith@example.com'
],
'shipping_address' => [
'first_name' => '<string>',
'last_name' => '<string>',
'company' => '<string>',
'address_1' => '<string>',
'address_2' => '<string>',
'city' => '<string>',
'state' => '<string>',
'postcode' => '<string>',
'country' => '<string>'
],
'use_different_billing' => true,
'payment_method' => '<string>',
'payment_data' => [
[
'key' => 'wc-stripe-payment-token',
'value' => '<string>'
]
],
'shipping_method' => '<string>',
'currency' => 'USD',
'create_account' => false,
'customer_password' => '<string>',
'customer_note' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{protocol}://{host}/wp-json/cocart/preview/checkout"
payload := strings.NewReader("{\n \"billing_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\",\n \"phone\": \"<string>\",\n \"email\": \"jsmith@example.com\"\n },\n \"shipping_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"use_different_billing\": true,\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ],\n \"shipping_method\": \"<string>\",\n \"currency\": \"USD\",\n \"create_account\": false,\n \"customer_password\": \"<string>\",\n \"customer_note\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("{protocol}://{host}/wp-json/cocart/preview/checkout")
.header("Content-Type", "application/json")
.body("{\n \"billing_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\",\n \"phone\": \"<string>\",\n \"email\": \"jsmith@example.com\"\n },\n \"shipping_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"use_different_billing\": true,\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ],\n \"shipping_method\": \"<string>\",\n \"currency\": \"USD\",\n \"create_account\": false,\n \"customer_password\": \"<string>\",\n \"customer_note\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/preview/checkout")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"billing_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\",\n \"phone\": \"<string>\",\n \"email\": \"jsmith@example.com\"\n },\n \"shipping_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"use_different_billing\": true,\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ],\n \"shipping_method\": \"<string>\",\n \"currency\": \"USD\",\n \"create_account\": false,\n \"customer_password\": \"<string>\",\n \"customer_note\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"order_id": 789,
"status": "processing",
"order_key": "wc_order_abc123xyz",
"order_number": "789",
"payment_result": {
"payment_status": "success",
"redirect_url": "https://example.com/checkout/order-received/789/?key=wc_order_abc123xyz",
"message": "Payment successful"
},
"customer_id": 123,
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"phone": "+1234567890",
"address_1": "123 Main St",
"address_2": "Apt 4B",
"city": "Anytown",
"state": "CA",
"postcode": "12345",
"country": "US",
"company": ""
},
"shipping_address": {
"first_name": "John",
"last_name": "Doe",
"address_1": "123 Main St",
"address_2": "Apt 4B",
"city": "Anytown",
"state": "CA",
"postcode": "12345",
"country": "US",
"company": ""
},
"cart_key": null
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}Complete the checkout process, create order, and process payment
curl --request POST \
--url {protocol}://{host}/wp-json/cocart/preview/checkout \
--header 'Content-Type: application/json' \
--data '
{
"billing_address": {
"first_name": "<string>",
"last_name": "<string>",
"company": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"state": "<string>",
"postcode": "<string>",
"country": "<string>",
"phone": "<string>",
"email": "jsmith@example.com"
},
"shipping_address": {
"first_name": "<string>",
"last_name": "<string>",
"company": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"state": "<string>",
"postcode": "<string>",
"country": "<string>"
},
"use_different_billing": true,
"payment_method": "<string>",
"payment_data": [
{
"key": "wc-stripe-payment-token",
"value": "<string>"
}
],
"shipping_method": "<string>",
"currency": "USD",
"create_account": false,
"customer_password": "<string>",
"customer_note": "<string>"
}
'import requests
url = "{protocol}://{host}/wp-json/cocart/preview/checkout"
payload = {
"billing_address": {
"first_name": "<string>",
"last_name": "<string>",
"company": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"state": "<string>",
"postcode": "<string>",
"country": "<string>",
"phone": "<string>",
"email": "jsmith@example.com"
},
"shipping_address": {
"first_name": "<string>",
"last_name": "<string>",
"company": "<string>",
"address_1": "<string>",
"address_2": "<string>",
"city": "<string>",
"state": "<string>",
"postcode": "<string>",
"country": "<string>"
},
"use_different_billing": True,
"payment_method": "<string>",
"payment_data": [
{
"key": "wc-stripe-payment-token",
"value": "<string>"
}
],
"shipping_method": "<string>",
"currency": "USD",
"create_account": False,
"customer_password": "<string>",
"customer_note": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
billing_address: {
first_name: '<string>',
last_name: '<string>',
company: '<string>',
address_1: '<string>',
address_2: '<string>',
city: '<string>',
state: '<string>',
postcode: '<string>',
country: '<string>',
phone: '<string>',
email: 'jsmith@example.com'
},
shipping_address: {
first_name: '<string>',
last_name: '<string>',
company: '<string>',
address_1: '<string>',
address_2: '<string>',
city: '<string>',
state: '<string>',
postcode: '<string>',
country: '<string>'
},
use_different_billing: true,
payment_method: '<string>',
payment_data: [{key: 'wc-stripe-payment-token', value: '<string>'}],
shipping_method: '<string>',
currency: 'USD',
create_account: false,
customer_password: '<string>',
customer_note: '<string>'
})
};
fetch('{protocol}://{host}/wp-json/cocart/preview/checkout', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "{protocol}://{host}/wp-json/cocart/preview/checkout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'billing_address' => [
'first_name' => '<string>',
'last_name' => '<string>',
'company' => '<string>',
'address_1' => '<string>',
'address_2' => '<string>',
'city' => '<string>',
'state' => '<string>',
'postcode' => '<string>',
'country' => '<string>',
'phone' => '<string>',
'email' => 'jsmith@example.com'
],
'shipping_address' => [
'first_name' => '<string>',
'last_name' => '<string>',
'company' => '<string>',
'address_1' => '<string>',
'address_2' => '<string>',
'city' => '<string>',
'state' => '<string>',
'postcode' => '<string>',
'country' => '<string>'
],
'use_different_billing' => true,
'payment_method' => '<string>',
'payment_data' => [
[
'key' => 'wc-stripe-payment-token',
'value' => '<string>'
]
],
'shipping_method' => '<string>',
'currency' => 'USD',
'create_account' => false,
'customer_password' => '<string>',
'customer_note' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{protocol}://{host}/wp-json/cocart/preview/checkout"
payload := strings.NewReader("{\n \"billing_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\",\n \"phone\": \"<string>\",\n \"email\": \"jsmith@example.com\"\n },\n \"shipping_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"use_different_billing\": true,\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ],\n \"shipping_method\": \"<string>\",\n \"currency\": \"USD\",\n \"create_account\": false,\n \"customer_password\": \"<string>\",\n \"customer_note\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("{protocol}://{host}/wp-json/cocart/preview/checkout")
.header("Content-Type", "application/json")
.body("{\n \"billing_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\",\n \"phone\": \"<string>\",\n \"email\": \"jsmith@example.com\"\n },\n \"shipping_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"use_different_billing\": true,\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ],\n \"shipping_method\": \"<string>\",\n \"currency\": \"USD\",\n \"create_account\": false,\n \"customer_password\": \"<string>\",\n \"customer_note\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/preview/checkout")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"billing_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\",\n \"phone\": \"<string>\",\n \"email\": \"jsmith@example.com\"\n },\n \"shipping_address\": {\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"company\": \"<string>\",\n \"address_1\": \"<string>\",\n \"address_2\": \"<string>\",\n \"city\": \"<string>\",\n \"state\": \"<string>\",\n \"postcode\": \"<string>\",\n \"country\": \"<string>\"\n },\n \"use_different_billing\": true,\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ],\n \"shipping_method\": \"<string>\",\n \"currency\": \"USD\",\n \"create_account\": false,\n \"customer_password\": \"<string>\",\n \"customer_note\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"order_id": 789,
"status": "processing",
"order_key": "wc_order_abc123xyz",
"order_number": "789",
"payment_result": {
"payment_status": "success",
"redirect_url": "https://example.com/checkout/order-received/789/?key=wc_order_abc123xyz",
"message": "Payment successful"
},
"customer_id": 123,
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"phone": "+1234567890",
"address_1": "123 Main St",
"address_2": "Apt 4B",
"city": "Anytown",
"state": "CA",
"postcode": "12345",
"country": "US",
"company": ""
},
"shipping_address": {
"first_name": "John",
"last_name": "Doe",
"address_1": "123 Main St",
"address_2": "Apt 4B",
"city": "Anytown",
"state": "CA",
"postcode": "12345",
"country": "US",
"company": ""
},
"cart_key": null
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}Overview
This endpoint completes the checkout process by creating an order and processing payment. Use this after collecting all necessary checkout information and customer details.Body
Checkout completion data
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Whether to use a different billing address from shipping
Payment method ID
Payment data to pass through to the payment gateway
Show child attributes
Show child attributes
Shipping method ID
Currency code for the order (e.g., USD, EUR, GBP). Enables multi-currency support with compatible plugins. If not provided, store default will be used.
^[A-Z]{3}$"USD"
Create customer account during checkout (for guest checkout)
Password for new customer account (required if create_account is true)
Customer note for the order
Response
Checkout processed successfully
Created order ID
Order status
Order key
Order number
Show child attributes
Show child attributes
Customer ID
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Cart key (null after successful checkout)
Was this page helpful?