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:
44 FPicoIAPInterface(FOnlineSubsystemPico& InSubsystem);
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
78 bool GetProductsBySKU(TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
79
89 bool GetNextProductsArrayPage(UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
90
101 bool GetViewerPurchases(FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
102
112 bool GetNextPurchaseArrayPage(UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
113
130 bool LaunchCheckoutFlow(const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
131
132};
133
148UCLASS()
149class ONLINESUBSYSTEMPICO_API UOnlinePicoIAPFunction : public UBlueprintFunctionLibrary
150{
151 GENERATED_BODY()
152
153public:
154
155
168 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
169 static bool ConsumePurchase(UObject* WorldContextObject,const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
170
182 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
183 static bool GetProductsBySKU(UObject* WorldContextObject, TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
184
195 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
196 static bool GetNextProductsArrayPage(UObject* WorldContextObject, UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
197
209 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
210 static bool GetViewerPurchases(UObject* WorldContextObject, FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
211
222 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
223 static bool GetNextPurchaseArrayPage(UObject* WorldContextObject, UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
224
242 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
243 static bool LaunchCheckoutFlow(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
244};
245
252UCLASS(BlueprintType)
253class ONLINESUBSYSTEMPICO_API UPico_Product : public UObject
254{
255 GENERATED_BODY()
256
257private:
258 FString Description = FString();
259 FString FormattedPrice = FString();
260 FString Price = FString();
261 FString Currency = FString();
262 FString Name = FString();
263 FString SKU = FString();
264public:
265 void InitParams(ppfProduct* InppfProductHandle);
266
267 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
268 FString GetDescription();
269
270 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
271 FString GetFormattedPrice();
272
273 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
274 FString GetPrice();
275
276 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
277 FString GetCurrency();
278
279 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
280 FString GetName();
281
282 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
283 FString GetSKU();
284};
285
289UCLASS(BlueprintType)
290class ONLINESUBSYSTEMPICO_API UPico_ProductArray : public UObject
291{
292 GENERATED_BODY()
293
294private:
295
296 UPROPERTY()
297 TArray<UPico_Product*> ProductArray;
298 int32 Size = 0;
299 bool bHasNextPage;
300 FString NextPageParam = FString();
301
302public:
303 void InitParams(ppfProductArray* InppfProductArrayHandle);
304
305 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
306 UPico_Product* GetElement(int32 Index);
307
308 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
309 FString GetNextPageParam();
310
311 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
312 int32 GetSize();
313
314 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
315 bool HasNextPage();
316};
317
321UCLASS(BlueprintType)
322class ONLINESUBSYSTEMPICO_API UPico_Purchase : public UObject
323{
324 GENERATED_BODY()
325
326private:
327 int32 ExpirationTime = 0;
328 int32 GrantTime = 0;
329 FString ID = FString();
330 FString SKU = FString();
331public:
332 void InitParams(ppfPurchase* InppfPurchaseHandle);
333
334 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
335 int32 GetExpirationTime();
336
337 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
338 int32 GetGrantTime();
339
340 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
341 FString GetID();
342
343 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
344 FString GetSKU();
345};
346
350UCLASS(BlueprintType)
351class ONLINESUBSYSTEMPICO_API UPico_PurchaseArray : public UObject
352{
353 GENERATED_BODY()
354
355private:
356
357 UPROPERTY()
358 TArray<UPico_Purchase*> PurchaseArray;
359 int32 Size = 0;
360 bool bHasNextPage;
361 FString NextPageParam = FString();
362
363public:
364 void InitParams(ppfPurchaseArray* InppfPurchaseArrayHandle);
365
366 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
367 UPico_Purchase* GetElement(int32 Index);
368
369 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
370 FString GetNextPageParam();
371
372 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
373 int32 GetSize();
374
375 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
376 bool HasNextPage();
377};
PicoIAPInterface class.
Definition: Pico_IAP.h:38
bool GetProductsBySKU(TArray< FString > ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate)
Gets a list of purchasable products in the current app.
bool ConsumePurchase(const FString &SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate)
Records the order fulfillment result for a consumable.
bool GetNextPurchaseArrayPage(UPico_PurchaseArray *InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate)
Gets the next page of purchased products.
bool LaunchCheckoutFlow(const FString &SKU, const FString &Price, const FString &Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate)
Launches the checkout flow to pay for a product.
bool GetNextProductsArrayPage(UPico_ProductArray *InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate)
Gets the next page of purchasable products.
bool GetViewerPurchases(FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate)
Gets a list of purchased products for a user.
OnlinePicoIAP Blueprint Function class.
Definition: Pico_IAP.h:150
Definition: Pico_IAP.h:291
Definition: Pico_IAP.h:254
Definition: Pico_IAP.h:352
Definition: Pico_IAP.h:323