TourCMS, a leading online booking and channel management solution is operated by Palisis.

Contact Info

Palisis AG
Florastrasse 18A
8610 Uster
support@palisis.com
+41 44 533 40 40

Follow Us

home > support > API > Marketplace API > Create new Spreedly Payment

Create a Spreedly payment

Charge a credit card vaulted with Spreedly, storing details of the transaction on the booking and on success automatically committing the booking (if not already committed)


Notes

For those using Spreedly as a gateway this replaces the generic Payment Create API method and possibly also the Booking Commit method. Allows charging of a card using a payment token obtained via one of Spreedly's card collection methods (environment keys available via the Show Channel API).

For environments where AVS is likely to be enabled (i.e. most online transactions) do ensure you are providing Spreedly with the clients billing address at the poinft of adding the payment method. In the case of the JSONP/CORS methods you can check this has been stored successfully by viewing the response from Spreedly.

Learn more about TourCMS Spreedly integration

REST info

Endpoint/c/booking/payment/spreedly/new
FormatsXML
ExampleURL: /c/booking/payment/spreedly/new.xml
 
POST data:
<?xml version="1.0"?>
<payment>
  <spreedly_payment_method>AAABBBCCC</spreedly_payment_method>
  <booking_id>12345</booking_id>
  <payment_value>100</payment_value>
  <payment_currency>EUR</payment_currency>
</payment>
VerbPOST

Code samples

PHP examples use the PHP Client Library with SimpleXML

Description

object spreedly_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 />');

// Set the Spreedly payment method token to use
$payment->addChild('spreedly_payment_method', 'AAABBBCCCDDDDEEE');

// 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');

// Must set the currency
$payment->addChild('payment_currency', 'GBP');

// (optional - only using Trust My Travel) Send cardholder details
// instead of using lead customer details
$customer = $payment->addChild('cardholder_customer');
$customer->addChild('firstname', 'Cardholder name');
$customer->addChild('surname', 'Cardholder surname');
$customer->addChild('email', 'email@example.com');
$customer->addChild('address', 'Cardholder address');
$customer->addChild('city', 'Cardholder city');
$customer->addChild('county', 'Cardholder county');
$customer->addChild('country', 'Cardholder country');
$customer->addChild('postcode', 'Cardholder postcode');
$customer->addChild('tel_home', 'Cardholder tel_home');

// Call TourCMS API, charging the card
$result = $tourcms->spreedly_create_payment($payment, $channel);

if($result->error == "OK") {

	// Spreedly has successfully charged the card
	// TourCMS has committed the booking (if not already committed)
	// And stored details of the payment on the booking

	print "Thanks, payment added";
} else {

	// Spreedly was unable to charge the card

	// In the case of a 3D Secure transaction,
	// further processing may be required

	print "Transaction not complete";

}
Thanks, payment added

C# examples use the .Net Client Library

Overload list

XmlDocument SpreedlyCreatePayment ( XmlDocument paymentData, 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);

// Must set the currency
XmlElement paymentCurrency = paymentData.CreateElement("payment_value");
paymentCurrency.InnerText = "GBP";
root.AppendChild(paymentCurrency);

// Set the Spreedly payment token (credit card) to use
XmlElement paymentToken = paymentData.CreateElement("payment_token");
paymentToken.InnerText = "AAABBBCCCDDD";
root.AppendChild(paymentToken);

// Send the data to the TourCMS API, recording the payment/refund
XmlDocument doc = myTourCMS.SpreedlyCreatePayment(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 SpreedlyCreatePayment ( XmlDocument paymentData, 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)

' Must set the currency
Dim paymentCurrency As XmlElement = paymentData.CreateElement("payment_value")
paymentCurrency.InnerText = "GBP"
root.AppendChild(paymentCurrency)

' Set the Spreedly payment token (credit card) to use
Dim paymentToken As XmlElement = paymentData.CreateElement("spreedly_payment_method")
paymentToken = "AAAABBBBCCCCDDD"
root.AppendChild(paymentToken)

' Send the data to the TourCMS API, recording the payment/refund
Dim doc As XmlDocument = myTourCMS.SpreedlyCreatePayment(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


Example

// Tell spreedly to charge 10GBP to the card represented by SPREEDLY_PAYMENT_METHOD_TOKEN
TourCMS.createSpreedlyPayment({
  channelId: 3930,
  payment: {
    spreedly_payment_method: "SPREEDLY_PAYMENT_METHOD_TOKEN",
    booking_id: "8400",
    payment_value: "10",
    currency: "GBP"
  },
  callback: function(response, status) {
    console.log(response.error);
  }
});
OK

Looking for sample code in a different language? TourCMS and community provided API libraries

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
spreedly_payment_methodThe Spreedly Payment Method Token (credit card) to use. Likely obtained either via a payment form or CORS request. This must be provided.
booking_idTourCMS ID number for the Booking. This must be provided.
payment_valueAmount to charge the customer, if issuing a refund then use a negative value. This must be provided.
payment_currencyCurrency for the payment_value.
 
In most cases this will be the "sale_currency" for the Channel & Tour(s) being booked. If a different currency is provided TourCMS will use the exchange rate configured in the account to convert to the "sale_currency" before adding to the booking, in this case you must have an exchange rate loaded for this currency.
 
Instead, if you are using a Trust My Travel Spreedly account, and looking to implement their Multi Currency Pricing functionality, see the Trust My Travel note below.
payment_typeTextual description of the payment type. E.g. Credit card
payment_noteAny extra detail that needs to be recorded
paid_byC for customer or A for agent
paid_by_idEither a Customer ID or an Agent ID. If not specified TourCMS will presume either the lead pax or agent has paid.
booking_status_updateSet to 0 to stop TourCMS automatically updating the booking status
creditcard_fee_typeInteger representing if and how to apply the preconfigured credit card fee:
 
0 - No credit card fee
 
1 - Fee included. E.g. you charge the customer 100 GBP with a 3% credit card fee included. The customer will pay 100 GBP and 100 GBP will be reduced from the outstanding balance. A 2.91 GBP fee will be added to the booking (don't use this if the customer is clearing their balance as it will leave money owed on the booking)
 
2 - Fee already added. E.g. you charge the customer 103 GBP with a 3% credit card fee added. The customer will pay 103 GBP and 103 GBP will be reduced from the outstanding balance. A 3 GBP fee will be added to the booking.
 
3 - Fee waived, use this if a fee should have been applied but was waived by staff
 
In the majority of cases, if a fee is being added then number 2 above will be used.
cardholder_customerTrust My Travel only. Send cardholder details instead of customer lead details. Check mandatory fields in Trust My Travel.
3D Secure (Learn more)
browser_infoCollected and serialized into a string as per the Spreedly guide.
attempt_3dsecureSet to "true" to attempt 3D Secure
three_ds_versionSet to "2"
redirect_urlUsed in the event that the transaction falls back to 3D Secure 1, more information on Spreedly 3D Secure 1 here.
Installments
installments

Instruct the gateway to bill the customer in installments. NB: Only supported by very few gateways and countries. Learn more

XML NodeNotes
count The number of installments to be used. TourCMS will send the appropriate gateway specific field (usually either "installments" or "instalments").
id "d_local" gateway only. The installment plan ID to use.
For those using Trust My Travel "Multi Currency Pricing" (Learn more)
salesledger_payment_valueAmount to store on the booking sale ledger in TourCMS (should be the amount in the channel currency).
 
The amount to charge the customer, in their chosen payment currency, should be passed in the payment_value node
salesledger_payment_currencyCurrency to store on the booking sale ledger in TourCMS (should be the sale currency for the Channel)

 
Response fields

Response fields
XML NodeNotes
request Confirmation of the request that you sent
error An error response of "OK" indicates a transaction has succeeded, otherwise an error will be displayed indicating the issue
 
In the case of 3D Secure transactions, instead check the //transaction/state and //transaction/required_action before deciding how to continue.
booking

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

XML NodeNotes
booking_idTourCMS Booking ID
3D Secure - Learn more
transaction

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

XML NodeNotes
transaction_id If the transaction is pending TourCMS will issue a transaction_id to allow it to be completed in future. This is different to the Spreedly transaction_token.
state Spreedly state field, e.g. "pending"
message Spreedly message field, a human-readable string indicating the result of the transaction
required_action The required action in the 3DS 2 flow, e.g., none, device_fingerprint, challenge, etc
checkout_form HTML entity encoded checkout form.
checkout_url
challenge_form
challenge_url HTML entity encoded challenge form.
device_fingerprint_form HTML entity encoded fingerprint form.

 
 
Installments

Caution: This is an advanced and potentially complex topic.

Payment via installments is a feature popular and often supported by gateways in countries such as Brazil, Mexico, Turkey and Japan whereby the customers card is billed in regular incremements, e.g. speading a payment over 6 payments, one every 30 days.

Installment support (including the allowed number of installments) can vary by gateway, merchant country, customer country etc. It is the responsibility of the API consumer to understand when and how many installments to offer.

The following is an example of a payment request with installments, based on this TourCMS will instruct Spreedly to pass the appropriate gateway-specific field(s).

<?xml version="1.0"?>
<payment>
  <spreedly_payment_method>AAABBBCCC</spreedly_payment_method>
  <booking_id>12345</booking_id>
  <payment_value>120</payment_value>
  <payment_currency>EUR</payment_currency>
  <installments>
    <count>6</count>
  </installments>
</payment>

 
Configuring installments

  • To check if Spreedly have implemented the gateway specific fields for installments on your chosen gateway find your chosen gateway on their list and check the details page for mention of installments.
     
  • A "Gateway Type" must be entered in the Spreedly gateway configuration within TourCMS (Configuration & Setup > Credit card payments > Edit).
     
    The gateway type must exactly match the Spreedly gateway type exactly (e.g. "adyen" for Adyen). If no gateway type has been configured within TourCMS attempting a payment with installments will result in a "GATEWAY_TYPE_NOT_CONFIGURED" error.
     
  • Where TourCMS have not implemented installments for a gateway type an "error" node containing "INSTALLMENTS_NOT_SUPPORTED" will be returned.
     
  • Please contact Palisis support to discuss.
     

 
 
Trust My Travel “Multi Currency Pricing”

If your payment facilities have been provided by Trust My Travel and you are looking to implement their Multi Currency Pricing functionality - allowing your customers to pay in their own currency, yet have the correct amount be deducted from the TourCMS - you should use the following logic:

Customer paying in the normal channel sale currency

Use payment_value and payment_currency as normal

Customer paying in a different currency

Send the amount to bill the customer (i.e. their chosen payment currency) as payment_value and payment_currency, then send the amount to store on the sales ledger (i.e. the amount in your sale currency) as salesledger_payment_value and salesledger_payment_currency.

Trust My Travel will calculate the exchange rate you have used and verify that it is in a range that they will accept, if so they will attempt to charge the customer to the value of payment_value and if the payment is successful TourCMS will update the customers booking with a payment to the value salesledger_payment_value, keeping a note of the amount that the customer paid.

More information