Create a session
curl --request POST \
--url https://api.tabby.ai/api/v2/checkout \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"payment": {
"amount": "100",
"currency": "AED",
"buyer": {
"name": "John Doe",
"email": "jsmith@example.com",
"phone": "500000001",
"dob": "2000-01-20"
},
"shipping_address": {
"city": "Dubai",
"address": "Dubai",
"zip": "1111"
},
"order": {
"reference_id": "1001",
"items": [
{
"title": "Name of the product",
"quantity": 1,
"unit_price": "0.00",
"category": "Clothes",
"reference_id": "SKU123",
"description": "Description of the product",
"discount_amount": "0.00",
"image_url": "https://example.com/",
"product_url": "https://example.com/",
"gender": "Kids",
"color": "white",
"product_material": "cotton",
"size_type": "EU",
"size": "M",
"brand": "Name of the Brand",
"is_refundable": true,
"barcode": "12345678",
"ppn": "MNXT2ZM/A",
"seller": "Name of the Seller"
}
],
"updated_at": "2023-11-07T05:31:56Z",
"tax_amount": "0.00",
"shipping_amount": "0.00",
"discount_amount": "0.00"
},
"buyer_history": {
"registered_since": "2023-11-07T05:31:56Z",
"loyalty_level": 0,
"wishlist_count": 0,
"is_social_networks_connected": true,
"is_phone_number_verified": true,
"is_email_verified": true
},
"order_history": [
{
"purchased_at": "2023-11-07T05:31:56Z",
"amount": "100",
"buyer": {
"name": "John Doe",
"email": "jsmith@example.com",
"phone": "500000001",
"dob": "2000-01-20"
},
"shipping_address": {
"city": "Dubai",
"address": "Dubai",
"zip": "1111"
},
"payment_method": "card",
"items": [
{
"reference_id": "SKU123",
"title": "Name of the product",
"description": "Description of the product",
"quantity": 1,
"unit_price": "0.00",
"discount_amount": "0.00",
"image_url": "https://example.com/",
"product_url": "https://example.com/",
"gender": "Kids",
"category": "Clothes",
"color": "white",
"product_material": "cotton",
"size_type": "EU",
"size": "M",
"brand": "Name of the Brand",
"is_refundable": true,
"barcode": "12345678",
"ppn": "MNXT2ZM/A",
"seller": "Name of the Seller"
}
]
}
],
"description": "test payload",
"meta": {
"customer": "#customer-id",
"order_id": "#1234"
},
"attachment": {
"body": "{\"flight_reservation_details\": {\"pnr\": \"TR9088999\",\"itinerary\": [...],\"insurance\": [...],\"passengers\": [...],\"affiliate_name\": \"some affiliate\"}}",
"content_type": "application/vnd.tabby.v1+json"
}
},
"lang": "en",
"merchant_code": "code provided to you from Tabby side",
"merchant_urls": {
"success": "https://your-store/success",
"cancel": "https://your-store/cancel",
"failure": "https://your-store/failure"
},
"token": null
}
'import requests
url = "https://api.tabby.ai/api/v2/checkout"
payload = {
"payment": {
"amount": "100",
"currency": "AED",
"buyer": {
"name": "John Doe",
"email": "jsmith@example.com",
"phone": "500000001",
"dob": "2000-01-20"
},
"shipping_address": {
"city": "Dubai",
"address": "Dubai",
"zip": "1111"
},
"order": {
"reference_id": "1001",
"items": [
{
"title": "Name of the product",
"quantity": 1,
"unit_price": "0.00",
"category": "Clothes",
"reference_id": "SKU123",
"description": "Description of the product",
"discount_amount": "0.00",
"image_url": "https://example.com/",
"product_url": "https://example.com/",
"gender": "Kids",
"color": "white",
"product_material": "cotton",
"size_type": "EU",
"size": "M",
"brand": "Name of the Brand",
"is_refundable": True,
"barcode": "12345678",
"ppn": "MNXT2ZM/A",
"seller": "Name of the Seller"
}
],
"updated_at": "2023-11-07T05:31:56Z",
"tax_amount": "0.00",
"shipping_amount": "0.00",
"discount_amount": "0.00"
},
"buyer_history": {
"registered_since": "2023-11-07T05:31:56Z",
"loyalty_level": 0,
"wishlist_count": 0,
"is_social_networks_connected": True,
"is_phone_number_verified": True,
"is_email_verified": True
},
"order_history": [
{
"purchased_at": "2023-11-07T05:31:56Z",
"amount": "100",
"buyer": {
"name": "John Doe",
"email": "jsmith@example.com",
"phone": "500000001",
"dob": "2000-01-20"
},
"shipping_address": {
"city": "Dubai",
"address": "Dubai",
"zip": "1111"
},
"payment_method": "card",
"items": [
{
"reference_id": "SKU123",
"title": "Name of the product",
"description": "Description of the product",
"quantity": 1,
"unit_price": "0.00",
"discount_amount": "0.00",
"image_url": "https://example.com/",
"product_url": "https://example.com/",
"gender": "Kids",
"category": "Clothes",
"color": "white",
"product_material": "cotton",
"size_type": "EU",
"size": "M",
"brand": "Name of the Brand",
"is_refundable": True,
"barcode": "12345678",
"ppn": "MNXT2ZM/A",
"seller": "Name of the Seller"
}
]
}
],
"description": "test payload",
"meta": {
"customer": "#customer-id",
"order_id": "#1234"
},
"attachment": {
"body": "{\"flight_reservation_details\": {\"pnr\": \"TR9088999\",\"itinerary\": [...],\"insurance\": [...],\"passengers\": [...],\"affiliate_name\": \"some affiliate\"}}",
"content_type": "application/vnd.tabby.v1+json"
}
},
"lang": "en",
"merchant_code": "code provided to you from Tabby side",
"merchant_urls": {
"success": "https://your-store/success",
"cancel": "https://your-store/cancel",
"failure": "https://your-store/failure"
},
"token": None
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
payment: {
amount: '100',
currency: 'AED',
buyer: {
name: 'John Doe',
email: 'jsmith@example.com',
phone: '500000001',
dob: '2000-01-20'
},
shipping_address: {city: 'Dubai', address: 'Dubai', zip: '1111'},
order: {
reference_id: '1001',
items: [
{
title: 'Name of the product',
quantity: 1,
unit_price: '0.00',
category: 'Clothes',
reference_id: 'SKU123',
description: 'Description of the product',
discount_amount: '0.00',
image_url: 'https://example.com/',
product_url: 'https://example.com/',
gender: 'Kids',
color: 'white',
product_material: 'cotton',
size_type: 'EU',
size: 'M',
brand: 'Name of the Brand',
is_refundable: true,
barcode: '12345678',
ppn: 'MNXT2ZM/A',
seller: 'Name of the Seller'
}
],
updated_at: '2023-11-07T05:31:56Z',
tax_amount: '0.00',
shipping_amount: '0.00',
discount_amount: '0.00'
},
buyer_history: {
registered_since: '2023-11-07T05:31:56Z',
loyalty_level: 0,
wishlist_count: 0,
is_social_networks_connected: true,
is_phone_number_verified: true,
is_email_verified: true
},
order_history: [
{
purchased_at: '2023-11-07T05:31:56Z',
amount: '100',
buyer: {
name: 'John Doe',
email: 'jsmith@example.com',
phone: '500000001',
dob: '2000-01-20'
},
shipping_address: {city: 'Dubai', address: 'Dubai', zip: '1111'},
payment_method: 'card',
items: [
{
reference_id: 'SKU123',
title: 'Name of the product',
description: 'Description of the product',
quantity: 1,
unit_price: '0.00',
discount_amount: '0.00',
image_url: 'https://example.com/',
product_url: 'https://example.com/',
gender: 'Kids',
category: 'Clothes',
color: 'white',
product_material: 'cotton',
size_type: 'EU',
size: 'M',
brand: 'Name of the Brand',
is_refundable: true,
barcode: '12345678',
ppn: 'MNXT2ZM/A',
seller: 'Name of the Seller'
}
]
}
],
description: 'test payload',
meta: {customer: '#customer-id', order_id: '#1234'},
attachment: {
body: JSON.stringify('{"flight_reservation_details": {"pnr": "TR9088999","itinerary": [...],"insurance": [...],"passengers": [...],"affiliate_name": "some affiliate"}}'),
content_type: 'application/vnd.tabby.v1+json'
}
},
lang: 'en',
merchant_code: 'code provided to you from Tabby side',
merchant_urls: {
success: 'https://your-store/success',
cancel: 'https://your-store/cancel',
failure: 'https://your-store/failure'
},
token: null
})
};
fetch('https://api.tabby.ai/api/v2/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 => "https://api.tabby.ai/api/v2/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([
'payment' => [
'amount' => '100',
'currency' => 'AED',
'buyer' => [
'name' => 'John Doe',
'email' => 'jsmith@example.com',
'phone' => '500000001',
'dob' => '2000-01-20'
],
'shipping_address' => [
'city' => 'Dubai',
'address' => 'Dubai',
'zip' => '1111'
],
'order' => [
'reference_id' => '1001',
'items' => [
[
'title' => 'Name of the product',
'quantity' => 1,
'unit_price' => '0.00',
'category' => 'Clothes',
'reference_id' => 'SKU123',
'description' => 'Description of the product',
'discount_amount' => '0.00',
'image_url' => 'https://example.com/',
'product_url' => 'https://example.com/',
'gender' => 'Kids',
'color' => 'white',
'product_material' => 'cotton',
'size_type' => 'EU',
'size' => 'M',
'brand' => 'Name of the Brand',
'is_refundable' => true,
'barcode' => '12345678',
'ppn' => 'MNXT2ZM/A',
'seller' => 'Name of the Seller'
]
],
'updated_at' => '2023-11-07T05:31:56Z',
'tax_amount' => '0.00',
'shipping_amount' => '0.00',
'discount_amount' => '0.00'
],
'buyer_history' => [
'registered_since' => '2023-11-07T05:31:56Z',
'loyalty_level' => 0,
'wishlist_count' => 0,
'is_social_networks_connected' => true,
'is_phone_number_verified' => true,
'is_email_verified' => true
],
'order_history' => [
[
'purchased_at' => '2023-11-07T05:31:56Z',
'amount' => '100',
'buyer' => [
'name' => 'John Doe',
'email' => 'jsmith@example.com',
'phone' => '500000001',
'dob' => '2000-01-20'
],
'shipping_address' => [
'city' => 'Dubai',
'address' => 'Dubai',
'zip' => '1111'
],
'payment_method' => 'card',
'items' => [
[
'reference_id' => 'SKU123',
'title' => 'Name of the product',
'description' => 'Description of the product',
'quantity' => 1,
'unit_price' => '0.00',
'discount_amount' => '0.00',
'image_url' => 'https://example.com/',
'product_url' => 'https://example.com/',
'gender' => 'Kids',
'category' => 'Clothes',
'color' => 'white',
'product_material' => 'cotton',
'size_type' => 'EU',
'size' => 'M',
'brand' => 'Name of the Brand',
'is_refundable' => true,
'barcode' => '12345678',
'ppn' => 'MNXT2ZM/A',
'seller' => 'Name of the Seller'
]
]
]
],
'description' => 'test payload',
'meta' => [
'customer' => '#customer-id',
'order_id' => '#1234'
],
'attachment' => [
'body' => '{"flight_reservation_details": {"pnr": "TR9088999","itinerary": [...],"insurance": [...],"passengers": [...],"affiliate_name": "some affiliate"}}',
'content_type' => 'application/vnd.tabby.v1+json'
]
],
'lang' => 'en',
'merchant_code' => 'code provided to you from Tabby side',
'merchant_urls' => [
'success' => 'https://your-store/success',
'cancel' => 'https://your-store/cancel',
'failure' => 'https://your-store/failure'
],
'token' => null
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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 := "https://api.tabby.ai/api/v2/checkout"
payload := strings.NewReader("{\n \"payment\": {\n \"amount\": \"100\",\n \"currency\": \"AED\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"order\": {\n \"reference_id\": \"1001\",\n \"items\": [\n {\n \"title\": \"Name of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"category\": \"Clothes\",\n \"reference_id\": \"SKU123\",\n \"description\": \"Description of the product\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ],\n \"updated_at\": \"2023-11-07T05:31:56Z\",\n \"tax_amount\": \"0.00\",\n \"shipping_amount\": \"0.00\",\n \"discount_amount\": \"0.00\"\n },\n \"buyer_history\": {\n \"registered_since\": \"2023-11-07T05:31:56Z\",\n \"loyalty_level\": 0,\n \"wishlist_count\": 0,\n \"is_social_networks_connected\": true,\n \"is_phone_number_verified\": true,\n \"is_email_verified\": true\n },\n \"order_history\": [\n {\n \"purchased_at\": \"2023-11-07T05:31:56Z\",\n \"amount\": \"100\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"payment_method\": \"card\",\n \"items\": [\n {\n \"reference_id\": \"SKU123\",\n \"title\": \"Name of the product\",\n \"description\": \"Description of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"category\": \"Clothes\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ]\n }\n ],\n \"description\": \"test payload\",\n \"meta\": {\n \"customer\": \"#customer-id\",\n \"order_id\": \"#1234\"\n },\n \"attachment\": {\n \"body\": \"{\\\"flight_reservation_details\\\": {\\\"pnr\\\": \\\"TR9088999\\\",\\\"itinerary\\\": [...],\\\"insurance\\\": [...],\\\"passengers\\\": [...],\\\"affiliate_name\\\": \\\"some affiliate\\\"}}\",\n \"content_type\": \"application/vnd.tabby.v1+json\"\n }\n },\n \"lang\": \"en\",\n \"merchant_code\": \"code provided to you from Tabby side\",\n \"merchant_urls\": {\n \"success\": \"https://your-store/success\",\n \"cancel\": \"https://your-store/cancel\",\n \"failure\": \"https://your-store/failure\"\n },\n \"token\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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("https://api.tabby.ai/api/v2/checkout")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payment\": {\n \"amount\": \"100\",\n \"currency\": \"AED\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"order\": {\n \"reference_id\": \"1001\",\n \"items\": [\n {\n \"title\": \"Name of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"category\": \"Clothes\",\n \"reference_id\": \"SKU123\",\n \"description\": \"Description of the product\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ],\n \"updated_at\": \"2023-11-07T05:31:56Z\",\n \"tax_amount\": \"0.00\",\n \"shipping_amount\": \"0.00\",\n \"discount_amount\": \"0.00\"\n },\n \"buyer_history\": {\n \"registered_since\": \"2023-11-07T05:31:56Z\",\n \"loyalty_level\": 0,\n \"wishlist_count\": 0,\n \"is_social_networks_connected\": true,\n \"is_phone_number_verified\": true,\n \"is_email_verified\": true\n },\n \"order_history\": [\n {\n \"purchased_at\": \"2023-11-07T05:31:56Z\",\n \"amount\": \"100\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"payment_method\": \"card\",\n \"items\": [\n {\n \"reference_id\": \"SKU123\",\n \"title\": \"Name of the product\",\n \"description\": \"Description of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"category\": \"Clothes\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ]\n }\n ],\n \"description\": \"test payload\",\n \"meta\": {\n \"customer\": \"#customer-id\",\n \"order_id\": \"#1234\"\n },\n \"attachment\": {\n \"body\": \"{\\\"flight_reservation_details\\\": {\\\"pnr\\\": \\\"TR9088999\\\",\\\"itinerary\\\": [...],\\\"insurance\\\": [...],\\\"passengers\\\": [...],\\\"affiliate_name\\\": \\\"some affiliate\\\"}}\",\n \"content_type\": \"application/vnd.tabby.v1+json\"\n }\n },\n \"lang\": \"en\",\n \"merchant_code\": \"code provided to you from Tabby side\",\n \"merchant_urls\": {\n \"success\": \"https://your-store/success\",\n \"cancel\": \"https://your-store/cancel\",\n \"failure\": \"https://your-store/failure\"\n },\n \"token\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tabby.ai/api/v2/checkout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payment\": {\n \"amount\": \"100\",\n \"currency\": \"AED\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"order\": {\n \"reference_id\": \"1001\",\n \"items\": [\n {\n \"title\": \"Name of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"category\": \"Clothes\",\n \"reference_id\": \"SKU123\",\n \"description\": \"Description of the product\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ],\n \"updated_at\": \"2023-11-07T05:31:56Z\",\n \"tax_amount\": \"0.00\",\n \"shipping_amount\": \"0.00\",\n \"discount_amount\": \"0.00\"\n },\n \"buyer_history\": {\n \"registered_since\": \"2023-11-07T05:31:56Z\",\n \"loyalty_level\": 0,\n \"wishlist_count\": 0,\n \"is_social_networks_connected\": true,\n \"is_phone_number_verified\": true,\n \"is_email_verified\": true\n },\n \"order_history\": [\n {\n \"purchased_at\": \"2023-11-07T05:31:56Z\",\n \"amount\": \"100\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"payment_method\": \"card\",\n \"items\": [\n {\n \"reference_id\": \"SKU123\",\n \"title\": \"Name of the product\",\n \"description\": \"Description of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"category\": \"Clothes\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ]\n }\n ],\n \"description\": \"test payload\",\n \"meta\": {\n \"customer\": \"#customer-id\",\n \"order_id\": \"#1234\"\n },\n \"attachment\": {\n \"body\": \"{\\\"flight_reservation_details\\\": {\\\"pnr\\\": \\\"TR9088999\\\",\\\"itinerary\\\": [...],\\\"insurance\\\": [...],\\\"passengers\\\": [...],\\\"affiliate_name\\\": \\\"some affiliate\\\"}}\",\n \"content_type\": \"application/vnd.tabby.v1+json\"\n }\n },\n \"lang\": \"en\",\n \"merchant_code\": \"code provided to you from Tabby side\",\n \"merchant_urls\": {\n \"success\": \"https://your-store/success\",\n \"cancel\": \"https://your-store/cancel\",\n \"failure\": \"https://your-store/failure\"\n },\n \"token\": null\n}"
response = http.request(request)
puts response.read_body{
"id": "session id, uuid format",
"configuration": {
"available_products": {
"installments": [
{
"web_url": "https://checkout.tabby.ai/",
"qr_code": "https://api.tabby.ai/api/v2/checkout/{id}/hpp_link_qr"
}
]
},
"products": {
"installments": {
"type": "installments",
"is_available": true,
"rejection_reason": null
}
}
},
"token": null,
"payment": {
"amount": "100",
"currency": "AED",
"order": {
"reference_id": "1001",
"items": [
{
"title": "Name of the product",
"quantity": 1,
"unit_price": "0.00",
"category": "Clothes",
"reference_id": "SKU123",
"description": "Description of the product",
"image_url": "https://example.com/",
"product_url": "https://example.com/",
"gender": "Kids",
"color": "white",
"product_material": "cotton",
"size_type": "EU",
"size": "M",
"brand": "Name of the Brand",
"is_refundable": true
}
],
"updated_at": "2023-11-07T05:31:56Z",
"tax_amount": "0.00",
"shipping_amount": "0.00",
"discount_amount": "0.00"
},
"id": "payment id, uuid format",
"created_at": "2023-11-07T05:31:56Z",
"status": "CREATED",
"is_test": true,
"description": "test payload",
"meta": {
"customer": "#customer-id",
"order_id": "#1234"
},
"attachment": {
"body": "{\"flight_reservation_details\": {\"pnr\": \"TR9088999\",\"itinerary\": [...],\"insurance\": [...],\"passengers\": [...],\"affiliate_name\": \"some affiliate\"}}",
"content_type": "application/vnd.tabby.v1+json"
}
},
"status": "created",
"merchant_urls": {
"success": "https://your-store/success",
"cancel": "https://your-store/cancel",
"failure": "https://your-store/failure"
},
"merchant": {
"name": "Your store name"
}
}{
"status": "error",
"errorType": "bad_data",
"error": "could not create payment: only 'AED' is supported, but got 'SAR'"
}{
"status": "error",
"errorType": "not_authorized",
"error": "merchant is null"
}{
"status": "error",
"errorType": "no_permission"
}"404 page not found"{
"status": "error",
"errorType": "internal",
"error": "Internal Server Error"
}Checkout
Create a session
Creates a Checkout session. Creates Session and Payment, returns Pre-Scoring result (status), ids of Payment and Session.
POST
/
api
/
v2
/
checkout
Create a session
curl --request POST \
--url https://api.tabby.ai/api/v2/checkout \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"payment": {
"amount": "100",
"currency": "AED",
"buyer": {
"name": "John Doe",
"email": "jsmith@example.com",
"phone": "500000001",
"dob": "2000-01-20"
},
"shipping_address": {
"city": "Dubai",
"address": "Dubai",
"zip": "1111"
},
"order": {
"reference_id": "1001",
"items": [
{
"title": "Name of the product",
"quantity": 1,
"unit_price": "0.00",
"category": "Clothes",
"reference_id": "SKU123",
"description": "Description of the product",
"discount_amount": "0.00",
"image_url": "https://example.com/",
"product_url": "https://example.com/",
"gender": "Kids",
"color": "white",
"product_material": "cotton",
"size_type": "EU",
"size": "M",
"brand": "Name of the Brand",
"is_refundable": true,
"barcode": "12345678",
"ppn": "MNXT2ZM/A",
"seller": "Name of the Seller"
}
],
"updated_at": "2023-11-07T05:31:56Z",
"tax_amount": "0.00",
"shipping_amount": "0.00",
"discount_amount": "0.00"
},
"buyer_history": {
"registered_since": "2023-11-07T05:31:56Z",
"loyalty_level": 0,
"wishlist_count": 0,
"is_social_networks_connected": true,
"is_phone_number_verified": true,
"is_email_verified": true
},
"order_history": [
{
"purchased_at": "2023-11-07T05:31:56Z",
"amount": "100",
"buyer": {
"name": "John Doe",
"email": "jsmith@example.com",
"phone": "500000001",
"dob": "2000-01-20"
},
"shipping_address": {
"city": "Dubai",
"address": "Dubai",
"zip": "1111"
},
"payment_method": "card",
"items": [
{
"reference_id": "SKU123",
"title": "Name of the product",
"description": "Description of the product",
"quantity": 1,
"unit_price": "0.00",
"discount_amount": "0.00",
"image_url": "https://example.com/",
"product_url": "https://example.com/",
"gender": "Kids",
"category": "Clothes",
"color": "white",
"product_material": "cotton",
"size_type": "EU",
"size": "M",
"brand": "Name of the Brand",
"is_refundable": true,
"barcode": "12345678",
"ppn": "MNXT2ZM/A",
"seller": "Name of the Seller"
}
]
}
],
"description": "test payload",
"meta": {
"customer": "#customer-id",
"order_id": "#1234"
},
"attachment": {
"body": "{\"flight_reservation_details\": {\"pnr\": \"TR9088999\",\"itinerary\": [...],\"insurance\": [...],\"passengers\": [...],\"affiliate_name\": \"some affiliate\"}}",
"content_type": "application/vnd.tabby.v1+json"
}
},
"lang": "en",
"merchant_code": "code provided to you from Tabby side",
"merchant_urls": {
"success": "https://your-store/success",
"cancel": "https://your-store/cancel",
"failure": "https://your-store/failure"
},
"token": null
}
'import requests
url = "https://api.tabby.ai/api/v2/checkout"
payload = {
"payment": {
"amount": "100",
"currency": "AED",
"buyer": {
"name": "John Doe",
"email": "jsmith@example.com",
"phone": "500000001",
"dob": "2000-01-20"
},
"shipping_address": {
"city": "Dubai",
"address": "Dubai",
"zip": "1111"
},
"order": {
"reference_id": "1001",
"items": [
{
"title": "Name of the product",
"quantity": 1,
"unit_price": "0.00",
"category": "Clothes",
"reference_id": "SKU123",
"description": "Description of the product",
"discount_amount": "0.00",
"image_url": "https://example.com/",
"product_url": "https://example.com/",
"gender": "Kids",
"color": "white",
"product_material": "cotton",
"size_type": "EU",
"size": "M",
"brand": "Name of the Brand",
"is_refundable": True,
"barcode": "12345678",
"ppn": "MNXT2ZM/A",
"seller": "Name of the Seller"
}
],
"updated_at": "2023-11-07T05:31:56Z",
"tax_amount": "0.00",
"shipping_amount": "0.00",
"discount_amount": "0.00"
},
"buyer_history": {
"registered_since": "2023-11-07T05:31:56Z",
"loyalty_level": 0,
"wishlist_count": 0,
"is_social_networks_connected": True,
"is_phone_number_verified": True,
"is_email_verified": True
},
"order_history": [
{
"purchased_at": "2023-11-07T05:31:56Z",
"amount": "100",
"buyer": {
"name": "John Doe",
"email": "jsmith@example.com",
"phone": "500000001",
"dob": "2000-01-20"
},
"shipping_address": {
"city": "Dubai",
"address": "Dubai",
"zip": "1111"
},
"payment_method": "card",
"items": [
{
"reference_id": "SKU123",
"title": "Name of the product",
"description": "Description of the product",
"quantity": 1,
"unit_price": "0.00",
"discount_amount": "0.00",
"image_url": "https://example.com/",
"product_url": "https://example.com/",
"gender": "Kids",
"category": "Clothes",
"color": "white",
"product_material": "cotton",
"size_type": "EU",
"size": "M",
"brand": "Name of the Brand",
"is_refundable": True,
"barcode": "12345678",
"ppn": "MNXT2ZM/A",
"seller": "Name of the Seller"
}
]
}
],
"description": "test payload",
"meta": {
"customer": "#customer-id",
"order_id": "#1234"
},
"attachment": {
"body": "{\"flight_reservation_details\": {\"pnr\": \"TR9088999\",\"itinerary\": [...],\"insurance\": [...],\"passengers\": [...],\"affiliate_name\": \"some affiliate\"}}",
"content_type": "application/vnd.tabby.v1+json"
}
},
"lang": "en",
"merchant_code": "code provided to you from Tabby side",
"merchant_urls": {
"success": "https://your-store/success",
"cancel": "https://your-store/cancel",
"failure": "https://your-store/failure"
},
"token": None
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
payment: {
amount: '100',
currency: 'AED',
buyer: {
name: 'John Doe',
email: 'jsmith@example.com',
phone: '500000001',
dob: '2000-01-20'
},
shipping_address: {city: 'Dubai', address: 'Dubai', zip: '1111'},
order: {
reference_id: '1001',
items: [
{
title: 'Name of the product',
quantity: 1,
unit_price: '0.00',
category: 'Clothes',
reference_id: 'SKU123',
description: 'Description of the product',
discount_amount: '0.00',
image_url: 'https://example.com/',
product_url: 'https://example.com/',
gender: 'Kids',
color: 'white',
product_material: 'cotton',
size_type: 'EU',
size: 'M',
brand: 'Name of the Brand',
is_refundable: true,
barcode: '12345678',
ppn: 'MNXT2ZM/A',
seller: 'Name of the Seller'
}
],
updated_at: '2023-11-07T05:31:56Z',
tax_amount: '0.00',
shipping_amount: '0.00',
discount_amount: '0.00'
},
buyer_history: {
registered_since: '2023-11-07T05:31:56Z',
loyalty_level: 0,
wishlist_count: 0,
is_social_networks_connected: true,
is_phone_number_verified: true,
is_email_verified: true
},
order_history: [
{
purchased_at: '2023-11-07T05:31:56Z',
amount: '100',
buyer: {
name: 'John Doe',
email: 'jsmith@example.com',
phone: '500000001',
dob: '2000-01-20'
},
shipping_address: {city: 'Dubai', address: 'Dubai', zip: '1111'},
payment_method: 'card',
items: [
{
reference_id: 'SKU123',
title: 'Name of the product',
description: 'Description of the product',
quantity: 1,
unit_price: '0.00',
discount_amount: '0.00',
image_url: 'https://example.com/',
product_url: 'https://example.com/',
gender: 'Kids',
category: 'Clothes',
color: 'white',
product_material: 'cotton',
size_type: 'EU',
size: 'M',
brand: 'Name of the Brand',
is_refundable: true,
barcode: '12345678',
ppn: 'MNXT2ZM/A',
seller: 'Name of the Seller'
}
]
}
],
description: 'test payload',
meta: {customer: '#customer-id', order_id: '#1234'},
attachment: {
body: JSON.stringify('{"flight_reservation_details": {"pnr": "TR9088999","itinerary": [...],"insurance": [...],"passengers": [...],"affiliate_name": "some affiliate"}}'),
content_type: 'application/vnd.tabby.v1+json'
}
},
lang: 'en',
merchant_code: 'code provided to you from Tabby side',
merchant_urls: {
success: 'https://your-store/success',
cancel: 'https://your-store/cancel',
failure: 'https://your-store/failure'
},
token: null
})
};
fetch('https://api.tabby.ai/api/v2/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 => "https://api.tabby.ai/api/v2/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([
'payment' => [
'amount' => '100',
'currency' => 'AED',
'buyer' => [
'name' => 'John Doe',
'email' => 'jsmith@example.com',
'phone' => '500000001',
'dob' => '2000-01-20'
],
'shipping_address' => [
'city' => 'Dubai',
'address' => 'Dubai',
'zip' => '1111'
],
'order' => [
'reference_id' => '1001',
'items' => [
[
'title' => 'Name of the product',
'quantity' => 1,
'unit_price' => '0.00',
'category' => 'Clothes',
'reference_id' => 'SKU123',
'description' => 'Description of the product',
'discount_amount' => '0.00',
'image_url' => 'https://example.com/',
'product_url' => 'https://example.com/',
'gender' => 'Kids',
'color' => 'white',
'product_material' => 'cotton',
'size_type' => 'EU',
'size' => 'M',
'brand' => 'Name of the Brand',
'is_refundable' => true,
'barcode' => '12345678',
'ppn' => 'MNXT2ZM/A',
'seller' => 'Name of the Seller'
]
],
'updated_at' => '2023-11-07T05:31:56Z',
'tax_amount' => '0.00',
'shipping_amount' => '0.00',
'discount_amount' => '0.00'
],
'buyer_history' => [
'registered_since' => '2023-11-07T05:31:56Z',
'loyalty_level' => 0,
'wishlist_count' => 0,
'is_social_networks_connected' => true,
'is_phone_number_verified' => true,
'is_email_verified' => true
],
'order_history' => [
[
'purchased_at' => '2023-11-07T05:31:56Z',
'amount' => '100',
'buyer' => [
'name' => 'John Doe',
'email' => 'jsmith@example.com',
'phone' => '500000001',
'dob' => '2000-01-20'
],
'shipping_address' => [
'city' => 'Dubai',
'address' => 'Dubai',
'zip' => '1111'
],
'payment_method' => 'card',
'items' => [
[
'reference_id' => 'SKU123',
'title' => 'Name of the product',
'description' => 'Description of the product',
'quantity' => 1,
'unit_price' => '0.00',
'discount_amount' => '0.00',
'image_url' => 'https://example.com/',
'product_url' => 'https://example.com/',
'gender' => 'Kids',
'category' => 'Clothes',
'color' => 'white',
'product_material' => 'cotton',
'size_type' => 'EU',
'size' => 'M',
'brand' => 'Name of the Brand',
'is_refundable' => true,
'barcode' => '12345678',
'ppn' => 'MNXT2ZM/A',
'seller' => 'Name of the Seller'
]
]
]
],
'description' => 'test payload',
'meta' => [
'customer' => '#customer-id',
'order_id' => '#1234'
],
'attachment' => [
'body' => '{"flight_reservation_details": {"pnr": "TR9088999","itinerary": [...],"insurance": [...],"passengers": [...],"affiliate_name": "some affiliate"}}',
'content_type' => 'application/vnd.tabby.v1+json'
]
],
'lang' => 'en',
'merchant_code' => 'code provided to you from Tabby side',
'merchant_urls' => [
'success' => 'https://your-store/success',
'cancel' => 'https://your-store/cancel',
'failure' => 'https://your-store/failure'
],
'token' => null
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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 := "https://api.tabby.ai/api/v2/checkout"
payload := strings.NewReader("{\n \"payment\": {\n \"amount\": \"100\",\n \"currency\": \"AED\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"order\": {\n \"reference_id\": \"1001\",\n \"items\": [\n {\n \"title\": \"Name of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"category\": \"Clothes\",\n \"reference_id\": \"SKU123\",\n \"description\": \"Description of the product\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ],\n \"updated_at\": \"2023-11-07T05:31:56Z\",\n \"tax_amount\": \"0.00\",\n \"shipping_amount\": \"0.00\",\n \"discount_amount\": \"0.00\"\n },\n \"buyer_history\": {\n \"registered_since\": \"2023-11-07T05:31:56Z\",\n \"loyalty_level\": 0,\n \"wishlist_count\": 0,\n \"is_social_networks_connected\": true,\n \"is_phone_number_verified\": true,\n \"is_email_verified\": true\n },\n \"order_history\": [\n {\n \"purchased_at\": \"2023-11-07T05:31:56Z\",\n \"amount\": \"100\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"payment_method\": \"card\",\n \"items\": [\n {\n \"reference_id\": \"SKU123\",\n \"title\": \"Name of the product\",\n \"description\": \"Description of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"category\": \"Clothes\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ]\n }\n ],\n \"description\": \"test payload\",\n \"meta\": {\n \"customer\": \"#customer-id\",\n \"order_id\": \"#1234\"\n },\n \"attachment\": {\n \"body\": \"{\\\"flight_reservation_details\\\": {\\\"pnr\\\": \\\"TR9088999\\\",\\\"itinerary\\\": [...],\\\"insurance\\\": [...],\\\"passengers\\\": [...],\\\"affiliate_name\\\": \\\"some affiliate\\\"}}\",\n \"content_type\": \"application/vnd.tabby.v1+json\"\n }\n },\n \"lang\": \"en\",\n \"merchant_code\": \"code provided to you from Tabby side\",\n \"merchant_urls\": {\n \"success\": \"https://your-store/success\",\n \"cancel\": \"https://your-store/cancel\",\n \"failure\": \"https://your-store/failure\"\n },\n \"token\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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("https://api.tabby.ai/api/v2/checkout")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payment\": {\n \"amount\": \"100\",\n \"currency\": \"AED\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"order\": {\n \"reference_id\": \"1001\",\n \"items\": [\n {\n \"title\": \"Name of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"category\": \"Clothes\",\n \"reference_id\": \"SKU123\",\n \"description\": \"Description of the product\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ],\n \"updated_at\": \"2023-11-07T05:31:56Z\",\n \"tax_amount\": \"0.00\",\n \"shipping_amount\": \"0.00\",\n \"discount_amount\": \"0.00\"\n },\n \"buyer_history\": {\n \"registered_since\": \"2023-11-07T05:31:56Z\",\n \"loyalty_level\": 0,\n \"wishlist_count\": 0,\n \"is_social_networks_connected\": true,\n \"is_phone_number_verified\": true,\n \"is_email_verified\": true\n },\n \"order_history\": [\n {\n \"purchased_at\": \"2023-11-07T05:31:56Z\",\n \"amount\": \"100\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"payment_method\": \"card\",\n \"items\": [\n {\n \"reference_id\": \"SKU123\",\n \"title\": \"Name of the product\",\n \"description\": \"Description of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"category\": \"Clothes\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ]\n }\n ],\n \"description\": \"test payload\",\n \"meta\": {\n \"customer\": \"#customer-id\",\n \"order_id\": \"#1234\"\n },\n \"attachment\": {\n \"body\": \"{\\\"flight_reservation_details\\\": {\\\"pnr\\\": \\\"TR9088999\\\",\\\"itinerary\\\": [...],\\\"insurance\\\": [...],\\\"passengers\\\": [...],\\\"affiliate_name\\\": \\\"some affiliate\\\"}}\",\n \"content_type\": \"application/vnd.tabby.v1+json\"\n }\n },\n \"lang\": \"en\",\n \"merchant_code\": \"code provided to you from Tabby side\",\n \"merchant_urls\": {\n \"success\": \"https://your-store/success\",\n \"cancel\": \"https://your-store/cancel\",\n \"failure\": \"https://your-store/failure\"\n },\n \"token\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tabby.ai/api/v2/checkout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payment\": {\n \"amount\": \"100\",\n \"currency\": \"AED\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"order\": {\n \"reference_id\": \"1001\",\n \"items\": [\n {\n \"title\": \"Name of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"category\": \"Clothes\",\n \"reference_id\": \"SKU123\",\n \"description\": \"Description of the product\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ],\n \"updated_at\": \"2023-11-07T05:31:56Z\",\n \"tax_amount\": \"0.00\",\n \"shipping_amount\": \"0.00\",\n \"discount_amount\": \"0.00\"\n },\n \"buyer_history\": {\n \"registered_since\": \"2023-11-07T05:31:56Z\",\n \"loyalty_level\": 0,\n \"wishlist_count\": 0,\n \"is_social_networks_connected\": true,\n \"is_phone_number_verified\": true,\n \"is_email_verified\": true\n },\n \"order_history\": [\n {\n \"purchased_at\": \"2023-11-07T05:31:56Z\",\n \"amount\": \"100\",\n \"buyer\": {\n \"name\": \"John Doe\",\n \"email\": \"jsmith@example.com\",\n \"phone\": \"500000001\",\n \"dob\": \"2000-01-20\"\n },\n \"shipping_address\": {\n \"city\": \"Dubai\",\n \"address\": \"Dubai\",\n \"zip\": \"1111\"\n },\n \"payment_method\": \"card\",\n \"items\": [\n {\n \"reference_id\": \"SKU123\",\n \"title\": \"Name of the product\",\n \"description\": \"Description of the product\",\n \"quantity\": 1,\n \"unit_price\": \"0.00\",\n \"discount_amount\": \"0.00\",\n \"image_url\": \"https://example.com/\",\n \"product_url\": \"https://example.com/\",\n \"gender\": \"Kids\",\n \"category\": \"Clothes\",\n \"color\": \"white\",\n \"product_material\": \"cotton\",\n \"size_type\": \"EU\",\n \"size\": \"M\",\n \"brand\": \"Name of the Brand\",\n \"is_refundable\": true,\n \"barcode\": \"12345678\",\n \"ppn\": \"MNXT2ZM/A\",\n \"seller\": \"Name of the Seller\"\n }\n ]\n }\n ],\n \"description\": \"test payload\",\n \"meta\": {\n \"customer\": \"#customer-id\",\n \"order_id\": \"#1234\"\n },\n \"attachment\": {\n \"body\": \"{\\\"flight_reservation_details\\\": {\\\"pnr\\\": \\\"TR9088999\\\",\\\"itinerary\\\": [...],\\\"insurance\\\": [...],\\\"passengers\\\": [...],\\\"affiliate_name\\\": \\\"some affiliate\\\"}}\",\n \"content_type\": \"application/vnd.tabby.v1+json\"\n }\n },\n \"lang\": \"en\",\n \"merchant_code\": \"code provided to you from Tabby side\",\n \"merchant_urls\": {\n \"success\": \"https://your-store/success\",\n \"cancel\": \"https://your-store/cancel\",\n \"failure\": \"https://your-store/failure\"\n },\n \"token\": null\n}"
response = http.request(request)
puts response.read_body{
"id": "session id, uuid format",
"configuration": {
"available_products": {
"installments": [
{
"web_url": "https://checkout.tabby.ai/",
"qr_code": "https://api.tabby.ai/api/v2/checkout/{id}/hpp_link_qr"
}
]
},
"products": {
"installments": {
"type": "installments",
"is_available": true,
"rejection_reason": null
}
}
},
"token": null,
"payment": {
"amount": "100",
"currency": "AED",
"order": {
"reference_id": "1001",
"items": [
{
"title": "Name of the product",
"quantity": 1,
"unit_price": "0.00",
"category": "Clothes",
"reference_id": "SKU123",
"description": "Description of the product",
"image_url": "https://example.com/",
"product_url": "https://example.com/",
"gender": "Kids",
"color": "white",
"product_material": "cotton",
"size_type": "EU",
"size": "M",
"brand": "Name of the Brand",
"is_refundable": true
}
],
"updated_at": "2023-11-07T05:31:56Z",
"tax_amount": "0.00",
"shipping_amount": "0.00",
"discount_amount": "0.00"
},
"id": "payment id, uuid format",
"created_at": "2023-11-07T05:31:56Z",
"status": "CREATED",
"is_test": true,
"description": "test payload",
"meta": {
"customer": "#customer-id",
"order_id": "#1234"
},
"attachment": {
"body": "{\"flight_reservation_details\": {\"pnr\": \"TR9088999\",\"itinerary\": [...],\"insurance\": [...],\"passengers\": [...],\"affiliate_name\": \"some affiliate\"}}",
"content_type": "application/vnd.tabby.v1+json"
}
},
"status": "created",
"merchant_urls": {
"success": "https://your-store/success",
"cancel": "https://your-store/cancel",
"failure": "https://your-store/failure"
},
"merchant": {
"name": "Your store name"
}
}{
"status": "error",
"errorType": "bad_data",
"error": "could not create payment: only 'AED' is supported, but got 'SAR'"
}{
"status": "error",
"errorType": "not_authorized",
"error": "merchant is null"
}{
"status": "error",
"errorType": "no_permission"
}"404 page not found"{
"status": "error",
"errorType": "internal",
"error": "Internal Server Error"
}Authorizations
Body
application/json
Response
Success. Checkout session object is returned.
Status of the current session. Used at the pre-scoring and session creation steps.
createdis returned when the request is approved and the customer is eligible to use Tabbyrejectedmeans that there are no available products for a customerexpiredandapproved- used for specific type of integration, kindly ignore them if not communicated directly
Available options:
created, rejected, expired, approved Example:
"created"
Was this page helpful?