Pay for existing order
curl --request POST \
--url {protocol}://{host}/wp-json/cocart/preview/order-received/{order_id}/pay \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"order_key": "<string>",
"payment_method": "<string>",
"payment_data": [
{
"key": "wc-stripe-payment-token",
"value": "<string>"
}
]
}
'import requests
url = "{protocol}://{host}/wp-json/cocart/preview/order-received/{order_id}/pay"
payload = {
"order_key": "<string>",
"payment_method": "<string>",
"payment_data": [
{
"key": "wc-stripe-payment-token",
"value": "<string>"
}
]
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
order_key: '<string>',
payment_method: '<string>',
payment_data: [{key: 'wc-stripe-payment-token', value: '<string>'}]
})
};
fetch('{protocol}://{host}/wp-json/cocart/preview/order-received/{order_id}/pay', 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/order-received/{order_id}/pay",
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([
'order_key' => '<string>',
'payment_method' => '<string>',
'payment_data' => [
[
'key' => 'wc-stripe-payment-token',
'value' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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/order-received/{order_id}/pay"
payload := strings.NewReader("{\n \"order_key\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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/order-received/{order_id}/pay")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"order_key\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/preview/order-received/{order_id}/pay")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"order_key\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"order_id": 789,
"order_status": "processing",
"redirect_url": "https://example.com/checkout/order-received/789/?key=wc_order_abc123xyz"
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}Process payment for an unpaid order (pending or failed orders)
POST
/
order-received
/
{order_id}
/
pay
Pay for existing order
curl --request POST \
--url {protocol}://{host}/wp-json/cocart/preview/order-received/{order_id}/pay \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"order_key": "<string>",
"payment_method": "<string>",
"payment_data": [
{
"key": "wc-stripe-payment-token",
"value": "<string>"
}
]
}
'import requests
url = "{protocol}://{host}/wp-json/cocart/preview/order-received/{order_id}/pay"
payload = {
"order_key": "<string>",
"payment_method": "<string>",
"payment_data": [
{
"key": "wc-stripe-payment-token",
"value": "<string>"
}
]
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
order_key: '<string>',
payment_method: '<string>',
payment_data: [{key: 'wc-stripe-payment-token', value: '<string>'}]
})
};
fetch('{protocol}://{host}/wp-json/cocart/preview/order-received/{order_id}/pay', 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/order-received/{order_id}/pay",
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([
'order_key' => '<string>',
'payment_method' => '<string>',
'payment_data' => [
[
'key' => 'wc-stripe-payment-token',
'value' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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/order-received/{order_id}/pay"
payload := strings.NewReader("{\n \"order_key\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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/order-received/{order_id}/pay")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"order_key\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("{protocol}://{host}/wp-json/cocart/preview/order-received/{order_id}/pay")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"order_key\": \"<string>\",\n \"payment_method\": \"<string>\",\n \"payment_data\": [\n {\n \"key\": \"wc-stripe-payment-token\",\n \"value\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"order_id": 789,
"order_status": "processing",
"redirect_url": "https://example.com/checkout/order-received/789/?key=wc_order_abc123xyz"
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}{
"code": "<string>",
"message": "<string>",
"data": {
"status": 123
}
}This endpoint is currently shown as a preview of what’s currently in development and is subject to change.
Authorizations
basicAuthbearerAuth
WordPress username and password
Path Parameters
Unique identifier for the order
Body
application/json
Payment details for the order
Was this page helpful?
⌘I