# 5. Platform Solution

If the applications will live on the QIYU store, the Online Subsystem QIYU must be enabled. Otherwise, the application will be refused when uploading to QIYU platform.

# 5.1 Initialization

If you want to use the functions of QIYU platform, you must initialize QIYU SDK, please refer to the figure 5.1.

Please write the parameters into Plugins-Online Subsystem QIYU-Platform.

Fig 5.1 Platform Initializaiton

Parameters description:

App ID, App Secret: Please log in to the adventure developer website and click "Release management - Application Management" to create your application. The system will generate a unique App ID and App Secret for each application.

After created the application, press the API to check the App ID and App Secret.

  • Configuration Files

To use Online Subsystem QIYU Plugin, the AndroidEngine.ini should be found at YourProjectDir/Config/Android/, and add or modify the following information below:

[OnlineSubsystem]
DefaultPlatformService=QIYU

[OnlineSubsystemQIYU]
bEnabled=true

Note: Please create a new one if the Android folder or AndroidEngine.ini is not exist.

  • Blueprint
Function name Blueprint Introduction Old Interface(Deprecated)
RequestSDKInit Initialize the SDK.
Output:
Code: Return code
Was Successful:whether successful to call the APIs
Request_InitQiyuSDK()
  • C++

    The APIs is Asynchronous, please refer to the following example:

    static void InitQIYUSDK(FQIYUInitQiyuSDKCompleteResult&& OnSuccess, FQIYUInitQiyuSDKCompleteResult&& OnFailure);
    
    MyActor.h
    
    class AMyActor
    {
    ...
    UFUNCTION()
    		void OnSuccessResults(const FString& Code, bool bWasSuccessful);
    	UFUNCTION()
    		void OnFailureResults(const FString& Code, bool bWasSuccessful);
    	UPROPERTY(BlueprintAssignable)
    		FQIYUInitQiyuSDKCompleteResult OnSuccess;
    	UPROPERTY(BlueprintAssignable)
    		FQIYUInitQiyuSDKCompleteResult OnFailure;...
    
    };
    ----
    MyActor.cpp
    
    void AMyActor::Test()
    {
    OnSuccess.AddDynamic(this,&AMyActor::OnSuccessResults);
    OnFailure.AddDynamic(this,&AMyActor::OnFailureResults);
    UOnlineSubsystemQIYUUtils::InitQIYUSDK(MoveTemp(OnSuccess), MoveTemp(OnFailure));
    }
    
    void AMyActor::OnSuccessResults(const FString& Code, bool bWasSuccessful)
    {
    // todo
    }
    
    void AMyActor::OnFailureResults(const FString& Code, bool bWasSuccessful)
    {
    // todo
    }
    
Return Code Reason
S0000 Success
S9000 System Error
S9001 App ID or App Secret is null
B1009 Fail to get Token
B3021 App ID or App Secret is incorrect

# 5.2 QIYU Account

The following functions is to get the QIYU account information and status.

  • Blueprint
Function name Blueprint Introduction Old Interface(Deprecated)
Is Logged In Request the status of account login
Input:
In Player Controller :Player controller
Output:
True:Account is logged in
False: Account is logged out
RequestisAccountLogin
GetQIYUIdentity Request Account Information:
Input:
In Player Controller :User controller
Output:
Results: Return user information
Error:Error code when fail to call
Was Successful:Whether success to call the API
RequestAccountInfo
  • C++
  1. Request Account Login Status
static bool UKismetSystemLibrary::IsLoggedIn(const APlayerController * SpecificPlayer);
  1. Request Account Information

The APIs is Asynchronous, please refer to the following example:

static void UOnlineSubsystemQIYUUtils::GetQIYUIdentity(APlayerController* InPlayerController, FQIYUIdentityCompleteResult&& OnSuccess, FQIYUIdentityCompleteResult&& OnFailure);
Error Code Reason
S0000 Success
S9000 System Error

QIYU Platform provides authentication APIs, please refer to 4.3 Server to Server Authentication (opens new window).

If you have two separate applications: for example, one single play game and one multiayer game. If you want to achieve deep link between the two applications, user can add the multiplayer game through the single game. Deep link needs to be integrated both in request and target application. Please refer to the following functions:

  • Blueprint
Function name Blueprint Introduction Old Interface(Deprecated)
Deeplink Gain the Deeplink information:
Output:
Result: Return DeepLink information
Code: Return Code
Was Successful: Call the APIs whether success or not
Result node:
RequestDeepLinkParam
LaunchOtherApp Launch to other application:
Input:
Appid : Deeplink APPID
Key : Deeplink Key (Note: The arguments of Key are small letters.)
Value : Deeplink value
RequestLaunchOtherApp
LaunchHome Launch Home:
Input:
Key :The key of launch application(launch the login page when the key value is login)
Value: The value transfer to home
RequestLauchHome
  • C++
  1. Request get Deep Link Information

The APIs is Asynchronous, please refer to the following example:

static void UOnlineSubsystemQIYUUtils::GetDeepLink(FQIYUDeeplinkCompleteResult&& OnSuccess,FQIYUDeeplinkCompleteResult&& OnFailure)
  1. Launch Other APP
static void UOnlineSubsystemQIYUUtils::LaunchOtherApp(const FString& AppId, const FString& Key,const FString& Value)
  1. Launch Home
static void UOnlineSubsystemQIYUUtils::LaunchHome(const FString& Key,const FString& Value)

Launch Home Sample:

Key Value Example
"store" "123456" Launch info page of the application which the appid is 123456
"login" "" Launch login page
"dlc" "123456" Launch the page of DLC which SKU is 123456

Deeplink Return Code

Return Code Reason
S0000 Success
S9000 System Error

# 5.4 Qiyu PlayerPrefs (A requirement to pass our QA Review)

If your APP has player prefs, please use QiyuPrefs. QiyuPrefs is a class that stores player preferences between game sessions - note that this is not related to Cloud Saving. QiyuPrefs also allows applications to retain existing Player preferences after version upgrades, uninstalls and reinstalls. Please remember to call the Prefs_Save() function when exiting the game or when you need it.

Function name Blueprint Introduction
Prefs_GetFloat(FString Key,float DefaultValue) Return the float value of key, if not exit, return defValue
Prefs_GetInt(FString Key,int32 DefaultValue) Return the Int value of key, if not exit, return defValue
Prefs_GetString(FString Key,FString DefaultValue) Return the String value of key, if not exit, return defValue
Prefs_SetFloat(FString Key,float Value) Set the float value of Key
Prefs_SetInt(FString Key,int32 Value) Set the Int value of Key
Prefs_SetString(FString Key,FString Value) Set the String value of Key
Prefs_HasKey(FString Key) If the Key is exit
return True
Otherwise,
return False
Prefs_Save() Save should be called when finishing the modification
Prefs_DeleteAll() Delete all the PlayerPrefs
Prefs_DeleteKey(FString Key) Delete the Key in the PlayerPrefs

Note:

QIYU devices support multiple accounts, so when using the PlayerPrefs solution, the Prefs data should be linked with the Qiyu Account's UserID to achieve the right Prefs data for each user.

# 5.5 In Application Payment

In-APP purchases (IAP) allow users to purchase content including visual products, game currency, additional levels, blood strip and so on. Developer can define the item for Purchase on QIYU platform, and then integrate into the game via SDK APIs. IAP allow users to purchase content including visual products, currencies and so on. Developer can define the item for Purchase on QIYU platform, and then integrate into the application via SDK APIs. IAP only support 'application' but not 'game'.

QIYU purchase is using SMS link to finish the payment with Wechat pay or Ali-pay, the main flow chart is shown below, you can refer to QIYU SDK Demo to finish the IAP integration.

Fig5.5 QIYU items Payment Flow Chart

# 5.5.1 Settings for developer

Please refer to 3.5.1 Define Items for Purchase (opens new window).

# 5.5.2 SDK APIs

Note: the initialization is required before using Payment in Application.

# Initialize QiyuPay

Function Name Blueprint Introduction
Init QIYUPay img Initialize Pay
Output:
Code: Return code
Was Successful: the calling whether is successful or not
  • C++
static void InitQIYUPay(FQIYUInitQiyuPayCompleteResult&&OnSuccess,FQIYUInitQiyuPayCompleteResult&& OnFailure);
Return Code Reason
S0000 Success
S1000 API is not initialized
S9000 System Error
S9001 Parameters Error

# Get Items list

Function Name Blueprint Introduction
Read In APP Purchase Information2 img Get items list:
Input:
Product Identifiers: Items sku array, the all items will be outputted when the array is null
Output:
In APP Offer Information:Return item array including all the informance of items.
img Items information:
offer id:Item SKU
Title:Item title
Regular Price:Item discount price (Minimum Unit is cents)
Numeric Price:Item original price (Minimum Unit is cents)
Dynamic Dields:Item extra attribute, which is mapping type, and the value of ItemType is item type, For example:
img
  • C++
void FTestStoreInterface::Test(UWorld* InWorld, const TArray<FString>& InOffersIds)
{
	auto OnlineSub = Online::GetSubsystem(InWorld, TEXT("QIYU"));
	if (OnlineSub != nullptr)
	{
		if (OnlineSub->GetIdentityInterface().IsValid())
		{
			LocalUserId = OnlineSub->GetIdentityInterface()->GetUniquePlayerId(0);
		}
		if (LocalUserId.IsValid())
		{
			if (OnlineSub->GetStoreV2Interface().IsValid())
			{
				for (const FString& OfferId : InOffersIds)
				{
					RequestOfferIds.Add(FUniqueOfferId(OfferId));
				}				
				OnlineSub->GetStoreV2Interface()->QueryOffersById(*LocalUserId, RequestOfferIds,
			FOnQueryOnlineStoreOffersComplete::CreateRaw(this, &FTestStoreInterface::OnQueryOnlineStoreOffersComplete));
			}
		}
	}
}

Call back function:

void FTestStoreInterface::OnQueryOnlineStoreOffersComplete(bool bWasSuccessful, const TArray<FUniqueOfferId>& OfferIds, const FString& ErrorString)
Return Code Reason
S0000 Success
S1001 API is not initialized
B1001 The result is null
S9000 System Error
S9001 Parameters Error

Note: The unit of items price should be minimum, for example, the price should be set as 12.00 RMB rather than 12 RMB, and developers can exchange the unit by requirement in coding.

# Place Order

Function Name Blueprint Introduction
Place Order img Place Order:
Input:
In Product Identifier: Item sku
Output:
Results: Return order number
Code: Return Code
Was Successful:whether successful to call
  • C++
static void UOnlineSubsystemQIYUUtils::PlaceOrder(const FString& Sku, FQIYUPlaceOrderCompleteResult&& OnSuccess, FQIYUPlaceOrderCompleteResult&& OnFailure)
Return Code Reason
S0000 Success
S1001 API is not initialized
B3007 Authentication code invalid
B4010 Already purchased sku
B4009 A pending order
B1003 authCookie invalid
B3019 Item is not exist
S9000 System Error
S9001 Parameters Error

# Order Result

Function Name Blueprint Introduction
Query Order Result img Order Result:
Input:
In Order Id: The order id will be returned when successful order
output:
Results: Return order details
Code: the return code
Was Successful: Check the result
img Order details:
Output:
Order Id: Order ID
Pay Date: Payment time
Sku: the item sku
Order Status: Order status
Paid Amount: Minimum unit is cent
  • C++
static void UOnlineSubsystemQIYUUtils::QueryOrderResult(const FString& OrderID, FQIYUQueryOrderResultCompleteResult&& OnSuccess, FQIYUQueryOrderResultCompleteResult&& OnFailure)
Return Code Reason
S0000 Success
S1001 API is not initialized
B1003 authCookie invalid
B3019 Item is not exist
B1001 The result is null
S9000 System Error
S9001 Parameters Error

Note: The unit of items price should be minimum, for example, the price should be set as 12.00 RMB rather than 12 RMB, and developers can exchange the unit by requirement in coding.

# History Orders

Function Name Blueprint Introduction
Query History Orders img Check the history order:
Input:
In Sku Id: The item Sku which need to be checked
In Page: Check page
In Page Size: the mount pages
Output:
Results: Return order details array
Was Successful: Check whether successful or not
Code: Return code
img Order details:
Order Id: Order ID
Pay Date: Payment time
Sku: Paid item sku
Order Status: Order status
Paid Amount: Minimum unit is cent
  • C++
static void UOnlineSubsystemQIYUUtils::QueryHistoryOrders(const FString& Sku, int32 CurrentPage, int32 PageSize, FQIYQueryHistoryOrdersCompleteResult&& OnSuccess, FQIYQueryHistoryOrdersCompleteResult&& OnFailure)
Return Code Reason
S0000 Success
S1001 API is not initialized
B1003 authCookie invalid
B3019 Item is not exist
B1001 The result is null
S9000 System Error
S9001 Parameters Error

Note: The unit of items price should be minimum, for example, the price should be set as 12.00 RMB rather than 12 RMB, and developers can exchange the unit by requirement in coding.

# 5.5.3 Payment Result Notification

Please refer to 4.2 Payment Result Notification (opens new window).

# 5.5.4 Testing

Please refer to3.5.4 Test Accounts for IAP (opens new window).

# 5.6 DLC

QIYU Platform provides a way to sell the DLCs.

The DLC can be created, configured and edited on QIYU Developer Portal (opens new window) (opens new window), and integrated into games via SDK APIs. After passing the content review, the DLC can be sold on QIYU store. Users can purchase virtual coins, new missions, maps or media sources in the QIYU store. After entering the game, the new mission will be unlocked and the new resource will be downloaded. you can refer to the following flow chart to finish the DLC integration.

Fig5.6.1 Grant DLC Access

# 5.6.1 Platform Configuration

Please refer to Platform SDK 3.6.1 (opens new window).

# 5.6.2 APIs

SDK provides the following APIs, supports application to verify and download the DLC:

  • Initialization
Function Name Blueprint Introduction
Init QIYUDLC img Initialize DLC
out:
Code: Return Code
Return Code Reason
S0000 Success
S1000 Platform has not been initialized or the initialization is failed
S9000 System error
S9001 Parameter error
  • Get DLC List
Function Name Blueprint Introduction
Get Assets List img Get DLC List
in:
In Cur Page: Page number of paged query
(The page number must bigger than 0, the default page is 1)
In Page Size: Set amount of Add-ons per page
(The number should be larger than 0, default number of DLCs per page is 10)
out:
Results: Return DLC
Code: Return code
img Sku: SKU code
Name: DLC name
Type:DLC type: 1 is Durable. 2 is Consumable
ChargeType: payment type: 0 is Free. 1 is Paid
IconUrl: DLC icon URL
OriginalPrice: Original Price(Unit is cent in RMB)
SalePrice: Sale price (Unit is cent in RMB)
ShortDescription: DLC description
Return Code Reason
S0000 Success
S1001 Not initialized
B1001 The result is null
S9000 System error
S9001 Parameter error
  • Get the status of DLC of current user (Applies to Durable DLC)
Function Name Blueprint Introduction
Get Assets Status img Get the status of DLC of current user (include check entitlement)
in:
In Sku: SKU of DLC
out:
Result: Callback
Code: Return Code
img Sku: SKU
Type:DLC type:
- 1 is Durable.
- 2 is Consumable
// Download status of current DLC
DownloadStatus:
- Available: able to download
- InProgress: downloading
- Downloaded: have already downloaded
- Pause: pause
Purchased: whether purchased or not
FilePath: The path of downloaded DLC
Return Code Reason
S0000 Success
S1001 Not initialized
B1001 The result is null
S9000 System errors
B4015 The entitlement check of Consumable DLC is not supported
B1003 The user account is expire
B4000 Fail to verify the application
B4013 Fail to verify the DLC
  • Download DLC
Function Name Blueprint Introduction
Download Asset img Download DLC (include check entitlement)
in:
In Sku: The SKU of DLC which is going to download
out
Code: Return code
Return Code Reason
S0000 Success
S1001 Not initialized
C1002 Memory space is inadequate
C1005 Resource does not exist
B4015 Not support the entitlement check for consumable DLC
B1003 The user account is expire
B4000 Fail to verify the application
B4013 Fail to verify the DLC
B3033 DLC version is wrong

Tips:

  1. Please call the GetAssetStatus firstly to verify the user purchased or obtaion your DLC legitimately before call the download API. When a purchased DLC is not downloaded or new version is available, the result of downloadStatus is AVAILABLE, then you should remind users to download or update the DLC.
  2. DLCs can be downloaded in the background when users turn off the home page (not exit the application). Downloading is interrupted when the application exits completely. After restarting the application, you may need to check status and decide whether to continue the download. if the download is not complete, please call the DownloadAsset to continue to download.
  • Get download progress
Function Name Blueprint Introduction
Set Download Update Notification img Set Download Update Notification
in:
Notifications: The event point
img Downloaded notification, can be used in every second
SKU: The SKU of downloading DLC
Now: the size of downloaded file, Unit is MB
Total: Target size, Unit is MB
Code: Return code
Path: If success to verify MD5, return the path of file
Return Code Reason
S0000 Success
S1001 Fail to verify MD5
C1002 Fail to write, Memory space might be inadequate
C1003 Receiving data has been interrupted, the network could be disconnected
C1004 Fail to query connection with server
C1006 The DLC is downloading
C1007 Repeat downloading query
C1008 Verifying MD5
C1000 System error
  • Unzip File
Function Name Blueprint Introduction
Unzip File img Quary the unzipped format file
in:
InPath: The path of file which needs to be unzipped
InDest: The target path to unzipped the file
out
FilePaths: List all the paths of unzipped files
Code: Return code
Return Code Reason
S0000 Success to unzip
S1009 A unzipping task in process
C1000 Fail to unzip
  • Launch the DLC's page in the QIYU Store
Function Name Blueprint Introduction
Launch Home img Launch Home:
in:
Key: Launch the key of application
Value: sku value

Sample:

Key Value Introduction
dlc 123456 launch the DLC page which the sku is 123456.

# 5.6.3 Server API

# 5.6.3.1 Order Check

You can use the API to check order, please refer to the 4.1 Order Check (opens new window).

# 5.6.3.2 Payment Result Notification

For the consumable DLC, QIYU platform will return the related result and uid to application server as data flow after the user complete to make a payment. Developers need to deal with those data and return the appropriate response.

For more information, please refer to 4.2 Payment Result Notification (opens new window).

# 5.6.4 Notes

  1. If you choose to submit your add-ons for store review, meaning it will display in the store on an APP detail page, it must meet the store content requirements. For store content guidelines and best practices, please refer to the "Application Review Guidelines (opens new window) (opens new window)". Once launched, it will be available to all users in QIYU Store.
  2. One resource file can be uploaded for each DLC. If a DLC includes multiple files, it needs to be compressed before uploading.
  3. To unzipped the package, the third parts library are recommended.
  4. For the Durable DLC, the entitlement check can be performed via client APIs. For the Consumable DLC, Since users can make repeated purchases, your game background should receive the order payment notice from the QIYU background to deliver the rights and maintain the order status.

# 5.6.5 Testing

Please refer to 3.6.5 Testing (opens new window).

# 5.6.6 DLC Demo

Please refer to the Platform Demo (opens new window), and 3.6.6 DLC Demo (opens new window).