Developers » Subscription Dialog Window
1. Parameters for showSubscriptionBox

To show the subscription dialog window, call the method [ showSubscriptionBox|showSubscriptionBox] from Client API. For the second argument, pass action, an action necessary for completion.
Possible values:
  • create purchase subscription;
  • resume renew subscription;
  • cancel cancel subscription.

The method showSubscriptionBox accepts the following parameters:
This is the name of the subscription that will be sent via the notification get_subscription. The string is up to 64 characters. For example, subscription_25new (for action = create).
Subscription ID (for action = resume, cancel).
2. Events

After completing the payment, one of these three events will be sent by the processor depending on the result:

onSubscriptionCancelUser cancels the purchase.
onSubscriptionSuccesssubscription_id (integer)The purchase was successful.
  • subscription_id the subscription ID. Complete information about payment notification processing can be found on this page.
onSubscriptionFailerrorCode (integer)The payment failed.
  • errorCode error code. Complete information about payment notification errors can be found on this page.
3. Example JavaScript Code
<script type="text/javascript">
  function order() {
    VK.callMethod('showSubscriptionBox', 'create', {item: 'subscription1'});

  var callbacksResults = document.getElementById('callbacks');

  VK.addCallback('onSubscriptionSuccess', function(subscription_id) {
    callbacksResults.innerHTML += '<br />onSubscriptionSuccess '+subscription_id;
  VK.addCallback('onSubscriptionFail', function() {
    callbacksResults.innerHTML += '<br />onSubscriptionFail';
  VK.addCallback('onSubscriptionCancel', function() {
    callbacksResults.innerHTML += '<br />onSubscriptionCancel';

The function 'order' allows you to display the product purchasing window to users using the name subscription_25new. The names of previous payment events are recorded in a container marked id=callbacks.