home > support > API > record details of a failed payment

Record a failed payment

Record details of a failed payment attempt, sends any failed payment email for the channel


Notes

For use by Tour Operators only (not Marketplace Partners). Not for use on temporary bookings (if inputting a booking via the API it must be committed before logging payments).

REST info

Endpoint/c/booking/payment/fail
FormatsXML
ExampleURL: /c/booking/payment/fail.xml
 
POST data:
<?xml version="1.0"?>
<payment>
  <booking_id>12345</booking_id>
  <audit_trail_note>Error message here</audit_trail_note>
</payment>
VerbPOST

Code samples

PHP examples use the PHP Client Library with SimpleXML

Description

object log_failed_payment ( SimpleXMLElement $payment, int $channel )

Parameters

$payment
SimpleXMLElement containing the booking ID and audit trail message
$channel
Channel ID as per TourCMS API settings page

Example

// Set your Channel ID, as per the TourCMS API settings page
$channel = 3;

// Create a new SimpleXMLElement to hold the failed payment log
$payment = new SimpleXMLElement('<payment />');
      
// Must set the Booking ID on the XML, so TourCMS knows which to update
$payment->addChild('booking_id', '194');

// Optionally add a message
$payment->addChild('audit_trail_note', 'Error message here');
 
// Call TourCMS API, storing the payment
$result = $tourcms->create_payment($payment, $channel);

if($result->status == "OK")
	print "Booking failure recorded";
else
	print "Unable to update booking";
Booking failure recorded

C# examples use the .Net Client Library

Overload list

XmlDocument LogFailedPayment ( XmlDocument paymentData, int channelId )


Parameters

paymentData
XmlDocument containing the information to log
channelId
Channel ID as per TourCMS API settings page

Example

// Set the ID for the channel the booking is made with
int channelID = 3;

// Create an XMLDocument to hold the payment log details
XmlDocument paymentData = new XmlDocument();

// Create the XML Declaration, append it to XML document
XmlDeclaration dec = paymentData.CreateXmlDeclaration("1.0", null, null);
paymentData.AppendChild(dec);

// Create the root element, append it to the XML document
XmlElement root = paymentData.CreateElement("payment");
paymentData.AppendChild(root);

// Now add the various elements to the payment

// Must set the Booking ID so TourCMS knows which booking to the log on to
XmlElement bookingId = paymentData.CreateElement("booking_id");
bookingId.InnerText = "12345";
root.AppendChild(bookingId);

// Optionally add a message to the audit trail
// Useful for debugging!
XmlElement auditNote = paymentData.CreateElement("audit_trail_note");
auditNote.InnerText = "Error message here";
root.AppendChild(auditNote);

// Send the data to the TourCMS API, recording the failure
XmlDocument doc = myTourCMS.CreatePayment(paymentData, channelId);

// Check the status
// Will be "OK" if the log was stored successfully
string status = doc.SelectSingleNode("//error").InnerText;

Console.WriteLine(status);
OK

VB examples use the .Net Client Library

Overload list

XmlDocument LogFailedPayment ( XmlDocument paymentData, Integer channelId )


Parameters

paymentData
XmlDocument containing the information to log
channelId
Channel ID as per TourCMS API settings page

Example

' Set the ID for the channel the booking is made with
Dim channelID As Integer = 3

' Create an XMLDocument to hold the payment log details
Dim paymentData As XmlDocument = new XmlDocument()

' Create the XML Declaration, append it to XML document
Dim dec As XmlDeclaration = paymentData.CreateXmlDeclaration("1.0", null, null)
paymentData.AppendChild(dec)

' Create the root element, append it to the XML document
Dim root As XmlElement = paymentData.CreateElement("payment")
paymentData.AppendChild(root)

' Optionally add note for the audit trail
' Useful for debugging!
Dim auditNote As XmlElement = paymentData.CreateElement("audit_trail_note")
auditNote.InnerText = "Error message here"
root.AppendChild(auditNote)

' Send the data to the TourCMS API, recording failure
Dim doc As XmlDocument = myTourCMS.CreatePayment(paymentData, channelId)

' Check the status
' Will be "OK" if the log was stored successfully
Dim status As String = doc.SelectSingleNode("//error").InnerText

Console.WriteLine(status)
OK

Querystring parameters

There are no querystring parameters supported by this method.

Post fields

The following fields can be posted as XML when calling the API.

Post fields
XML NodeNotes
payment

The root XML element, can contain any of the following child nodes.

XML NodeNotes
booking_idTourCMS ID number for the Booking. This must be provided.
audit_trail_noteFree text note to add to the audit trail on the booking.

Response fields

Response fields
XML NodeNotes
request Confirmation of the request that you sent
error Any error message returned, if there is no error this will just contain the text OK
booking

If the booking is found the booking node will contain the following child nodes.

XML NodeNotes
booking_idBooking ID

More information