Skip to main content

Subscriptions

Process players' recurring payments.

Overview

The service allows your players to buy subscriptions. For example, a player can buy a VIP access that requires a monthly renewal. Payments for goods and payments for subscriptions differ in the frequency of debiting funds from the user's account. One-time payments are debited once per purchase, while subscription payments are debited at regular intervals.

  • Subscriptions are best suited for VIP accounts and sales of bonus.
  • Subscriptions can also be used to access regularly updated content, such as new levels or characters.

Thus, a subscription is a product that has such fields as:

  • Subscription ID - boolean field (true = subscription / false = product);
  • Subscription period - 7 and 30, 90 days;
  • Trial period - 0, 3, 7 and 30 days;
FieldTypeDescriptionExample
isSubscriptionbooleanPurchase is a subscriptiondefault false
periodnumberSubscription duration in days7, 30, 90
trialPeriodnumberThe duration of the trial period in days (during this time, the user can cancel the subscription without debiting funds)0, 3, 7, 30

In the SDK, you have access to information on purchased player subscriptions, they expand the standard purchase.

FieldTypeDescriptionExample
subscribedbooleanChecking if a purchase subscription is activetrue
expiredAtstringSubscription end date, format ISO 8601 UTC2022-12-01T04:52:26+0000

Supported platforms

  • VK Games
  • OK Games
  • Google Play
  • Android (alternative stores)
  • Web (custom site)
  • Platforms without support
  • CrazyGames
  • GamePix
  • GameDistribution
  • GameMonetize
  • SmartMarket
  • VK Play
  • Yandex Games
  • WG Playground
  • Kongregate
  • PlayDeck
  • Telegram
  • beeline
  • Fotostrana
  • Y8
  • Supported platforms (one-time subscriptions)

  • Yandex Games
  • VK Play
  • Kongregate
  • Telegram
  • beeline
  • Fotostrana
  • Platforms without support
  • CrazyGames
  • GamePix
  • GameDistribution
  • GameMonetize
  • OK Games
  • SmartMarket
  • VK Games
  • WG Playground
  • PlayDeck
  • Google Play
  • Y8
  • Android (alternative stores)
  • Web (custom site)
  • Use the isSubscriptionsAvailable property to check for on-platofrm subscription support in the SDK.

    // Check for subscription support on the platform
    if (gp.payments.isSubscriptionsAvailable) {
    // you can subscribe
    }

    Subscription period and trial period

    The period is specified in days. For the test period are available: 0, 3, 7 and 30 days. The trial period is the period when money is not withdrawn from the player and he can cancel the subscription free of charge. At the end of the test period, the site writes off the funds.

    The subscription period can be specified in 7, 30 and 90 days. The subscription will automatically renew at the end of the period, unless cancelled.

    tip

    Suggested periods in 7, 30 and 90 days are due to a single implementation of subscriptions on all sites. Some sites allow only such values.

    Subscriptions

    Setting up subscriptions on the platforms

    Platforms setup are described in payments section, nothing else is required from the technical side. Pay attention to the features of working with platforms.

    Adding a subscription

    To enable a subscription, you need to select a purchase and transfer it to the subscription status using the "Enable Subscription" toggle switch.

    Now you can subscribe to this product.

    tip

    If you buy a subscription through the purchase method purchase, then it will be issued as a subscription without automatic renewal and will be used up after the period specified in the purchase

    Subscribing

    +1-3 Request

    To subscribe, use the subscribe method.

    // by ID
    gp.payments.subscribe({ id: 12 });

    // by Tag
    gp.payments.subscribe({ tag: 'VIP' });

    The result of the call can be found out by subscribing to events subscribe.

    // The player has subscribed
    gp.payments.on('subscribe', ({ product, purchase }) => {});

    // Subscription not registered
    gp.payments.on('error:subscribe', (error) => {});

    When used asynchronously:

    const result = await gp.payments.subscribe({ id: 17541 });

    /**
    * Product data
    * @type {Product}
    */
    result.product;

    /**
    * Purchase data
    * @type {PlayerPurchase}
    */
    result.purchase;

    Cancel subscription

    +0-1 Request

    The player should be able to unsubscribe. To unsubscribe, use the method unsubscribe.

    tip

    Canceling a subscription does not mean deleting a player's purchase. The purchase will be valid until the end of the period.

    // by ID
    gp.payments.unsubscribe({ id: 12 });

    // by Tag
    gp.payments.unsubscribe({ tag: 'VIP' });

    The result of the call can be found out by subscribing to events unsubscribe.

    // Player unsubscribed
    gp.payments.on('unsubscribe', ({ product, purchase }) => {});

    // Failed to unsubscribe
    gp.payments.on('error:unsubscribe', (error) => {});

    When used asynchronously:

    const result = await gp.payments.unsubscribe({ id: 17541 });

    /**
    * Product data
    * @type {Product}
    */
    result.product;

    /**
    * Purchase data
    * @type {PlayerPurchase}
    */
    result.purchase;

    Subscription renewal

    +0-3 Request

    After canceling a subscription, while it is still valid, it is possible to renew the subscription. Call the subscription method again to resume the subscription.subscribe for the same item.

    Subscription testing

    We have prepared for you a convenient tool for testing subscriptions without the need to test directly on the sites.

    Test subscriptions automatically renew at the end of their term. To test the subscription expiration, you can set the subscription expiration date to the previous day in the control panel. Every 10 minutes we delete expired subscriptions.

    After cancellation, the subscription will still be valid until the expiration date, then it will be deleted. You can renew your subscription while it's still active.

    Interface to change the subscription expiration time:

    Features of working with platforms

    One-time subscriptions

    There is no subscription functionality on Yandex.Games, VK Play and Kongregate, but we have provided a unified work logic. It is possible to subscribe to a subscription that will not be renewed and will be deleted after the end of the subscription period. This will work like a one-time purchase, but will automatically consume when it expires.

    OK Games

    Before using subscriptions, you must submit a request to technical support indicating detailed information about the products you need to subscribe to. In the product ID, specify the product ID in the GamePush admin panel.

    tip

    Do not delete published subscriptions or change their period information. The data is stored on the Odnoklassniki side. First, make changes in Odnoklassniki.

    Implementation examples

    Checking the goods. There may be a situation where you need to check that the product is a subscription. And depending on this check - buy a product, or subscribe to it, if it isSubscription. The implementation of such a check is shown below:

    if (product.isSubscription) {
    gp.payments.subscribe({ id: product.id });
    } else {
    gp.payments.purchase({ id: product.id });
    }

    Purchase. An example of explicitly buying a subscription by id:

    gp.payments.subscribe({ id: 12 });

    Subscription period fields. An example of using period fields shows how you can display information about the balance of a trial period. And also inform the player about the terms of the subscription.

    $form.setText(`Free first ${product.trialPeriod} days`);
    $form.setText(`Then ${product.price} ${product.currencySymbol} every ${product.period} days`);

    User notice. An example of notifying the user about the approaching end of subscription event:

    const purchase = gp.payments.getPurchase('VIP');

    const timeBetween = new Date(purchase.expiredAt).getTime() - new Date(gs.serverTime).getTime();
    const daysBetween = timeBetween / (1000 * 3600 * 24);

    if (daysBetween <= 3 && !purchase.subscribed) {
    alert('You have 3 days of subscription left, you have not renewed it');
    }

    Stay in Touch

    Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.

    GamePush Community Telegram: @gs_community.

    For your suggestions e-mail: [email protected]

    We Wish you Success!