home > support > API > record details of a failed payment
Record details of a failed payment attempt, sends any failed payment email for the channel
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).
Endpoint | /c/booking/payment/fail |
Formats | XML |
Example | URL: /c/booking/payment/fail.xml POST data:
|
Verb | POST |
PHP examples use the PHP Client Library with SimpleXML
object log_failed_payment ( SimpleXMLElement $payment, int $channel )
// 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
XmlDocument LogFailedPayment ( XmlDocument paymentData, int channelId )
// 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
XmlDocument LogFailedPayment ( XmlDocument paymentData, Integer channelId )
' 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
There are no querystring parameters supported by this method.
The following fields can be posted as XML when calling the API.
XML Node | Notes | ||||||
---|---|---|---|---|---|---|---|
payment |
The root XML element, can contain any of the following child nodes.
|
XML Node | Notes |
---|---|
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.
|