Please Select Your Location

Thailand
Australia
Österreich
België
Canada
Canada - Français
中国
Česká republika
Denmark
Deutschland
France
HongKong
Iceland
India
Ireland
Italia
日本
Korea
Latvija
Lietuva
Lëtzebuerg
Malaysia
Malta
Mexico
Nederland
New Zealand
Norge
Polska
Portugal
Russia
Saudi Arabia
Singapore
Southeast Asia
España
Suisse
Suomi
Sverige
台灣
Ukraine
United Kingdom
United States
Việt Nam
المملكة العربية السعودية (Arabic)

Example usage

The following example highlights how a developer might use the VIVEPORT In-App Purchase API in their title.

Before you begin:

  • Make sure you have a VIVEPORT ID and key for your title before trying to implement any of the API functions.
  • Make sure you have an API key before implementing any of the IAP API functions.
  • Keep in mind that prices must be set in each billable currency. Developers are responsible for managing their own exchange rates.

  1. Call the Top Level API using Viveport.Api.Init to initialize the VIVEPORT SDK. For Unity developers, this is typically called as Monobehavior Start() .
  2. Call IAPurchase.IsReady() to initialize the Session Token API.
  3. Do any of the following:
    • Call Request()[NEW] to request the price of an IAP item by item name pchItemName .
    • Call Purchase() to purchase item specified by pchPurchaseId .
    • Call Query() if the end user has already purchased the item specified by pchPurchaseId . Call without a pchPurchaseID to get an entire list of purchases.
    • Call GetBalance() to get the balance of the end user’s wallet.
    • Call RequestSubscription() to generate a subscription ID to subscribe to a plan that has not been specified in the VIVEPORT Developer Console.
    • Call RequestSubscriptionWithPlanID() to subscribe to a plan in the VIVEPORT Developer Console that has a Plan ID.
    • Call Subscribe() to subscribe to a plan with a SubscriptionID from RequestSubscription() or RequestSubscriptionWithPlanID() .
    • Call QuerySubscription() to check subscription status using the subscription ID received from the callback of Subscribe() . If pchSubscriptionId is null, the callback will retrieve all subscriptions as an array.
    • Call QuerySubscriptionList() to check all subscriptions as an array.
    • Call CancelSubscription() to cancel the subscription specified by pchSubscriptionId .
  4. Call Viveport.Api.Shutdown to release VIVEPORT SDK resources when no longer needed. In Unity, this is typically either in MonoBehavior OnDestroy() or before Application.Quit() .