Kaltura Configuration Guide
Version: 1.15
Release: 7 Mar 2012
Copyright © 2012 RMP Protection Limited
Table of Contents
3 Creating a Pay-Per-View profile
4 Assigning a Pay-Per-View profile to an entry
5 Installing the CarrotPay plug-in a Kaltura player
6 Communicating with the CarrotPay plug-in
7 Charging for videos without a Digital Rights Management service
8 Interfacing a Digital Rights Management service with CarrotPay
8.5 Releasing a KS after payment
9 Specifying the Digital Rights Management URL
9.1 Option 1 - Specifying the DRM URL in the Kaltura Management Console
9.2 Option 2 - Specifying the DRM URL in your website with JavaScript
9.3 Option 3 - Specifying the DRM URL in FlashVars
9.4 Option 4 - Specifying the DRM URL in the CarrotPay Account Control Panel
10 Embedding Kaltura player in your website
11 Enabling share-n-earn for video sales
11.2 Enabling share-n-earn via Kaltura Management Console
11.3 Enabling share-n-earn via FlashVars parameters
11.4 Add share-n-earn functionality directly to a page
This document provides a technical guide for the integration of Kaltura's video platform with our payment plug-in and a third-party Digital Rights Management (DRM) service. After integration you will be able to start charging for premium video content through your website.
We recommend you also reading the CarrotPay-Overview for Merchants document so you become familiar with the general concepts of CarrotPay payments.
You may obtain a CarrotPay Merchant account in one of two ways;
Merchant ID Secret Hash seed | KPPW-KBCD-GDZD-JWMW (this is the same as your WebPurse ID) e. g. csswlwclzgchcwch e.g. jwwvkgkdksmskqcl |
NOTE: For more information about the Hash seed and Secret, read document: CarrotPay-Overview for Merchants, chapter: CarrotPay Security.
For HTTP pages: <script src="http://cdn.carrot.org/js/carrot.js"></script> For HTTPS pages: <script src="https://cdn.carrot.org/js/carrot.js"></script> |
If you plan to charge viewers to watch your videos, you will need to create a Pay-Per-View profile within the Kaltura console and select the 'Advanced Security' and 'Pay-Per-View' options.
In order to charge for your content you will need to install the CarrotPay plug-in to your player.
Key | Value |
CarrotPay.plugin | true |
CarrotPay.path | http://cdn.carrot.org/swf/CarrotPayPlugin.swf |
CarrotPay.relativeTo | ControllerScreen |
CarrotPay.position | lastChild |
CarrotPay.width | 24 |
CarrotPay.height | 24 |
CarrotPay.entry | {mediaProxy.entry} |
In chapter 5 Installing the CarrotPay plug-in a Kaltura player the basic set-up steps were explained and now we will elaborate on how to communicate through the Carrot library. When the CarrotPay plug-in is installed in the Kaltura player, it provides a declarative interface to the carrot.js JavaScript library by interpreting FlashVars parameters and calling Carrot functions which have been instantiated on host html page.
The table below shows the mapping between the programmatic interface provided by carrot.js and the declarative interface provided by the plug-in.
carrot.js programmatic interface | CarrotPay plug-in declarative interface |
Carrot.pay({parameter:'value'}) | carrot_pay_parameter=value |
Carrot.purse({parameter:'value'}) | carrot_purse_parameter=value |
Carrot.get_id({parameter:'value'}) | carrot_get_id_parameter=value |
Carrot.DRM({parameter:'value'}) | carrot_drm_parameter=value |
Example of calling the Carrot.pay() function with JavaScript
Carrot.pay({ //Merchant ID as allocated during CarrotPay registration merchant: "BWRV-JZHS-RQGZ-WLVL", price: "0.001:EUR" description: "Carrot Icon", return_url: "http://www.carrot.org/Carrot[Carrot].png" }); |
Example of passing parameters to the Carrot.pay() function with FlashVars
<object... <param name="flashVars" value="&carrot_pay_merchant=BWRV-JZHS-RQGZ-WLVL&carrot_pay_price=0.001:EUR&carrot_pay_description=Carrot Icon&carrot_return_url=http://www.carrot.org/Carrot[Carrot].png" /> </object... |
NOTE: The plug-in will call Carrot.pay() with the set of supplied parameters and will also include some additional parameters such as entry-id and partner-id.
NOTE: In addition to being able to specify parameters for each of the four Carrot functions, you may also specify parameters that will be used with all four functions by prefixing the parameter name with 'carrot_'. However take case when specifying parameters like 'drm_url', as this may easily be mis-read if you are not careful. For example if you want to send the parameter 'drm_url' to the DRM function, you must actually use 'carrot_drm_drm_url' because if you simply use 'carrot_drm_url' it will pass a parameter with the key 'url' rather that 'drm_url' as you may have intended. A useful example of this method is 'carrot_merchant'.
You can charge for videos by applying a Kaltura pay-per-view policy:
A user has just clicked the Play button on the Kaltura player and the Carrot WebPurse is displayed and prompts for confirmation of the payment of US 20¢ (as specified by the carrot_pay_price parameter in FlashVars).
In this case the Kaltura player FlashVars will be something like this:
<object... <param name="flashVars" value="&carrot_pay_merchant=BWRV-JZHS-RQGZ-WLVL&carrot_pay_price=0.20:USD&carrot_pay_description=just a video&carrot_pay_other_parameters_here...=..." /> </object> |
After the user has confirmed the payment, your server should process and validate the return_url based on your website's own criteria (e.g. did the price match the video and was there a valid hash).
Once validation is complete, your server must use the Kaltura API to generate the Kaltura Session (KS) and return this back to the player, thereby allowing the video to continue.
Digital Rights Management (DRM) in this context referrers to the 'Digital Management of Rights', with the intent to allow or restrict access an on-line digital asset (namely a video). It can be used to allow extended viewing periods and to permit access from multiple devices (e.g. computer, pad or phone).
When selling videos with extended viewing rights (e.g. 24hr access or monthly subscription etc.), there is a need for a DRM service to identify the viewer and the content, check for any previously purchased rights and to authorize access or request payment as appropriate. CarrotPay provides a convenient way to add a DRM phase to the 'in-video' sales process . When selling a video on a purely pay-per-view basis, there is no need for a DRM as the viewer must make a payment every time and the viewer's identity is likely to be unimportant.
CarrorPay makes no assumptions about the nature of your particular DRM other than;
If this is not the case then you must arrange for a regular web service (e.g. PHP or Java etc.) to forward the parameters to the actual DRM and then to return a suitable result in HTML format.
When the user is required to pay for a video, the CarrotPay plug-in calls Carrot.DRM() passing the entry_id of the video and the partner_id of the merchant. The CarrotPay library adds the entry_id, parter_id, element_id and webpurse_id (if known), to the drm_url and creates an iframe on the host HTML page. The iframe 'src' is set to the drm_url thereby getting the browser to call the DRM.
When called, the DRM must determine if the viewer owns an existing right to view the video and if so it must generate a Kaltura Session (KS) (using various Kaltura server-side functions), and return a KS to the player via the Carrot JavaScript library.
Using JSP the returned HTML will look something like this example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <!-- DRM/approved --> <head> <title>DRM approval</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="https://cdn.carrot.org/js/carrot.js" ></script> <script type="text/javascript"> <!-- <![CDATA[ $(function() { Carrot.initialise_host(function() { Carrot.host.handle_return("KS=${KS}"); }); }); // ]]> → </script> </head> <body style="background-color: transparent"> </body> </html> |
NOTE: The important bit here is the call to Carrot.initialise_host() and Carrot.host.handle_return(). This code will cause the KS to be returned to the plug-in as a key-value pair (KS=<actual KS string>), and then on to the player, which will then continue to play the video. In this case there is no need to display anything to the viewer so the <body> is empty.
If the viewer does not currently own the right to view the video, the DRM may;
To directly return payment data use something like this:
Carrot.initialise_host(function() { Carrot.host.handle_return( "merchant=<merchantID>&price=0.2:USD&description=Cool video&return_url=<url>" ); }); |
NOTE : Payment parameters must be passed to the plug-in in standard URL format (i.e. ¶m=value).
NOTE: The return_url must be URL encoded so that it forms a valid URL parameter. This may easily be achieved by using the “escape()” function in JavaScript or a similar server-side function.
When returning multiple payment options to the viewer it's a little more complex because the choices need to be displayed before the viewer selects one. The follow code shows the essentials element of this process:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <!-- DRM/multiOptionSale --> <head> <title>DRM sale</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="https://cdn.carrot.org/js/carrot.js" ></script> <script type="text/javascript"> <!-- <![CDATA[ function cancel() { if(typeof Carrot.host != 'undefined') { Carrot.host.popup_message('Sale cancelled',4000); Carrot.host.handle_failure('cancelled'); } } function revealSalesOffer(area) { Carrot.initialise_host(function() { if(typeof Carrot.host != 'undefined') { Carrot.host.resize_iframe($(area).width(),$(area).height()); Carrot.host.show_iframe("${param['element_id']}"); } }); } $(function() { $("li#ppv").click(function() { var url = "${AUTH_URL}?entry_id=${param['asset_id']}"; url += "&product_code=ppv&h=[${param['asset_id']} ppv]"; var item = "price=0.2:USD&description=Cool video"; var params = "merchant=BBBB-VVVV-GGGG-QQQQ&"+item; Carrot.host.handle_return(params+"&return_url="+escape(url)); }); $("li#day").click(function() { var url = "${AUTH_URL}?entry_id=${param['asset_id']}"; url += "&product_code=day&h=[${param['asset_id']} day]"; var item = "price=0.5:USD&description=Cool video day pass"; var params = "merchant=BBBB-VVVV-GGGG-QQQQ&"+item; Carrot.host.handle_return(params+"&return_url="+escape(url)); }); revealSalesOffer($("#container")); }); // ]]> --> </script> </head> <body class="sale-body" > <div id="container"> <ul> <li id="ppv">Pay-per-view</li> <li id="day">Day pass</li> <li><a href="Javascript:cancel()">Close</a></li> </ul> </div> </body> </html> |
Code example – 8.1
Points of interest in the code example 8.1
NOTE: For furthered details see the Kaltura DRM/Payment sequence diagram in figure 8.2
Figure 8.2 - Kaltura DRM/Payment sequence diagram
When called, the DRM should expect to receive a number of parameters which must be processed to determine if a viewer should be granted access to the video immediately or if a payment should first be requested. The CarrotPay plug-in for the Kaltura player will ensure that the following parameters are passed to the DRM:
Parameter | Description |
asset_id | This will be set to the Kaltura entry_id for the particular video that has been requested to play. |
element_id | This will be set to the id of the player that is playing the video. |
webpurse_id | If it's available, this will be set to the unique id of the viewer's WebPurse, otherwise it will be empty. |
The DRM should have it's own method of knowing who the viewer is. Perhaps the viewer must first login or maybe the identity is already held in a server session or in a Cookie in the same domain as the drm_url or perhaps the identity is established through OpenID or Facebook etc. If the viewer needs to login but has not already done so, the DRM may return an HTML login page to capture the viewer's credentials before determining if the viewer currently owns viewing rights or not. In this case it must use Carrot.initialise_host() and Carrot.host.show_iframe() to display the login page.
If payment is required and the plug-in is passed appropriate payment data, it will call Carrot.pay() with all the payment parameters and set the no_replay parameter to true. With this option set, the payment process will perform a server-side fetch of the processed return_url.
Once called the return_url should check the hash to ensure that payment has been properly made and if so it may need to update its records to record the fact that the viewer now has future viewing rights for one or more videos in the catalog. It also needs to calculate and return the KS for the specific video identified by the enrty_id which will then be passed back to the plug-in through the CarrotPay system.
NOTE: In this case the KS should NOT be prefixed with “KS=” as is the case when the KS is returned from the DRM process.
Specifying a DRM service to be used with the Kaltura Video platform and CarrotPay payments can be achieved by using one of the following four options.
NOTE: You should installed the CarrotPay plug-in before continuing this section. For more information on how to do that, please read chapter 5 Installing the CarrotPay plug-in a Kaltura player.
NOTE: You are advised not to enable the Kaltura Player feature Share Button (found under KMC > Studio > Edit a Kaltura Player > Features > Share Button) because in most social media websites, e.g. Facebook the player will not be able to display successfully a payment request to the end user and that is because some websites do not allow JavaScript to communicate with the player, (i.e <param name="allowScriptAccess" value="never"/> ). Alternatively, you are encouraged to enable the share-n-earn functionality (see chapter 10 Enabling share-n-earn for video sales) which will allow users to copy and share the video link to any website. When the link is shared the video content will still not be viewed within the shared website, e.g. on a Facebook Wall but instead the user will have to click on the displayed link which will redirect him to the merchant’s website where from there the video will be possible to be played and successfully display the payment request to the end user.
This solution is suggested if you are planning to enable the Kaltura player "Share Button". The "Share Button" allows users to copy the Embed Code of your video entries from your page and paste them in other pages (e.g. a blog).
NOTE: As mentioned earlier in chapter 9 Specifying the Digital Rights Management URL, when the video is shared using the Share Button the end user when is trying to play the video content may not be able to successfully receive a payment request prompt due to the allowScriptAccess parameter set to never by some websites.
You can specify the DRM URL for your desired Kaltura player by adding the following key-value pair under the Additional parameters and plugins panel in Kaltura Management Console (KMC).
Key | Value |
carrot_drm_drm_url | https://yourvideowebsite.com/yourDRM? |
NOTE: The value of the carrot_drm_drm_url key should point to your DRM URL.
This solution is suggested if you are not planning to enable the Kaltura player Share Button, i.e. your videos will be viewed only within your own site.
For HTTP pages: <script type="text/javascript" src="http://cdn.carrot.org/js/carrot.js"></script> For HTTPS pages: <script type="text/javascript" src="https://cdn.carrot.org/js/carrot.js"></script> |
Here is the simplest way to achieve this:
<script> Carrot.drm_url="https://secure.yourwebsite.com/yourDRM?"; </script> |
However, the following jQuery method may be more reliable because it ensures the Carrot library has been loaded and initialised.
<script> $(document).ready(function() { //The Carrot.drm_url will be set-up when the page is loaded Carrot.drm_url="https://secure.yourwebsite.com/yourDRM?"; }); </script> |
NOTE: The jQuery library is automatically loaded buy the carrot.js JavaScript library.
This solution is suggested if you are planning to use a different DRM URL for different sets of video entries while using the same Kaltura player for all entries. An alternative solution to this is to create as many Kaltura players as required and set the DRM URL for each individually through the Additional parameters and plugins panel in Kaltura Management Console (KMC).
NOTE: If you have the player's "Share Button" enabled, and a viewer shares the video on a third-party site (e.g. facebook), Kaltura will recreate the embed code from its internal records. In this way any manually added FlashVars parameters will not be included in the shared player.
NOTE: As mentioned earlier in chapter 10 Embedding Kaltura player in your website, when the video is shared using the Share Button the end user when is trying to play the video content may not be able to successfully see a payment request prompt due to the allowScriptAccess parameter set to never by many websites.
In the highlighted line below, an example is given of how the carrot_drm_drm_url attribute has been set-up to point to a DRM URL using FlashVars.
<object> id="kaltura_player_1328581297" name="kaltura_player_1328581297" type="application/x-shockwave-flash" allowFullScreen="true" allowNetworking="all" allowScriptAccess="always" height="330" width="400" bgcolor="#000000" xmlns:dc="http://purl.org/dc/terms/" xmlns:media="http://search.yahoo.com/searchmonkey/media/" rel="media:video" resource="http://www.kaltura.com/index.php/kwidget/cache_st/1328581297/wid/_757252/uiconf_id/7124832/entry_id/0_cj9cah63" data="http://www.kaltura.com/index.php/kwidget/cache_st/1328581297/wid/_757252/uiconf_id/7124832/entry_id/0_cj9cah63" wmode="opaque">
<param name="wmode" value="opaque"/> <param name="allowFullScreen" value="true" /> <param name="allowNetworking" value="all" /> <param name="allowScriptAccess" value="always" /> <param name="bgcolor" value="#000000" /> <param name="flashVars" value="&carrot_drm_drm_url=http://yourwebsite.com/yourDRM?" /> <param name="movie" value="http://www.kaltura.com/index.php/kwidget/cache_st/1328581297/wid/_757252/uiconf_id/7124832/entry_id/0_cj9cah63" /> </object> |
This solution is suggested when for some reason you are unable to set up the DRM URL by using any of the previously mentioned options or simply because you feel this way might be more suitable to what you are trying to achieve. When the DRM URL is set in the CarrotPay Account Control Panel the URL will always be retrieved through Carrot.
You can specify the DRM URL in the Control Panel by executing the following steps:
kaltura:123456 |
After you have successfully installed the CarrotPay plug-in you can start embedding premium videos that can be played with the Kaltura player in your site.
<object id="kaltura_player_1328581297" name="kaltura_player_1328581297" type="application/x-shockwave-flash" allowFullScreen="true" allowNetworking="all" allowScriptAccess="always" height="330" width="400" bgcolor="#000000" xmlns:dc="http://purl.org/dc/terms/" xmlns:media="http://search.yahoo.com/searchmonkey/media/" rel="media:video" resource="http://www.kaltura.com/index.php/kwidget/cache_st/1328581297/wid/_757252/uiconf_id/7124832/entry_id/0_cj9cah63" data="http://www.kaltura.com/index.php/kwidget/cache_st/1328581297/wid/_757252/uiconf_id/7124832/entry_id/0_cj9cah63" wmode="opaque"> <param name="wmode" value="opaque"/> <param name="allowFullScreen" value="true" /> <param name="allowNetworking" value="all" /> <param name="allowScriptAccess" value="always" /> <param name="bgcolor" value="#000000" /> <param name="flashVars" value="&" /> <param name="movie" value="http://www.kaltura.com/index.php/kwidget/cache_st/1328581297/wid/_757252/uiconf_id/7124832/entry_id/0_cj9cah63" /> </object> |
share-n-earn (S-N-E), is a free ad-hoc affiliate network service for web sites (merchants), who wish to promote selected sales items, (e.g. video, music, games) or their site as a whole. A merchant signifies their willingness to share sales revenue with an affiliate by enabling the S-N-E button of CarrotPay plug-in after it has been installed in the Kaltura player. The use of this button by a potential affiliate creates a custom version of a URL supplied by the merchant (known as an 'affiliate URL'), to be posted on the affiliate's social network page, sent in an email or posted on the affiliate's own web site. If subsequent use of this URL results in a sale for the merchant, the merchant agrees to split the sales revenue with the affiliate. We recommend you also read the CarrotPay:share-n-earn document so you become familiar with the general concepts of share-n-earn and find out more technical information and further examples of how share-n-earn can be integrated in your site.
This option is ideal if you wish to operate a site wide S-N-E scheme where every sne_link is the same. Alternatively, if you would prefer to promote individual videos, you may wish to dynamically set the parameters through FlashVars, thereby having the flexibility to vary the terms of the scheme. Chapter 11.3 Enabling share-n-earn via FlashVars parameters has more details of this.
After you have successfully installed the CarrotPay plug-in, you may enable S-N-E by adding parameters in the Kaltura Management Console (KMC).
Key | Value (Example) |
carrot_purse_se_link | A URL that allows the merchant to determine what is being promoted. |
carrot_purse_se_title | A short description of the content being promoted. |
Key | Value (Example) |
carrot_purse_se_cobrand | A short name to be displayed during the sharing process. |
carrot_purse_se_earn | A very brief description of the sharing scheme. Defaults to blank, |
carrot_purse_se_scheme | The URL of a page describing the merchant's share-n-earn scheme. This URL may be activated by an affiliate by clicking an information icon provided in the share-n-earn widget. If not provided the affiliate will be sent to a generic description of the service hosted by carror.org. |
<script src="http://cdn.carrot.org/js/carrot.js" type="text/javascript"></script> <script src="http://cdn.carrot.org/js/shareNearn.js" type="text/javascript"></script> |
This option is ideal if you prefer your pages to set the share-n-earn parameters through FlashVars for each specific video, independently of the Kaltura player(s) being used on your page. Alternatively, if you would prefer to use a specific Kaltura player for a specific set of videos then read chapter Enabling share-n-earn via Kaltura Management Console
After you have successfully installed the CarrotPay plug-in you can enable S-N-E by adding S-N-E parameters to the FlashVars already in the embedded code.
NOTE: If you haven't yet embedded any video in your page, please read chapter 10 of this document.
<script src="http://cdn.carrot.org/js/carrot.js" type="text/javascript"></script> <script src="http://cdn.carrot.org/js/shareNearn.js" type="text/javascript"></script> |
Parameter | Value (Example) |
carrot_purse_se_link | A URL that allows the merchant to determine what is being promoted. |
carrot_purse_se_title | A short description of the content being promoted. |
Parameter | Value (Example) |
carrot_purse_se_cobrand | A short name to be displayed during the sharing process. |
carrot_purse_se_earn | A very brief description of the sharing scheme. Defaults to blank |
carrot_purse_se_scheme | The URL of a page describing the merchant's share-n-earn scheme. This URL may be activated by an affiliate by clicking an information icon provided in the share-n-earn widget. If not provided the affiliate will be sent to a generic description of the service hosted by carror.org. |
<object id="kaltura_player_1328581297" name="kaltura_player_1328581297" type="application/x-shockwave-flash" allowFullScreen="true" allowNetworking="all" allowScriptAccess="always" height="330" width="400" bgcolor="#000000" xmlns:dc="http://purl.org/dc/terms/" xmlns:media="http://search.yahoo.com/searchmonkey/media/" rel="media:video" resource="http://www.kaltura.com/index.php/kwidget/cache_st/1328581297/wid/_757252/uiconf_id/7124832/entry_id/0_cj9cah63" data="http://www.kaltura.com/index.php/kwidget/cache_st/1328581297/wid/_757252/uiconf_id/7124832/entry_id/0_cj9cah63" wmode="opaque"> <param name="wmode" value="opaque"/> <param name="allowFullScreen" value="true" /> <param name="allowNetworking" value="all" /> <param name="allowScriptAccess" value="always" /> <param name="bgcolor" value="#000000" /> <param name="flashVars"value="&carrot_purse_se_link=http://www.yoursite.com/affiliate-sale?prod=1234&carrot_purse_se_title=A funny video&carrot_aff=${param['aff']}"/> <param name="movie" value="http://www.kaltura.com/index.php/kwidget/cache_st/1328581297/wid/_757252/uiconf_id/7124832/entry_id/0_cj9cah6 </object> |
If you wish to enable the share-n-earn functionality in your site for the promotion of any content (including video), then you may wish to read the CarrotPay-share-n-earn document which describes how you can achieve that.
For your reference, below there is a simple example of how to instantiate a share-n-earn button for a mobile phone review.
<a class="carrot-share-n-earn-button" data-link="http://www.yoursite.com/affiliate?review=xyz-1625" data-scheme="http://www.yoursite.com/carrot-affiliate-scheme.html" data-title="Mobile Phone – Model xyz" data-earn="Earn 10% for sale of this mobile phone review" data-cobrand="Your Brand"></a> |