Order Purchase/Return/Refund/Cancellation
1 min
POST
https://api.us1.odp.optimizely.com/v3/events
Body Parameters
- bodyEvent[]requiredExamplesOrder Purchase Example Payload:
[ { "type": "order", "action": "purchase", "identifiers": { "email": "[email protected]" }, "data": { "ts": 123456789, "order": { "order_id": "OR345", "total": 109.65, "discount": 5, "subtotal": 103, "tax": 5.15, "shipping": 6.5, "coupon_code": "5OFF", "items": [ { "product_id": "2045", "price": 19, "quantity": 5, "discount": 0, "subtotal": 95 }, { "product_id": "2091", "price": 10, "quantity": 1, "discount": 2, "subtotal": 8 } ] } } } ]Order Cancellation Example Payload:[ { "type": "order", "action": "cancel", "identifiers": { "email": "[email protected]" }, "data": { "ts": 123456789, "order": { "order_id": "OR345", "total": -100, "items": [ { "product_id": "2045", "price": -10, "quantity": 10, "subtotal": -100 } ] } } } ]Partial Refund Example Payload:[ { "identifiers": { "email": "[email protected]" }, "type": "order", "action": "refund", "data": { "order": { "order_id": "ABC", "total": 10, "subtotal": 10 } } } ]- typestringrequiredExampleDescriptionDefaultorder
- actionstringrequiredExampleDescription
- identifiersmap<string, string>requiredDescription
- datamap<string, string>Description
- tsnumberDescription
- orderOrder
- order_idstringrequiredDescription
- totalnumberDescription
- subtotalnumberDescription
- taxnumber
- shippingnumber
- itemsLineItem[]
- product_idstringrequiredDescription
- pricenumberDescription
- quantitynumberDescription
- discountnumberDescription
- subtotalnumberDescription
Responses
202
- GenericUpdateResponse
- titlestring
- statusinteger<int32>Formatint32
- timestampstring
400
- undefinedExample
{ "title": "Bad Request", "status": 400, "timestamp": "2018-09-10T21:07:10-05:00", "detail": { "invalids": [ { "field": "delimiter", "reason": "Unrecognized delimiter, valid options are comma, tab or pipe" } ] } }
403
- undefinedExample
{ "message": "Forbidden" }
404
- undefinedExample
{ "title": "Bad Request", "status": 404, "timestamp": "2018-09-10T21:07:10-05:00", "detail": { "message": "Not found description" } }
curl
curl --request POST \
--url https://api.us1.odp.optimizely.com/v3/events \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '[
{
"type": "order",
"action": "purchase",
"identifiers": "",
"data": ""
}
]'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify([
{
"type": "order",
"action": "purchase",
"identifiers": "",
"data": ""
}
]);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.us1.odp.optimizely.com/v3/events", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.us1.odp.optimizely.com/v3/events")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
request.body = JSON.dump([
{
"type": "order",
"action": "purchase",
"identifiers": "",
"data": ""
}
])
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.us1.odp.optimizely.com/v3/events"
payload = json.dumps([
{
"type": "order",
"action": "purchase",
"identifiers": "",
"data": ""
}
])
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
202
// Accepted
{
"title": "",
"status": "",
"timestamp": ""
}400
// Bad Request
"{\"title\":\"Bad Request\",\"status\":400,\"timestamp\":\"2018-09-10T21:07:10-05:00\",\"detail\":{\"invalids\":[{\"field\":\"delimiter\",\"reason\":\"Unrecognized delimiter, valid options are comma, tab or pipe\"}]}}"403
// Forbidden
"{ \"message\": \"Forbidden\"}"404
// Not Found
"{\"title\":\"Bad Request\",\"status\":404,\"timestamp\":\"2018-09-10T21:07:10-05:00\",\"detail\":{\"message\":\"Not found description\"}}"