Pico Unreal Platform SDK
Pico_IAP.h
1// Copyright 2022 Pico Technology Co., Ltd.All rights reserved.
2// This plugin incorporates portions of the Unreal® Engine. Unreal® is a trademark or registered trademark of Epic Games, Inc.In the United States of America and elsewhere.
3// Unreal® Engine, Copyright 1998 – 2022, Epic Games, Inc.All rights reserved.
4
5#pragma once
6
7#include "CoreMinimal.h"
8#include "UObject/NoExportTypes.h"
9#include "PPF_Platform.h"
10#include "OnlineSubsystemPico.h"
11#include "Pico_IAP.generated.h"
12
14
15DECLARE_LOG_CATEGORY_EXTERN(PicoIAP, Log, All);
19DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetProductsBySKUDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_ProductArray*, ProductArray);
20DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetViewerPurchasesDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_PurchaseArray*, PurchaseArray);
21DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetNextProductArrayPageDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_ProductArray*, ProductArray);
22DECLARE_DYNAMIC_DELEGATE_TwoParams(FConsumePurchaseDelegate, bool, bIsError, const FString&, ErrorMessage);
23DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetNextPurchaseArrayPageDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_PurchaseArray*, PurchaseArray);
24DECLARE_DYNAMIC_DELEGATE_ThreeParams(FLaunchCheckoutFlowDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_Purchase*, Purchase);
25
37class ONLINESUBSYSTEMPICO_API FPicoIAPInterface
38{
39private:
40
41 FOnlineSubsystemPico& PicoSubsystem;
42
43public:
46
47 FConsumePurchaseDelegate ConsumePurchaseDelegate;
48 FGetProductsBySKUDelegate GetProductsBySKUDelegate;
49 FGetNextProductArrayPageDelegate GetNextProductArrayPageDelegate;
50 FGetViewerPurchasesDelegate GetViewerPurchasesDelegate;
51 FGetNextPurchaseArrayPageDelegate GetNextPurchaseArrayPageDelegate;
52 FLaunchCheckoutFlowDelegate LaunchCheckoutFlowDelegate;
53
65 bool ConsumePurchase(const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
66
79 bool GetProductsBySKU(TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
80
90 bool GetNextProductsArrayPage(UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
91
102 bool GetViewerPurchases(FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
103
113 bool GetNextPurchaseArrayPage(UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
114
131 bool LaunchCheckoutFlow(const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
132
133};
134
149UCLASS()
150class ONLINESUBSYSTEMPICO_API UOnlinePicoIAPFunction : public UBlueprintFunctionLibrary
151{
152 GENERATED_BODY()
153
154public:
155
156
169 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
170 static bool ConsumePurchase(UObject* WorldContextObject,const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
171
183 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
184 static bool GetProductsBySKU(UObject* WorldContextObject, TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
185
196 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
197 static bool GetNextProductsArrayPage(UObject* WorldContextObject, UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
198
210 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
211 static bool GetViewerPurchases(UObject* WorldContextObject, FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
212
223 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
224 static bool GetNextPurchaseArrayPage(UObject* WorldContextObject, UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
225
243 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
244 static bool LaunchCheckoutFlow(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
245};
246
253UCLASS(BlueprintType)
254class ONLINESUBSYSTEMPICO_API UPico_Product : public UObject
255{
256 GENERATED_BODY()
257
258private:
259 FString Description = FString();
260 FString FormattedPrice = FString();
261 FString Price = FString();
262 FString Currency = FString();
263 FString Name = FString();
264 FString SKU = FString();
265public:
266 void InitParams(ppfProduct* InppfProductHandle);
267
268 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
269 FString GetDescription();
270
271 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
272 FString GetFormattedPrice();
273
274 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
275 FString GetPrice();
276
277 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
278 FString GetCurrency();
279
280 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
281 FString GetName();
282
283 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
284 FString GetSKU();
285};
286
290UCLASS(BlueprintType)
291class ONLINESUBSYSTEMPICO_API UPico_ProductArray : public UObject
292{
293 GENERATED_BODY()
294
295private:
296
297 UPROPERTY()
298 TArray<UPico_Product*> ProductArray;
299 int32 Size = 0;
300 bool bHasNextPage;
301 FString NextPageParam = FString();
302
303public:
304 void InitParams(ppfProductArray* InppfProductArrayHandle);
305
306 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
307 UPico_Product* GetElement(int32 Index);
308
309 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
310 FString GetNextPageParam();
311
312 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
313 int32 GetSize();
314
315 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
316 bool HasNextPage();
317};
318
322UCLASS(BlueprintType)
323class ONLINESUBSYSTEMPICO_API UPico_Purchase : public UObject
324{
325 GENERATED_BODY()
326
327private:
328 int32 ExpirationTime = 0;
329 int32 GrantTime = 0;
330 FString ID = FString();
331 FString SKU = FString();
332public:
333 void InitParams(ppfPurchase* InppfPurchaseHandle);
334
335 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
336 int32 GetExpirationTime();
337
338 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
339 int32 GetGrantTime();
340
341 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
342 FString GetID();
343
344 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
345 FString GetSKU();
346};
347
351UCLASS(BlueprintType)
352class ONLINESUBSYSTEMPICO_API UPico_PurchaseArray : public UObject
353{
354 GENERATED_BODY()
355
356private:
357
358 UPROPERTY()
359 TArray<UPico_Purchase*> PurchaseArray;
360 int32 Size = 0;
361 bool bHasNextPage;
362 FString NextPageParam = FString();
363
364public:
365 void InitParams(ppfPurchaseArray* InppfPurchaseArrayHandle);
366
367 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
368 UPico_Purchase* GetElement(int32 Index);
369
370 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
371 FString GetNextPageParam();
372
373 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
374 int32 GetSize();
375
376 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
377 bool HasNextPage();
378};
OnlineSubsystemPico class inherited from FOnlineSubsystemImpl(Unreal Engine)
Definition: OnlineSubsystemPico.h:44
PicoIAPInterface class.
Definition: Pico_IAP.h:38
OnlinePicoIAP Blueprint Function class.
Definition: Pico_IAP.h:151
Definition: Pico_IAP.h:292
Definition: Pico_IAP.h:255
Definition: Pico_IAP.h:353
Definition: Pico_IAP.h:324