Setting up ticket sales with widgets

Ticketmatic’s widgets are being replaced by Ticket sales flows that have more functionality and are easier to use. You can still use widgets directly, as specified below.


A widget is a configurable web application that covers a part of the ticket sales process. A typical ticket sales process consists of following steps:

  1. Explore events (happens on your website)
  2. Add tickets to order for an event
  3. Show basket (optional)
  4. Checkout

Widgets allow you to handle each of the steps 2 to 4 individually and allow you to navigate back to your website after each step. Compared to the plug and play approach which handles steps 2-4 in a single, straightforward wizard, this gives you much more flexibility to setup a ticket sales process that is tailored to your individual need.

Some examples of what you can achieve:

  • You can let the user iterate between steps 1 and 2 to allow the user to add tickets for more than 1 event to his order
  • You can provide your own upselling page, right before going to checkout

Widgets can be used embedded or standalone. An embedded widget is displayed inside your website (using an iframe). A standalone widget is displayed in a complete browser window.

Embedded widgets used inside an iframe require the use of a [custom domain](tickets/selling_tickets/customurl) that is on the same domain as your website (for example `tickets.mydomain.com`).

Generating a widget url

You use a widget by generating a widget url and simply linking to it.

When generating a widget url, you specify the parameters to configure the widget and then you need to generate a signature (to avoid tampering with the widget url). The easiest way to generate a widget url is by using one of the API libraries. Each library contains a helper class to generate widget urls and generating the signatures is provided by the library.

The signing helper is Ticketmatic\Widgets. Instantiate it with your account name and widget keys:

1use Ticketmatic\Widgets;
2
3$widgets = new Widgets($accountname, $accesskey, $privatekey);

Pass a widget name and a set of parameters to sign the URL:

1$url = $widgets->generateUrl("addtickets", array(
2    "event"     => 123,
3    "skinid"    => 1,
4    "returnurl" => "http://www.ticketmatic.com",
5    "l"         => "en",
6));

If you don’t find a suitable library or if you prefer to generate the widget urls yourself you can manually generate widget urls.


Configuring widgets

You configure widgets by providing the parameters you want. Most parameters are optional, when omitting them Ticketmatic will provide sensible defaults.

You must specify the name of the widget. Ticketmatic provides following widgets:

* [authenticate](/docs/tickets/selling_tickets/widgets/#widget-authenticate): used for an authenticated buying process * [addtickets](/docs/tickets/selling_tickets/widgets/#widget-addtickets): used for adding tickets to an order (step 2) * [basket](/docs/tickets/selling_tickets/widgets/#widget-basket): used for displaying and optionally modifying an order (step 3) * [checkout](/docs/tickets/selling_tickets/widgets/#widget-checkout): used for checking out an order (step 4)

Widget authenticate

Use this widget to enable an authenticated buying process. The returnurl will contain the contactid as parameter. This widget needs to be used as the first step in the buying process.

Widget addtickets

Use this widget to add tickets for one or more events to an order. You can also use it to add products to an order.

You should at least specify the event or product parameter:

  • In the event parameter, specify one or more event ids (comma-separated) for which you want to sell tickets. Specifying multiple event ids works best when you have only a limited set of prices for each event. With too much prices, the widget quickly becomes too complicated. In that case it is best to use separate widgets for each event.
  • In the product parameter, specify one or more product ids.

Upselling

The addtickets widget supports upselling: you can specify additional events and products beside the main event or product on sale. Use the parameters extraevents and/or extratickets and specify one or more ids.

Ticketmatic only supports unseated events in the extraevents parameter.

Collecting ticket info

Use the ticketinfo parameter to specify what information should be collected for each ticket that was added to the order. The ticketinfo parameter should contain a comma-separated list of fields. If this parameter is not specified, no extra ticket information will be collected.

Supported ticketinfo fields:

ValueDescription
nameName of the ticket holder
emailE-mail address of the ticket holder

Example:

1ticketinfo=name,email

Action after adding tickets

Use the flow parameter to specify what should happen after adding tickets to the order:

ValueDescription
returnafter adding tickets, go straight back to the website (parameter returnurl decides where the user is redirected to)
checkoutafter adding tickets, go straight to checkout (default)
basketafter adding tickets, go to the basket page. The basket page will contain an ‘Add more tickets’ link and the user will be redirected to the website when clicking this link (parameter returnurl decides where the user is redirected to)
basketwithcheckoutafter adding tickets, go to the basket page with possibility to continue to checkout. The basket page will contain an ‘Add more tickets’ link and the user will be redirected to the website when clicking this link (parameter returnurl decides where the user is redirected to)

Widget basket

Use this widget to display the contents of the current order to a user.

Disable editing the order

You can optionally disable the user to edit his order by specifying value no for the parameter edit. If this parameter is not specified, the basket is read-only.

Action after displaying the order

Use the flow parameter to specify what should happen after displaying the order:

ValueDescription
returnafter displaying the order, go straight back to the website (parameter returnurl decides where the user is redirected to)
checkoutdisplay a checkout button in the basket widget so the user can optionally continue to the checkout

Widget checkout

Use this widget to handle checkout of an order: this means registering customer, payment and delivery info and handling the online payment.

Use the parameter panels to specify what part of the checkout should be handled. The panels parameter should contain a comma-separated list of fields. If this parameter is not specified, all parts will be handled.

Supported fields:

ValueDescription
customerCustomer registration
deliverySelection of delivery method
paymentSelection of payment method and handling online payment

Action after checkout

Use the oncompletion parameter to specify what should happen after the checkout:

ValueDescription
orderdetailafter a succesful checkout, go to the Ticketmatic order detail page
returnafter a succesful checkout, go back to the website (parameter returnurl decides where the user is redirected to)

Widget addoptionbundles

Use this widget to sell one or more option bundles. After selecting the product, the user will be asked for its details firstname, lastname, email after which he/she will be able to configure the option bundle by adding tickets.

Use the parameter product to specify the option bundles to sell. Multiple product ids are supported

Action after adding tickets

Use the flow parameter to specify what should happen after adding tickets to the order:

ValueDescription
returnafter adding tickets, go straight back to the website (parameter returnurl decides where the user is redirected to)
checkoutafter adding tickets, go straight to checkout (default)
basketafter adding tickets, go to the basket page. The basket page will contain an ‘Add more tickets’ link and the user will be redirected to the website when clicking this link (parameter returnurl decides where the user is redirected to)
basketwithcheckoutafter adding tickets, go to the basket page with possibility to continue to checkout. The basket page will contain an ‘Add more tickets’ link and the user will be redirected to the website when clicking this link (parameter returnurl decides where the user is redirected to)

Widget subscribe

Use this widget to let the user fill in his/her details after checkout.

Use the parameter fields to specify the details the user can fill in.

Supported values are customertitle, address, phone, birthdate


Styling widgets

You can style widgets by styling the webskin. See the webskin article for more details.

You can define several webskins. Use the parameter skinid to specify the webskin to use for the widget. If this parameter is not specified, the default webskin is used.


Parameter returnurl

The parameter returnurl can be used on any widget. It should contain the landingpage on the website where the user will be redirected to after finishing the widget. When redirecting the user to the landingpage, Ticketmatic will add following parameters to the returnurl:

  • accesskey: the accesskey that was passed in the widget url
  • orderid: the orderid used or generated in the widget
  • ordercode: an ordercode representing the current active basket
  • contactid: the id of the authenticated contact
  • reason: the reason why the user was redirected
    ValueDescription
    return“Previous” button has been clicked
    reservemoretickets“Reserve more tickets” button has been clicked
    ordercompletedThe order has been successfully completed
    ordercancelledThe order has been cancelled
    skinReturn URL from websales skin configuration has been used
    appcheckoutcompletedThe order has been successfully completed using the Ticketmatic app
  • signature: Ticketmatic generates a signature so you can verify that the call to the returnurl is genuine. The parameters are signed in exactly the same way as they need to be signed for the widget url

More advanced integration

For even more advanced integration, you can combine widgets with the API. For example: you could use the API to add tickets to the basket, and then use a checkout widget for letting the customer finish his order.


Generating widget urls manually

The easiest way to generate a widget url is by using one of the API libraries. But you can also generate it manually.

All widgets are provided at the endpoint:

1GET https://apps.ticketmatic.com/widgets/{accountname}/{widgetname}?{parameters}
2              &accesskey={accesskey}
3              &signature={signature}
  • {accountname} is the short name for the account. You can retrieve this in Settings -> Account parameters.
  • {widgetname} is the name of the widget
  • {parameters} contains the set of widget-specific querystring parameters
  • {accesskey} is the accesskey used to generate the signature
  • {signature} contains the signature for the request

Generating a widget signature

In order to make sure that the widget urls are not tampered with, you have to generate a signature and add this to each widget url.

Before you can start generating signatures, you will need an API keypair that has sufficient permissions to generate widget signatures. More info on obtaining an API-key

The keypair consists of 2 keys:

* `Access key`: this is a public key and is passed in each request * `Secret key`: this is a private key and is never passed in requests. It should be kept secret.

Every request you make to a widget must carry with it the access key and a signature. The signature is computed by hashing the request parameters and the access key, using the secret key as hashing key. The hashing algorithm used is SHA256.

In PHP you would generate the signature as follows:

1    $signature = hash_hmac(
2                      'sha256' , 
3                      $accesskey.$accountshortname.$parameters, 
4                      $secretkey
5    );

Example

Suppose you want to call the addtickets widget with following parameters:

* event: 123 * skinid: 25 * l: fr * returnurl: http://www.ticketmatic.com

And your keypair is:

* Access key: azertyuiop * Secret key: qsdfghjklm

First, generate the payload for the signature by concatenating these fields: accesskey, account shortname, parameter names and values in alphabetical order:

1azertyuiopmyaccountnameevent123returnurlhttp://www.ticketmatic.comskinid25

Remark: the l parameter (languagecode) should not be included when generating the signature!

Then, calculate the signature:

1  $signature = hash_hmac('sha256' , "azertyuiopmyaccountnameevent123returnurlhttp://www.ticketmatic.comskinid25", "qsdfghjklm");

This should return 0978f4fb9341ad17f6ed82bb1db0acbc2748b9042f39f10457eaded938fef2b8. The final widget url is:

1https://apps.ticketmatic.com/widgets/myaccountname/addtickets?
2          event=123&
3          l=fr&
4          returnurl=http%3A%2F%2Fwww.ticketmatic.com&skinid=25&
5          accesskey=azertyuiop&
6          signature=0978f4fb9341ad17f6ed82bb1db0acbc2748b9042f39f10457eaded938fef2b8
Remark that the parameters in the url should be urlencoded along RFC 3986 (for example the returnurl should be encoded as http%3A%2F%2Fwww.ticketmatic.com). For generating the signature, the original value should be used and not the urlencoded value.

More information


Questions?

We're always happy to help! Send us an e-mail