How to allow a user to change a subscription plan

Note
If you want to allow users to change the plan in your project, you need to set up the correct operation of the payment interface. To do this, contact your Customer Success Manager or email to csm@xsolla.com.
You can allow users to change the subscription plan in the current or next period, and also allow them to change the plan several times a day.

How it works

  • When choosing a new plan, a refund is made to the user’s balance for the unused period of the current subscription.
  • Payment for the new subscription plan is made entirely from the user’s balance. If their balance is insufficient, an additional payment is made by any of the payment methods allowed in the project.
  • When changing the plan, funds are debited immediately after payment is confirmed, even if the project is configured to change the plan from the next billing period.
  • If the currency of the new plan is different from the currency of the current plan, the purchase of the new plan will be done with a currency conversion.

Plan change is not possible if:
  • the user already has an active subscription with the plan that the current plan is changing to
  • the subscription that the user wants to change is not in the Active status
  • the subscription plan that the user wants to change is of the Lifetime plan type: such a subscription can only be canceled within the specified refund period
Note
If plan groups are configured in your project, plan change can only be done within a group. For more information about how groups work, see How to set up subscription-based products and plan groups instructions.

How to get it

  1. Open your project in Publisher Account.
  2. Click Subscriptions in the sidebar and go to the Settings section.
  3. In the Changing plan section, set the Ability to choose a different plan toggle to On.
  4. Plan changes are allowed from the next period by default. To allow changing the plan in the current period, select Now. If you select this option, the plan changes immediately after payment is confirmed.
  5. To allow plan changes more than once a day, set the toggle Ability to choose a different plan several times on the same day to On.
  6. When opening the payment interface, use:

Opening the payment UI via the server-side Create token API call

  1. Get a token to open the payment UI by passing the following to the method:
    • change_plan value in the purchase.subscription.operation parameter.
    • ID of the new plan in the purchase.subscription.plan_id parameter.
    • Subscription-based product ID in the purchase.subscription.product_id parameter if you are using subscription-based products. To get it, contact your Customer Success Manager or email to csm@xsolla.com.
  2. Open the payment interface in one of the following ways:

Opening the payment UI on the subscription management page using the client-side API call

If Xsolla Login is configured in your project, you can use the client-side API call to get a link to open the payment interface. The link returned in the response allows you to open the payment UI on the subscription management page, where users can select an active subscription and change it.

To do this, on the client side of your application, implement receiving a link to the payment interface using an HTTP POST request: https://subscriptions.xsolla.com​/api/user/v1/projects/{project_id}/subscriptions/manage. The request must contain an Authorization: Bearer <client_user_jwt> header, where <client_user_jwt> is user’s JSON Web Token (JWT) — a unique, Base64-encoded token encoded according to the Base64 standard. To get the token:

Specify the project ID as the projectId path parameter. You can find this parameter in your Publisher Account next to the name of the project. Specify country as the query parameter — the two-letter designation of the user’s country according to the ISO 3166-1 alpha-2 standard. Affects the choice of locale and currency. If this parameter is not passed, the country is determined by the user’s IP address.

Pass additional parameters for customization if needed.

Request body parameters:

ParameterTypeDescription
plan_external_id
stringRequired. The external ID of the subscription plan. You can find it in the Publisher Account > Subscriptions > Subscription Plans section.
settings
objectCustom project settings (object).
settings.ui
objectInterface settings (object).
settings.ui.size
stringPayment UI size. Can be:
  • small: the least possible size of the payment UI. Use this value when the window size is strictly limited (dimensions: 620 x 630 px)
  • medium: recommended size. Use this value to display the payment UI in a lightbox (dimensions: 740 x 760 px)
  • large: the optimal size for displaying the payment UI in a new window or tab (dimensions: 820 x 840 px)
settings.ui.theme
stringPayment UI theme. Can be default, default_dark or custom theme ID.
settings.ui.version
stringDevice type. Can be desktop (default) or mobile.
settings.ui.desktop
objectInterface settings for the desktop version (object).
settings.ui.desktop.header
objectHeader settings (object).
settings.ui.desktop.header.close_button
booleanWhether to show a Close button in Pay Station desktop. The button closes Pay Station and redirects the user to the URL specified in the settings.return_url parameter. false by default.
settings.ui.desktop.header.is_visible
booleanWhether to show the header in the payment UI.
settings.ui.desktop.header.is_visible.type
stringHeader appearance. Can be compact (in which case the game name and user ID will not be shown in the header) or normal.
booleanIf true, the header shows your logo (first provide the image to your Customer Success Manager).
settings.ui.desktop.header.visible_name
booleanWhether to show the project name in the header.
settings.ui.desktop.header.type
stringHow to show the header. Can be compact (hides project name and user ID) or normal (default).
settings.ui.mobile.mode
stringA user can only pay using their saved payment methods. Can be saved_accounts.
booleanWhether to hide the footer in the mobile version of the payment UI.
settings.ui.mobile.header.close_button
booleanWhether to show a Close button in Pay Station mobile. The button closes Pay Station and redirects the user to the URL specified in the settings.return_url parameter. false by default.
settings.ui.mode
stringInterface mode in Pay Station. Can be user_account only: The header contains only the account navigation menu, and the user cannot select a product or make a payment. This mode is only available on the desktop.
settings.currency
stringPreferred payment currency. Three-letter ISO 4217 currency code.
settings.external_id
stringTransaction ID in the game. Has to be unique for each user payment.
settings.payment_method
integerPayment method ID. You can get the list of payment method IDs in Publisher Account.
settings.return_url
stringPage to redirect the user to after payment. Parameters user_id, foreigninvoice, invoice_id and status will be automatically added to the link.
settings.redirect_policy
objectRedirect policy settings (object).
settings.redirect_policy.redirect_conditions
stringA payment status that redirects the user to a return URL after making a payment. Can be none, successful, successful_or_canceled, or any.
settings.redirect_policy.delay
integerDelay (in seconds) after which a user is automatically redirected to the return URL.
settings.redirect_policy.status_for_manual_redirection
stringA payment status that redirects the user to a return URL after making a payment. Can be none, successful, successful_or_canceled, or any.
settings.redirect_policy.redirect_button_caption
stringText on the button for manual redirection.
Request example:
Copy
Full screen
Small screen
curl -X 'POST' \
'https://subscriptions.xsolla.com/api/user/v1/projects/{project_id}/subscriptions/manage?country=RU  ' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer client_user_jwt'
{
  "settings": {
    "ui": {
      "size": "large",
      "theme": "string",
      "version": "desktop",
      "desktop": {
        "header": {
          "is_visible": true,
          "visible_logo": true,
          "visible_name": true,
          "type": "compact",
          "close_button": true
        }
      },
      "mobile": {
        "mode": "saved_accounts",
        "footer": {
          "is_visible": true
        },
        "header": {
          "close_button": true
        }
      },
      "license_url": "string",
      "mode": "user_account",
      "user_account": {
        "history": {
          "enable": true,
          "order": 1
        },
        "payment_accounts": {
          "enable": true,
          "order": 1
        },
        "info": {
          "enable": true,
          "order": 1
        },
        "subscriptions": {
          "enable": true,
          "order": 1
        }
      }
    },
    "currency": "str",
    "locale": "st",
    "external_id": "string",
    "payment_method": 1,
    "return_url": "string",
    "redirect_policy": {
      "redirect_conditions": "none",
      "delay": 0,
      "status_for_manual_redirection": "none",
      "redirect_button_caption": "string"
    }
  }
}

Response example:

Copy
Full screen
Small screen
{
  "link_to_ps": "https://secure.xsolla.com/paystation2/?access_token=<access_token>"
}
Was this article helpful?
Thank you!
Is there anything we can improve? Message
We’re sorry to hear that
Please explain why this article wasn’t helpful to you. Message
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.
Last updated: September 30, 2024

Found a typo or other text error? Select the text and press Ctrl+Enter.

Report a problem
We always review our content. Your feedback helps us improve it.
Provide an email so we can follow up
Thank you for your feedback!