PHP examples use the PHP Client Library with SimpleXML
Description
object create_payment ( SimpleXMLElement $payment_data, int $channel )
Parameters
$payment
SimpleXMLElement containing all of the payment information
$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 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->status == "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
Overload list
XmlDocument CreatePayment ( XmlDocument payemntData, int channelId )
Parameters
paymentData
XmlDocument containing all of the payment information
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 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
Overload list
XmlDocument CreatePayment ( XmlDocument payemntData, Integer channelId )
Parameters
paymentData
XmlDocument containing all of the payment information
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 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