home > support > API > Marketplace API > record details of a new payment
Store details of a new payment on a booking sales ledger. Allows Tour Operators to integrate their own payment methods and update the TourCMS sales ledger automatically.
For use by Tour Operator accounts only (not for use by Marketplace Partners). It can be used on temporary and commited bookings (it will appear with the rest of the payments once the bookings is commited).
Endpoint | /c/booking/payment/new |
Formats | XML |
Example | URL: /c/booking/payment/new.xml POST data:
|
Verb | POST |
PHP examples use the PHP Client Library with SimpleXML
object create_payment ( SimpleXMLElement $payment_data, int $channel )
// Set your Channel ID, as per the TourCMS API settings page
$channel = 3;
// Create a new SimpleXMLElement to hold the payment details
$payment = new SimpleXMLElement('<payment />');
// Must set the Booking ID on the XML, so TourCMS knows which to update
$payment->addChild('booking_id', '194');
// Must set the value of the payment
$payment->addChild('payment_value', '20');
// Optionally set the currency
$payment->addChild('payment_currency', 'GBP');
// Optionally set the payment type
$payment->addChild('payment_type', 'Credit Card');
// Optionally add a reference
$payment->addChild('payment_reference', '12345');
// Call TourCMS API, storing the payment
$result = $tourcms->create_payment($payment, $channel);
if($result->error == "OK")
print "Thanks, payment added";
else
print "Sorry, unable to store the payment at this time";
Thanks, payment added
C# examples use the .Net Client Library
XmlDocument CreatePayment ( 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 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 add payment onto
XmlElement bookingId = paymentData.CreateElement("booking_id");
bookingId.InnerText = "12345";
root.AppendChild(bookingId);
// _MUST_ set the value of the payment (negative if it's a refund)
XmlElement paymentValue = paymentData.CreateElement("payment_value");
paymentValue.InnerText = "100";
root.AppendChild(paymentValue);
// Optionally set the currency
XmlElement paymentCurrency = paymentData.CreateElement("payment_value");
paymentCurrency.InnerText = "GBP";
root.AppendChild(paymentCurrency);
// Optionally set the payment type
XmlElement paymentType = paymentData.CreateElement("payment_type");
paymentType.InnerText = "Credit card";
root.AppendChild(paymentType);
// Optionally add a reference
XmlElement paymentReference = paymentData.CreateElement("payment_reference");
paymentReference.InnerText = "6789";
root.AppendChild(paymentReference);
// Send the data to the TourCMS API, recording the payment/refund
XmlDocument doc = myTourCMS.CreatePayment(paymentData, channelId);
// Check the status
// Will be "OK" if the payment was stored successfully
string status = doc.SelectSingleNode("//error").InnerText;
Console.WriteLine(status);
OK
VB examples use the .Net Client Library
XmlDocument CreatePayment ( 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 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)
' Now add the various elements to the payment
' Must set the Booking ID so TourCMS knows which booking to add payment onto
Dim bookingId As XmlElement = paymentData.CreateElement("booking_id")
bookingId.InnerText = "12345"
root.AppendChild(bookingId)
' _MUST_ set the value of the payment (negative if it's a refund)
Dim paymentValue As XmlElement = paymentData.CreateElement("payment_value")
paymentValue.InnerText = "100"
root.AppendChild(paymentValue)
' Optionally set the currency
Dim paymentCurrency As XmlElement = paymentData.CreateElement("payment_value")
paymentCurrency.InnerText = "GBP"
root.AppendChild(paymentCurrency)
' Optionally set the payment type
Dim paymentType As XmlElement = paymentData.CreateElement("payment_type")
paymentType.InnerText = "Credit card"
root.AppendChild(paymentType)
' Optionally add a reference
Dim paymentReference As XmlElement = paymentData.CreateElement("payment_reference")
paymentReference.InnerText = "6789"
root.AppendChild(paymentReference)
' Send the data to the TourCMS API, recording the payment/refund
Dim doc As XmlDocument = myTourCMS.CreatePayment(paymentData, channelId)
' Check the status
' Will be "OK" if the payment was stored successfully
Dim status As String = doc.SelectSingleNode("//error").InnerText
Console.WriteLine(status)
OK
NodeJS examples use the NodeJS Wrapper
// Record a payment on the booking of value 10 (in the Channel currency)
TourCMS.createPayment({
channelId: 3930,
payment: {
booking_id: "8400",
payment_value: "10",
},
callback: function(response, status) {
console.log(response.error);
}
});
OK
Looking for sample code in a different language? TourCMS and community provided API libraries
Enter your TourCMS API credentials below to call the Create Payment endpoint.
Take care, submitting this form will modify live data!
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.
|