Make Booking
Introduction
The make booking API allows users to create a booking for an event by providing the necessary details such as ticket ID, slot ID, quantity, and attendee information as per the expected_payload parameter on the response from the Get Booking Payload API. This API generates a payment URL that users can use to complete the booking process.
Making a Booking
To make the booking, users need to make an HTTP POST request to the specified endpoint with the required parameters.
Endpoint
https://api.paydexp.com/v1/booking/make
Authorization
Users need to include basic authentication credentials in the request headers.
Where base64_encoded_username_password is a Base64-encoded string of your API username and password joined by a colon.
Request Body (Token Object)
The request body should include the necessary parameters for the request, such as the ticket_id, slot_id, and quantity.
{
"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"
}
}
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/make' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data-raw '{
"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"
}
}'
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.paydexp.com/api/v1/booking/make"
method := "POST"
payload := strings.NewReader(`{`+"
"+`
"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"`+"
"+`
}`+"
"+`
}`)
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({
"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"
},
"coupon_code": "DISCOUNT20"
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.paydexp.com/api/v1/booking/make',
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/make"
payload = json.dumps({
"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"
},
"coupon_code": "DISCOUNT20"
})
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/make');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'application/json',
'Authorization' => '••••••'
));
$request->setBody('{
\n "callback_url": "https://example.com/callback",
\n "ticket_id": 118,
\n "slot_id": 49,
\n "quantity": 2,
\n "fields": {
\n "attendee[0]first_name": "John",
\n "attendee[0]last_name": "Doe",
\n "attendee[0]email": "johndoe@example.com",
\n "attendee[0]phone": "1234567890",
\n "attendee[0]fields[66]": "Danger",
\n "attendee[1]first_name": "John",
\n "attendee[1]last_name": "Doe",
\n "attendee[1]email": "johndoe@example.com",
\n "attendee[1]phone": "1234567890",
\n "attendee[1]fields[66]": "Danger"
\n }
"coupon_code": "DISCOUNT20"
\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,
"payment_url": "https://pay.vabu.app/checkout/abc123xyz",
"message": "Booking created successfully. Make Payment via the payment URL provided to complete the booking."
}
For free events or fully discounted bookings:
{
"success": true,
"payment_url": "https://vabu.app/invoice/PE-ABCD-123XYZ",
"message": "Booking made successfully. No payment required. Redirecting to your ticket."
}