PICO Unreal Platform SDK
Pico_IAP.h
1/*******************************************************************************
2Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
3
4NOTICE:All information contained herein is, and remains the property of
5PICO Technology Co., Ltd. The intellectual and technical concepts
6contained herein are proprietary to PICO Technology Co., Ltd. and may be
7covered by patents, patents in process, and are protected by trade secret or
8copyright law. Dissemination of this information or reproduction of this
9material is strictly forbidden unless prior written permission is obtained from
10PICO Technology Co., Ltd.
11*******************************************************************************/
12// 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.
13// Unreal® Engine, Copyright 1998 – 2022, Epic Games, Inc.All rights reserved.
14
15#pragma once
16
17#include "CoreMinimal.h"
18#include "UObject/NoExportTypes.h"
19#include "PPF_Platform.h"
20#include "OnlineSubsystemPico.h"
21#include "Pico_IAP.generated.h"
22
24
25DECLARE_LOG_CATEGORY_EXTERN(PicoIAP, Log, All);
29DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetProductsBySKUDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_ProductArray*, ProductArray);
30DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetViewerPurchasesDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_PurchaseArray*, PurchaseArray);
31DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetNextProductArrayPageDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_ProductArray*, ProductArray);
32DECLARE_DYNAMIC_DELEGATE_TwoParams(FConsumePurchaseDelegate, bool, bIsError, const FString&, ErrorMessage);
33DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetNextPurchaseArrayPageDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_PurchaseArray*, PurchaseArray);
34DECLARE_DYNAMIC_DELEGATE_ThreeParams(FLaunchCheckoutFlowDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_Purchase*, Purchase);
35DECLARE_DYNAMIC_DELEGATE_ThreeParams(FLaunchCheckoutFlow_V2Delegate, bool, bIsError, const FString&, ErrorMessage, UPico_Purchase*, Purchase);
36
48class ONLINESUBSYSTEMPICO_API FPicoIAPInterface
49{
50private:
51
52 FOnlineSubsystemPico& PicoSubsystem;
53
54public:
55 FPicoIAPInterface(FOnlineSubsystemPico& InSubsystem);
57
58 FConsumePurchaseDelegate ConsumePurchaseDelegate;
59 FGetProductsBySKUDelegate GetProductsBySKUDelegate;
60 FGetNextProductArrayPageDelegate GetNextProductArrayPageDelegate;
61 FGetViewerPurchasesDelegate GetViewerPurchasesDelegate;
62 FGetNextPurchaseArrayPageDelegate GetNextPurchaseArrayPageDelegate;
63 FLaunchCheckoutFlowDelegate LaunchCheckoutFlowDelegate;
64 FLaunchCheckoutFlow_V2Delegate LaunchCheckoutFlow_V2Delegate;
65
78 bool ConsumePurchase(const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
79
92 bool GetProductsBySKU(TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
93
104 bool GetNextProductsArrayPage(UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
105
117 bool GetViewerPurchases(FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
118
129 bool GetNextPurchaseArrayPage(UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
130
145 bool LaunchCheckoutFlow(const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
146
162 bool LaunchCheckoutFlowV2(const FString& SKU, const FString& Price, const FString& Currency, const FString& OuterId, FLaunchCheckoutFlow_V2Delegate InLaunchCheckoutFlow_V2Delegate);
163
164};
165
180UCLASS()
181class ONLINESUBSYSTEMPICO_API UOnlinePicoIAPFunction : public UBlueprintFunctionLibrary
182{
183 GENERATED_BODY()
184
185public:
186
187
201 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
202 static bool ConsumePurchase(UObject* WorldContextObject, const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
203
216 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
217 static bool GetProductsBySKU(UObject* WorldContextObject, TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
218
230 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
231 static bool GetNextProductsArrayPage(UObject* WorldContextObject, UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
232
245 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
246 static bool GetViewerPurchases(UObject* WorldContextObject, FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
247
259 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
260 static bool GetNextPurchaseArrayPage(UObject* WorldContextObject, UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
261
277 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
278 static bool LaunchCheckoutFlow(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
279
296 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
297 static bool LaunchCheckoutFlowV2(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, const FString& OuterId, FLaunchCheckoutFlow_V2Delegate InLaunchCheckoutFlow_V2Delegate);
298};
299
308UCLASS(BlueprintType)
309class ONLINESUBSYSTEMPICO_API UPico_Product : public UObject
310{
311 GENERATED_BODY()
312
313private:
314 FString Description = FString();
315 FString DetailDescription = FString();
316 FString Price = FString();
317 FString Currency = FString();
318 FString Name = FString();
319 FString SKU = FString();
320 FString Icon = FString();
323 EPeriodType TrialPeriodUnit = EPeriodType::Unknown;
324 int32 TrialPeriodValue = -1;
325 FString OuterId = FString();
326 FString OriginalPrice = FString();
327 bool bIsContinuous = false;
328
329public:
330 void InitParams(ppfProduct* InppfProductHandle);
331
333 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
334 FString GetDescription();
335
337 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
338 FString GetDetailDescription();
339
341 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
342 FString GetPrice();
343
345 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
346 FString GetFormattedPrice();
347
349 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
350 FString GetCurrency();
351
353 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
354 FString GetName();
355
357 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
358 FString GetSKU();
359
361 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
362 FString GetIcon();
363
365 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
366 EAddonsType GetAddonsType();
367
369 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
370 EPeriodType GetPeriodType();
371
373 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
374 EPeriodType GetTrialPeriodUnit();
375
377 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
378 int32 GetTrialPeriodValue();
379
381 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
382 FString GetOuterId();
383
387 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
388 FString GetOriginalPrice();
389
391 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
392 bool GetIsContinuous();
393
394};
395
401UCLASS(BlueprintType)
402class ONLINESUBSYSTEMPICO_API UPico_ProductArray : public UObject
403{
404 GENERATED_BODY()
405
406private:
407
408 UPROPERTY()
409 TArray<UPico_Product*> ProductArray;
410 int32 Size = 0;
411 bool bHasNextPage;
412 FString NextPageParam = FString();
413
414public:
415 void InitParams(ppfProductArray* InppfProductArrayHandle);
416
418 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
419 UPico_Product* GetElement(int32 Index);
420
421 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
422 FString GetNextPageParam();
423
425 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
426 int32 GetSize();
427
429 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
430 bool HasNextPage();
431};
432
438UCLASS(BlueprintType)
439class ONLINESUBSYSTEMPICO_API UPico_Purchase : public UObject
440{
441 GENERATED_BODY()
442
443private:
444 int64 ExpirationTime = 0;
445 int64 GrantTime = 0;
446 FString ID = FString();
447 FString SKU = FString();
448 FString Icon = FString();
450 FString OuterId = FString();
451 EPeriodType CurrentPeriodType = EPeriodType::Unknown;
452 EPeriodType NextPeriodType = EPeriodType::Unknown;
453 int64 NextPayTime = 0;
455public:
456 void InitParams(ppfPurchase* InppfPurchaseHandle);
457
458
460 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
461 int64 GetExpirationTime();
462
464 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
465 int64 GetGrantTime();
466
468 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
469 FString GetID();
470
472 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
473 FString GetSKU();
474
476 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
477 FString GetIcon();
478
480 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
481 EAddonsType GetAddonsType();
482
484 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
485 EPeriodType GetCurrentPeriodType();
486
488 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
489 EPeriodType GetNextPeriodType();
490
492 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
493 FString GetOuterId();
494
496 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
497 int64 GetNextPayTime();
498
500 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
501 EDiscountType GetDiscountType();
502};
503
509UCLASS(BlueprintType)
510class ONLINESUBSYSTEMPICO_API UPico_PurchaseArray : public UObject
511{
512 GENERATED_BODY()
513
514private:
515
516 UPROPERTY()
517 TArray<UPico_Purchase*> PurchaseArray;
518 int32 Size = 0;
519 bool bHasNextPage;
520 FString NextPageParam = FString();
521
522public:
523 void InitParams(ppfPurchaseArray* InppfPurchaseArrayHandle);
524
526 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
527 UPico_Purchase* GetElement(int32 Index);
528
529 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
530 FString GetNextPageParam();
531
533 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
534 int32 GetSize();
535
537 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
538 bool HasNextPage();
539};
PicoIAPInterface class.
Definition: Pico_IAP.h:49
bool GetProductsBySKU(TArray< FString > ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate)
Gets a list of purchasable add-ons 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 add-ons.
bool LaunchCheckoutFlow(const FString &SKU, const FString &Price, const FString &Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate)
Launches the checkout flow to purchase a durable or consumable.
bool GetNextProductsArrayPage(UPico_ProductArray *InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate)
Gets the next page of purchasable add-ons.
bool LaunchCheckoutFlowV2(const FString &SKU, const FString &Price, const FString &Currency, const FString &OuterId, FLaunchCheckoutFlow_V2Delegate InLaunchCheckoutFlow_V2Delegate)
Launches the checkout flow to purchase a subscription add-on.
bool GetViewerPurchases(FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate)
Gets a list of purchased add-ons for a user.
OnlinePicoIAP Blueprint Function class.
Definition: Pico_IAP.h:182
UPico_ProductArray class.
Definition: Pico_IAP.h:403
UPico_Product class.
Definition: Pico_IAP.h:310
UPico_PurchaseArray class.
Definition: Pico_IAP.h:511
UPico_Purchase class.
Definition: Pico_IAP.h:440
EDiscountType
Discount type.
Definition: OnlineSubsystemPicoNames.h:723
EPeriodType
Subscription period type.
Definition: OnlineSubsystemPicoNames.h:708
EAddonsType
Add-on type.
Definition: OnlineSubsystemPicoNames.h:697