PICO Unreal Platform SDK
Pico_IAP.h
1// Copyright® 2015-2023 PICO Technology Co., Ltd. All rights reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "UObject/NoExportTypes.h"
7#include "PPF_Platform.h"
8#include "OnlineSubsystemPico.h"
9#include "Kismet/BlueprintFunctionLibrary.h"
10#include "Pico_IAP.generated.h"
11
13
14DECLARE_LOG_CATEGORY_EXTERN(PicoIAP, Log, All);
18DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetProductsBySKUDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_ProductArray*, ProductArray);
19DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetViewerPurchasesDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_PurchaseArray*, PurchaseArray);
20DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetNextProductArrayPageDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_ProductArray*, ProductArray);
21DECLARE_DYNAMIC_DELEGATE_TwoParams(FConsumePurchaseDelegate, bool, bIsError, const FString&, ErrorMessage);
22DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetNextPurchaseArrayPageDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_PurchaseArray*, PurchaseArray);
23DECLARE_DYNAMIC_DELEGATE_ThreeParams(FLaunchCheckoutFlowDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_Purchase*, Purchase);
24DECLARE_DYNAMIC_DELEGATE_ThreeParams(FLaunchCheckoutFlow_V2Delegate, bool, bIsError, const FString&, ErrorMessage, UPico_Purchase*, Purchase);
25DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetSubscriptionStatusDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_SubscriptionStatus*, SubscriptionStatus);
26DECLARE_DYNAMIC_DELEGATE_ThreeParams(FLaunchCheckoutFlow_V3Delegate, bool, bIsError, const FString&, ErrorMessage, UPico_Purchase*, Purchase);
27
39class ONLINESUBSYSTEMPICO_API FPicoIAPInterface
40{
41private:
42
43 FOnlineSubsystemPico& PicoSubsystem;
44
45public:
46 FPicoIAPInterface(FOnlineSubsystemPico& InSubsystem);
48
49 FConsumePurchaseDelegate ConsumePurchaseDelegate;
50 FGetProductsBySKUDelegate GetProductsBySKUDelegate;
51 FGetNextProductArrayPageDelegate GetNextProductArrayPageDelegate;
52 FGetViewerPurchasesDelegate GetViewerPurchasesDelegate;
53 FGetNextPurchaseArrayPageDelegate GetNextPurchaseArrayPageDelegate;
54 FLaunchCheckoutFlowDelegate LaunchCheckoutFlowDelegate;
55 FLaunchCheckoutFlow_V2Delegate LaunchCheckoutFlow_V2Delegate;
56 FGetSubscriptionStatusDelegate GetSubscriptionStatusDelegate;
57 FLaunchCheckoutFlow_V3Delegate LaunchCheckoutFlow_V3Delegate;
58
71 bool ConsumePurchase(const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
72
85 bool GetProductsBySKU(TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
86
97 bool GetNextProductsArrayPage(UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
98
109 bool GetViewerPurchases(FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
110
121 bool GetNextPurchaseArrayPage(UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
122
137 bool LaunchCheckoutFlow(const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
138
154 bool LaunchCheckoutFlowV2(const FString& SKU, const FString& Price, const FString& Currency, const FString& OuterId, FLaunchCheckoutFlow_V2Delegate InLaunchCheckoutFlow_V2Delegate);
155
168 bool GetSubscriptionStatus(const FString& SKU, FGetSubscriptionStatusDelegate InGetSubscriptionStatusDelegate);
169
186 bool LaunchCheckoutFlowV3(const FString& SKU, const FString& Price, const FString& Currency, const FString& OuterId, const FString& OrderComment, FLaunchCheckoutFlow_V3Delegate InLaunchCheckoutFlow_V3Delegate);
187};
188
203UCLASS()
204class ONLINESUBSYSTEMPICO_API UOnlinePicoIAPFunction : public UBlueprintFunctionLibrary
205{
206 GENERATED_BODY()
207
208public:
209
210
224 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
225 static bool ConsumePurchase(UObject* WorldContextObject, const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
226
239 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
240 static bool GetProductsBySKU(UObject* WorldContextObject, TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
241
253 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
254 static bool GetNextProductsArrayPage(UObject* WorldContextObject, UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
255
267 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
268 static bool GetViewerPurchases(UObject* WorldContextObject, FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
269
281 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
282 static bool GetNextPurchaseArrayPage(UObject* WorldContextObject, UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
283
299 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
300 static bool LaunchCheckoutFlow(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
301
318 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
319 static bool LaunchCheckoutFlowV2(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, const FString& OuterId, FLaunchCheckoutFlow_V2Delegate InLaunchCheckoutFlow_V2Delegate);
320
334 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
335 static bool GetSubscriptionStatus(UObject* WorldContextObject, const FString& SKU, FGetSubscriptionStatusDelegate InGetSubscriptionStatusDelegate);
336
337
355 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
356 static bool LaunchCheckoutFlowV3(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, const FString& OuterId, const FString& OrderComment, FLaunchCheckoutFlow_V3Delegate InLaunchCheckoutFlow_V3Delegate);
357};
358
367UCLASS(BlueprintType)
368class ONLINESUBSYSTEMPICO_API UPico_Product : public UObject
369{
370 GENERATED_BODY()
371
372private:
373 FString Description = FString();
374 FString DetailDescription = FString();
375 FString Price = FString();
376 FString Currency = FString();
377 FString Name = FString();
378 FString SKU = FString();
379 FString Icon = FString();
382 EPeriodType TrialPeriodUnit = EPeriodType::Unknown;
383 int32 TrialPeriodValue = -1;
384 FString OuterId = FString();
385 FString OriginalPrice = FString();
386 bool bIsContinuous = false;
387
388public:
389 void InitParams(ppfProduct* InppfProductHandle);
390
392 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
393 FString GetDescription();
394
396 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
397 FString GetDetailDescription();
398
400 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
401 FString GetPrice();
402
404 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
405 FString GetFormattedPrice();
406
408 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
409 FString GetCurrency();
410
412 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
413 FString GetName();
414
416 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
417 FString GetSKU();
418
420 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
421 FString GetIcon();
422
424 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
425 EAddonsType GetAddonsType();
426
428 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
429 EPeriodType GetPeriodType();
430
432 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
433 EPeriodType GetTrialPeriodUnit();
434
436 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
437 int32 GetTrialPeriodValue();
438
440 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
441 FString GetOuterId();
442
446 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
447 FString GetOriginalPrice();
448
450 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
451 bool GetIsContinuous();
452
453};
454
460UCLASS(BlueprintType)
461class ONLINESUBSYSTEMPICO_API UPico_ProductArray : public UObject
462{
463 GENERATED_BODY()
464
465private:
466
467 UPROPERTY()
468 TArray<UPico_Product*> ProductArray;
469 int32 Size = 0;
470 bool bHasNextPage;
471 FString NextPageParam = FString();
472
473public:
474 void InitParams(ppfProductArray* InppfProductArrayHandle);
475
477 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
478 UPico_Product* GetElement(int32 Index);
479
480 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
481 FString GetNextPageParam();
482
484 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
485 int32 GetSize();
486
488 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
489 bool HasNextPage();
490};
491
497UCLASS(BlueprintType)
498class ONLINESUBSYSTEMPICO_API UPico_Purchase : public UObject
499{
500 GENERATED_BODY()
501
502private:
503 int64 ExpirationTime = 0;
504 int64 GrantTime = 0;
505 FString ID = FString();
506 FString SKU = FString();
507 FString Icon = FString();
509 FString OuterId = FString();
510 EPeriodType CurrentPeriodType = EPeriodType::Unknown;
511 EPeriodType NextPeriodType = EPeriodType::Unknown;
512 int64 NextPayTime = 0;
514 FString OrderComment = FString();
515public:
516 void InitParams(ppfPurchase* InppfPurchaseHandle);
517
518
520 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
521 int64 GetExpirationTime();
522
524 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
525 int64 GetGrantTime();
526
528 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
529 FString GetID();
530
532 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
533 FString GetSKU();
534
536 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
537 FString GetIcon();
538
540 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
541 EAddonsType GetAddonsType();
542
544 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
545 EPeriodType GetCurrentPeriodType();
546
548 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
549 EPeriodType GetNextPeriodType();
550
552 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
553 FString GetOuterId();
554
556 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
557 int64 GetNextPayTime();
558
560 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
561 EDiscountType GetDiscountType();
562
564 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
565 FString GetOrderComment();
566};
567
573UCLASS(BlueprintType)
574class ONLINESUBSYSTEMPICO_API UPico_PurchaseArray : public UObject
575{
576 GENERATED_BODY()
577
578private:
579
580 UPROPERTY()
581 TArray<UPico_Purchase*> PurchaseArray;
582 int32 Size = 0;
583 bool bHasNextPage;
584 FString NextPageParam = FString();
585
586public:
587 void InitParams(ppfPurchaseArray* InppfPurchaseArrayHandle);
588
590 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
591 UPico_Purchase* GetElement(int32 Index);
592
593 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
594 FString GetNextPageParam();
595
597 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
598 int32 GetSize();
599
601 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
602 bool HasNextPage();
603};
604
610UCLASS(BlueprintType)
611class ONLINESUBSYSTEMPICO_API UPico_SubscriptionStatus : public UObject
612{
613 GENERATED_BODY()
614
615private:
616 FString SKU = FString();
617 FString OuterId = FString();
618 int64 StartTime = 0;
619 int64 EndTime = 0;
620 EPeriodType CurrentPeriodType = EPeriodType::Unknown;
622 ECancelReason CancelReason = ECancelReason::None;
623 bool bIsFreeTrial = false;
624 int32 NextPeriod = -1;
625public:
626 void InitParams(ppfSubscriptionStatus* InppfSubscriptionStatusHandle);
627
629 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
630 FString GetSKU();
631
633 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
634 FString GetOuterId();
635
637 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
638 int64 GetStartTime();
639
641 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
642 int64 GetEndTime();
643
645 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
646 EPeriodType GetCurrentPeriodType();
647
649 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
650 EEntitlementStatus GetEntitlementStatus();
651
653 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
654 ECancelReason GetCancelReason();
655
657 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
658 bool GetIsFreeTrial();
659
661 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
662 int32 GetNextPeriod();
663
664};
PicoIAPInterface class.
Definition: Pico_IAP.h:40
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 LaunchCheckoutFlowV3(const FString &SKU, const FString &Price, const FString &Currency, const FString &OuterId, const FString &OrderComment, FLaunchCheckoutFlow_V3Delegate InLaunchCheckoutFlow_V3Delegate)
Launches the checkout flow to purchase a subscription add-on.
bool GetSubscriptionStatus(const FString &SKU, FGetSubscriptionStatusDelegate InGetSubscriptionStatusDelegate)
Gets the subscription status of an add-on.
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, including durables and unfulfilled consumables.
OnlinePicoIAP Blueprint Function class.
Definition: Pico_IAP.h:205
UPico_ProductArray class.
Definition: Pico_IAP.h:462
UPico_Product class.
Definition: Pico_IAP.h:369
UPico_PurchaseArray class.
Definition: Pico_IAP.h:575
UPico_Purchase class.
Definition: Pico_IAP.h:499
UPico_SubscriptionStatus class.
Definition: Pico_IAP.h:612
EEntitlementStatus
The subscription entitlement status type.
Definition: OnlineSubsystemPicoNames.h:722
EDiscountType
Discount type.
Definition: OnlineSubsystemPicoNames.h:711
ECancelReason
The subscription entitlement cancel reason type.
Definition: OnlineSubsystemPicoNames.h:735
EPeriodType
Subscription period type.
Definition: OnlineSubsystemPicoNames.h:696
EAddonsType
Add-on type.
Definition: OnlineSubsystemPicoNames.h:685