Get Booking Payload
Introduction
The Get Booking Payload API allows you to get the booking payload for a particular ticket and slot. This API is useful when you want to generate a form for attendees to fill in their details before booking a ticket. The booking payload includes the required fields for the form, such as first name, last name, email, phone number, and custom fields.
Generate Booking Payload
To get the booking payload, users need to make an HTTP POST request to the specified endpoint with the required parameters.
Endpoint
https://api.paydexp.com/v1/booking/payload
Authorization
Users need to include basic authentication credentials in the request headers.
Request Body (Token Object)
The request body should include the necessary parameters for the request, such as the ticket_id, slot_id, and quantity.
{
"ticket_id": 118,
"slot_id": 49,
"quantity": 2
}
Code Examples
Below are code examples in different programming languages demonstrating how to get booking payload using HTTP POST requests.
- Curl
- Go
- Nodejs
- Python
- PHP
curl --location 'https://api.paydexp.com/api/v1/booking/payload' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••'
--data '{
"ticket_id": 118,
"slot_id": 49,
"quantity": 2
}'
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.paydexp.com/api/v1/booking/payload"
method := "POST"
payload := strings.NewReader(`{`+"
"+`
"ticket_id": 118,`+"
"+`
"slot_id": 49,`+"
"+`
"quantity": 2`+"
"+`
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "••••••")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
const axios = require('axios');
let data = JSON.stringify({
"ticket_id": 118,
"slot_id": 49,
"quantity": 2
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.paydexp.com/api/v1/booking/payload',
headers: {
'Content-Type': 'application/json',
'Authorization': '••••••'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import requests
import json
url = "https://api.paydexp.com/api/v1/booking/payload"
payload = json.dumps({
"ticket_id": 118,
"slot_id": 49,
"quantity": 2
})
headers = {
'Content-Type': 'application/json',
'Authorization': '••••••'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api.paydexp.com/api/v1/booking/payload');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'application/json',
'Authorization' => '••••••'
));
$request->setBody('{
\n "ticket_id": 118,
\n "slot_id": 49,
\n "quantity": 2
\n}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Example of a successful response
{
"success": true,
"payload": [
{
"name": "attendee[0]first_name",
"label": "First Name",
"type": "text",
"required": true,
"options": []
},
{
"name": "attendee[0]last_name",
"label": "Last Name",
"type": "text",
"required": true,
"options": []
},
{
"name": "attendee[0]email",
"label": "Email",
"type": "email",
"required": true,
"options": []
},
{
"name": "attendee[0]phone",
"label": "Phone",
"type": "text",
"required": true,
"options": []
},
{
"name": "attendee[0]fields[66]",
"label": "Favourite Song",
"type": "select",
"required": 0,
"options": [
"Danger",
" Hatari"
]
},
{
"name": "attendee[1]first_name",
"label": "First Name",
"type": "text",
"required": true,
"options": []
},
{
"name": "attendee[1]last_name",
"label": "Last Name",
"type": "text",
"required": true,
"options": []
},
{
"name": "attendee[1]email",
"label": "Email",
"type": "email",
"required": true,
"options": []
},
{
"name": "attendee[1]phone",
"label": "Phone",
"type": "text",
"required": true,
"options": []
},
{
"name": "attendee[1]fields[66]",
"label": "Favourite Song",
"type": "select",
"required": 0,
"options": [
"Danger",
" Hatari"
]
}
],
"expected_payload": {
"callback_url": "https://example.com/callback",
"ticket_id": 118,
"slot_id": 49,
"quantity": 2,
"fields": {
"attendee[0]first_name": "John",
"attendee[0]last_name": "Doe",
"attendee[0]email": "johndoe@example.com",
"attendee[0]phone": "1234567890",
"attendee[0]fields[66]": "Danger",
"attendee[1]first_name": "John",
"attendee[1]last_name": "Doe",
"attendee[1]email": "johndoe@example.com",
"attendee[1]phone": "1234567890",
"attendee[1]fields[66]": "Danger"
}
},
"message": "Payload generated successfully. Fill in the required fields and submit the form."
}
Conclusion
This API allows users to get the booking payload for a particular ticket and slot. Users can use the booking payload to generate a form for attendees to fill in their details before booking a ticket. This API provides a seamless way to collect attendee information and process bookings.