创建目录UI

创建目录UI有三种方式:

使用自有界面

在您自己的界面创建目录时,可使用:

注:
您也可以使用SDK库在自有界面中实现目录。现成的库提供可直接使用的数据结构和方法来与艾克索拉API交互,便于将艾克索拉产品集成到您的项目中。

艾克索拉登录管理器和客户端侧API调用

要实现目录:

  1. 使用客户端方法获取订阅计划列表:
  2. 实现在界面中显示收到的计划列表。

按产品获取订阅计划的客户端侧方法

在应用程序的的客户端侧,请使用HTTP get请求实现获取订阅计划列表:https://subscriptions.xsolla.com​/api/user/v1/projects/{project_id}/products/{​​productId}/plans

请求必须包含Authorization: Bearer <client_user_jwt>头,其中<client_user_jwt>是用户的JSON Web令牌(JWT),它是一个根据Base64标准编码的Base64编码令牌。要获取该令牌:

以路径参数的形式指定:

  • projectId — 项目ID。可在发布商帐户项目名称旁边找到该参数。
  • productID — 基于订阅的产品ID。要获取该值,请联系您的帐户经理。

以请求参数的形式指定:

参数类型描述
plan_id
array of integers计划ID。
plan_external_id
array of strings计划的外部ID。可在发布商帐户中的订阅 > 订阅计划 > 您的计划部分找到或通过列示所有计划API调用找到。
limit
integer页面上元素数量的限制。默认显示15项。
offset
integer元素编号,从该元素开始生成列表。默认从0开始数。
locale
string用两个小写字母表示的界面语言。接受ISO 639-1值。如未传入此值,则语言由用户IP地址决定。
country
string用于识别用户国家/地区的ISO 3166-1 alpha-2两字母代码。此参数影响区域位置和货币的选择。如未传入此参数,则国家/地区由用户的IP地址决定。
Copy
Full screen
Small screen

    curl -X 'GET' \
    'https://subscriptions.xsolla.com​/api/user/v1/projects/{project_id}/products/{​​productId}/plans?country=RU  ' \
      -H 'accept: application/json' \
      -H 'Authorization: Bearer client_user_jwt'

    Copy
    Full screen
    Small screen

    {
      "items": [
        {
          "plan_id": 54321,
          "plan_external_id": "PlanExternalId",
          "plan_group_id": "TestGroupId",
          "plan_type": "all",
          "plan_name": "Localized plan name",
          "plan_description": "Localized plan description",
          "plan_start_date": "2021-04-11T13:51:02+03:00",
          "plan_end_date": "2031-04-11T13:51:02+03:00",
          "trial_period": 7,
          "period": {
            "value": 1,
            "unit": "month"
          },
          "charge": {
            "amount": 4.99,
            "setup_fee": 0.99,
            "currency": "USD"
          },
          "promotion": {
            "promotion_charge_amount": 3.99,
            "promotion_remaining_charges": 3
          }
        }
      ],
      "has_more": false
    }
    

    获取订阅计划列表的客户端侧方法

    在应用程序的的客户端侧,请使用HTTP GET请求实现获取订阅计划列表:https://subscriptions.xsolla.com​/api/user/v1/projects/{project_id}/plans

    请求必须包含Authorization: Bearer <client_user_jwt>头,其中<client_user_jwt>是用户的JSON Web令牌(JWT),它是一个根据Base64标准编码的Base64编码令牌。要获取该令牌:

    指定项目ID作为projectId路径参数。可在发布商帐户项目名称旁边找到该参数。

    以请求参数的形式指定:

    参数类型描述
    plan_id
    array of integers计划ID。
    plan_external_id
    array of strings计划的外部ID。可在发布商帐户中的订阅 > 订阅计划 > 您的计划部分找到或通过列示所有计划API调用找到。
    limit
    integer页面上元素数量的限制。默认显示15项。
    offset
    integer元素编号,从该元素开始生成列表。默认从0开始数。
    locale
    string用两个小写字母表示的界面语言。接受ISO 639-1值。如未传入此值,则语言由用户IP地址决定。
    country
    string用于识别用户国家/地区的ISO 3166-1 alpha-2两字母代码。此参数影响区域位置和货币的选择。如未传入此参数,则国家/地区由用户的IP地址决定。
    Copy
    Full screen
    Small screen

      curl -X 'GET' \
      'https://subscriptions.xsolla.com​/api/user/v1/projects/{project_id}/plans?country=RU  ' \
        -H 'accept: application/json' \
        -H 'Authorization: Bearer client_user_jwt'
        

      Copy
      Full screen
      Small screen

      {
        "items": [
          {
            "plan_id": 54321,
            "plan_external_id": "PlanExternalId",
            "plan_group_id": "TestGroupId",
            "plan_type": "all",
            "plan_name": "Localized plan name",
            "plan_description": "Localized plan description",
            "plan_start_date": "2021-04-11T13:51:02+03:00",
            "plan_end_date": "2031-04-11T13:51:02+03:00",
            "trial_period": 7,
            "period": {
              "value": 1,
              "unit": "month"
            },
            "charge": {
              "amount": 4.99,
              "setup_fee": 0.99,
              "currency": "USD"
            },
            "promotion": {
              "promotion_charge_amount": 3.99,
              "promotion_remaining_charges": 3
            }
          }
        ],
        "has_more": false
      }
      

      使用艾克索拉支付中心

      目录在支付UI中的创建方式取决于项目的身份认证设置:

      自有授权系统

      如应用程序使用您自己的授权系统:

      1. 实现通过服务器获取令牌API调用获取令牌。在请求的user.iduser.email参数中传入用户信息。
      2. 实现在Pay Station Embediframe新窗口中打开支付UI。
      Copy
      Full screen
      Small screen

      {
          "user": {
              "id": {
                  "value": "1234567",
                  "hidden": true
              }
          },
          "settings": {
              "project_id": 123456,
              "language": "en",
              "currency": "USD"
          }
      }
      

      艾克索拉登录管理器

      如项目中设置了艾克索拉登录管理器:

      在应用程序的的客户端侧,请使用HTTP POST请求实现支付UI的打开:https://subscriptions.xsolla.com​/api/user/v1/projects/{project_id}/subscriptions/buy

      请求必须包含Authorization: Bearer <client_user_jwt>头,其中<client_user_jwt>是用户的JSON Web令牌(JWT),它是一个根据Base64标准编码的Base64编码令牌。要获取该令牌:

      指定项目ID作为projectId路径参数。可在发布商帐户项目名称旁边找到该参数。

      指定country作为请求参数,值为符合ISO 3166-1 alpha-2标准的用户国家/地区两字母代码。该参数影响区域位置和货币。如未传入该参数,则国家/地区由用户的IP地址决定。

      请求正文参数:

      参数类型描述
      plan_external_id
      string必需。订阅计划的外部ID。可在发布商帐户 > 订阅 > 订阅计划部分找到。
      settings
      object带有自定义项目设置的对象。
      settings.ui
      object带有界面设置相关数据的对象。
      settings.ui.size
      string支付UI的大小。此参数可拥有以下值之一,具体取决于支付UI的所需大小:
      • small:支付UI支持的最小尺寸。当窗口大小严格受限时,请使用此值(尺寸:620 x 630 px)
      • medium:支付UI的推荐大小。使用此值可以在灯箱中显示支付UI(尺寸:740 x 760 px)
      • large:在新窗口或者选项卡中显示支付UI的最佳大小(尺寸:820 x 840 px)
      settings.ui.theme
      string支付UI的外观主题。可以是defaultdefault_dark
      settings.ui.version
      string设备类型。可以是desktop(默认)或mobile
      settings.ui.desktop
      object带有对桌面版本有效的界面设置相关数据的对象。
      settings.ui.desktop.header
      object带有标题设置相关数据的对象。
      settings.ui.desktop.header.close_button
      boolean是否在支付中心桌面端显示关闭按钮。该按钮将关闭支付中心并将用户重定向到settings.return_url参数中指定的URL。默认为false
      settings.ui.desktop.header.is_visible
      boolean标题在支付UI上是否可见。
      settings.ui.desktop.header.is_visible.type
      string标题外观。可以是compact(游戏名和用户ID不在标题中显示)或normal
      boolean如果为true,标头中将显示Logo(请先把Logo文件提供给您的项目经理)。
      settings.ui.desktop.header.visible_name
      boolean标题中是否显示项目名称。
      settings.ui.desktop.header.type
      string如何显示标题。可以是compact(隐藏项目名称和用户ID)或normal(默认)。
      settings.ui.mobile.mode
      string用户仅可以通过他们已保存的付款方式进行付款。可以为saved_accounts
      boolean是否在移动版本的支付UI中隐藏或显示脚注。
      settings.ui.mobile.header.close_button
      boolean是否在支付中心移动版中显示关闭按钮。该按钮将关闭支付中心并将用户重定向到settings.return_url参数中指定的URL。默认为false
      settings.ui.license_url
      stringEULA的链接。
      settings.ui.mode
      string支付中心中的界面模式。只能是user_account:标头仅包含帐户导航菜单,而没有用于选择产品或进行付款的任何选项。此模式仅在桌面版中可用。
      settings.ui.user_account
      object对象以及有关用户账号的数据。
      settings.ui.user_account.history
      object历史记录子菜单。
      settings.ui.user_account.history.enable
      integer该部分是否应在支付UI的下拉菜单中显示。可以是truefalse。如未传入此参数,则不显示该部分。
      settings.ui.user_account.history.order
      integer该部分在支付界面下拉菜单中的位置。
      settings.ui.user_account.info
      object我的帐户页面。
      settings.ui.user_account.info.order
      integer该部分在支付UI下拉菜单中的位置。
      settings.ui.user_account.info.enable
      boolean该部分是否应在支付UI的下拉菜单中显示。可以是truefalse。如未传入此参数,则不显示该部分。
      settings.ui.user_account.payment_accounts
      object我的支付帐户子菜单。
      settings.ui.user_account.payment_accounts.order
      integer该部分在支付UI下拉菜单中的位置。
      settings.ui.user_account.payment_accounts.enable
      boolean是否显示子菜单。可以是truefalse。如未传入此参数,则显示该部分。
      settings.ui.user_account.subscriptions
      object管理订阅子菜单。
      settings.ui.user_account.subscriptions.enable
      boolean是否显示子菜单。可以是truefalse。如未传入此参数,则显示该部分。
      settings.ui.user_account.subscriptions.order
      integer该部分在支付UI下拉菜单中的位置。
      settings.currency
      string首选支付币种。参照ISO 4217标准的三字母货币代码。
      settings.external_id
      string游戏中的交易ID。值对于每个用户付款必须唯一。
      settings.payment_method
      integer支付方式ID。要获取支付方式ID列表,您可以前往发布商帐户,或使用获取支付方式API调用。
      settings.return_url
      string用户在支付过后重定向到的页面。参数user_idforeigninvoiceinvoice_idstatus将自动添加到链接中。
      settings.redirect_policy
      object重定向政策设置(对象)。
      settings.redirect_policy.redirect_conditions
      string支付后将用户重定向到返回URL的支付状态。可以是nonesuccessfulsuccessful_or_canceledany
      settings.redirect_policy.delay
      integer延迟时间(单位为秒),经过该时间后用户将自动重定向至返回URL。
      settings.redirect_policy.status_for_manual_redirection
      string支付后将用户重定向到返回URL的支付状态。可以是nonesuccessfulsuccessful_or_canceledany
      settings.redirect_policy.redirect_button_caption
      string手动重定向按钮上的文字。

      如需要,传入自定义补充参数

      Copy
      Full screen
      Small screen

        curl -X 'POST' \
        'https://subscriptions.xsolla.com​/api/user/v1/projects/{project_id}/subscriptions/buy?country=RU  ' \
          -H 'accept: application/json' \
          -H 'Authorization: Bearer client_user_jwt'
        
        {
          "plan_external_id": "PlanExternalId",
          "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": "string",
            "locale": "string",
            "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"
            }
          }
        }

        Copy
        Full screen
        Small screen

          {
            "link_to_ps": "https://secure.xsolla.com/paystation2/?access_token=<access_token>"
          }

          在艾克索拉支付中心里显示订阅目录的示例:

          使用艾克索拉建站器

          通过艾克索拉建站器您可以创建并设置自己的网站来销售订阅。方法是使用Web商店模板来创建网站。关于设置角色的详细信息,请参阅在有用户认证功能的Web商店中销售说明。

          您的进度
          感谢您的反馈!
          上次更新时间: 2023年2月14日

          发现了错别字或其他内容错误? 请选择文本,然后按Ctrl+Enter。

          报告问题
          我们非常重视内容质量。您的反馈将帮助我们做得更好。
          请留下邮箱以便我们后续跟进
          感谢您的反馈!