Send train tickets

To send a train ticket, you must first retrieve the transactionID of the user for whom you want to generate a ticket. Provide the transactionId for every transaction.

After getting the user transactionID, pass the train ticket template parameters in the message payload.

To send a flight ticket to a user, make the following POST request to the API:

POST https://nbupayments.googleapis.com/v1/merchantCommunications:send
Content-type: application/json

{
  "merchantInfo": {
    "googleMerchantId": "Google assigned merchant ID"
  },
  "recipients": [
    {
      "vendorPaymentTransactionId": "35 digit UPI transaction ID"
    }
  ],
  "messagePayload": {
    "merchantMessageId": "Merchant created unique ID for every message",
    "components": [
      {
        "template": {
          "templateType": "TRAIN_TICKET",
          "templateParameters": {
            "merchantTicketId": "Merchant assigned ticket ID",
            "travelLegs": [
              {
                "trainInfo": {
                  "trainNumber": "Train number",
                  "trainName": "Train name"
                },
                "pnrNumber": "PNR for this train ticket",
                "departureStation": {
                  "cityName": "Name of departure city",
                  "stationName": "Name of departure train station",
                  "stationCode": "Unique code for departure station"
                },
                "departureTime": "Departure time in RFC 3339 format(2017-02-15T10:50:30Z)",
                "arrivalStation": {
                  "cityName": "Name of arrival city",
                  "stationName": "Name of arrival train station",
                  "stationCode": "Unique code for arrival station"
                },
                "arrivalTime": "Arrival time in RFC 3339 format (2017-02-15T10:50:30Z)",
                "passengers": [
                  {
                    "name": "Passenger's name",
                    "ageYears": 25,
                    "seatType": "Train seat type (SL / 3AC)",
                    "seatNumber": "Train seat number"
                  },
                  {
                    "name": "Passenger's name",
                    "ageYears": 25,
                    "seatType": "Train seat type (SL / 3AC)",
                    "seatNumber": "Train seat number"
                  }
                ]
              }
            ]
          }
        }
      }
    ]
  }
}

Parameters

User and merchant

The following data parameters for the user object must be passed in the API request:

Parameters Type of value Description Required/Optional
googleMerchantID String ID provided by Google for a business. Required
googleTransactionId String ID provided by Google for every transaction using Google Pay. Required

Template type

You must pass the value for templateType object as Train_TICKET. Pass the merchant created unique ID for every message in the merchantTicketId.

Passenger and seat

The following are the key-value pairs to pass into the passengers array:

Parameters Type of value Description Required/Optional
name String Name of the passenger. Required
age Number Age of the passenger. Optional
seatType String Type of seat - Sleeper/AC/RAC/berth. Required
seatNumber String Berth number allocated to the passenger. Required

If more than one passenger is traveling, define the key-value pairs such as name, ageYears, seatType,and seatNumber for each passenger in the passengers array as shown in the sample request.

Train info object

The following are the key-value pairs to pass into the trainInfo object:

Parameters Type of value Description Required/Optional
trainName String Name of the train. Required
trainNumber String The train number. Required

PNR number

You must pass the PNR number generated for each bus ticket in the pnrNumber key.

If the travel booking has connecting buses, define key-value pairs trainName, trainNumber,and pnrNumber for each bus in the travelLegs array as shown in the sample request.

Departure station object

The following are the key-value pairs to pass into the departureStation object:

Parameters Type of value Description Required/Optional
cityName String Name of the city from where the train will depart. Required
stationName String Name of the station from where the bus will depart. Required
stationCode String Code of the station from where the train will depart. Optional
departureTime String Train departure time. Required

Arrival station object

The following are the key-value pairs to pass in the arrivalstation object.

Parameters Type of value Description Required/Optional
cityName String Name of the city where the train will arrive. Required
stationName String Name of the station where the train will arrive. Required
stationCode String Code of the station where the train will arrive. Optional
arrivalTime String Train arrival time. Required

Response

{
  "sendMessageResults": [
    {
      "recipient": {
        "vendorPaymentTransactionId": "35 digit UPI transaction ID"
      },
      "status": {
        "code": 200,
        "message": "Success response message"
      }
    }
  ]
}

The response contains the recipient googleTransactionId, API response status, and the relevant message.