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 "Pico_IAP.generated.h"
10
12
13DECLARE_LOG_CATEGORY_EXTERN(PicoIAP, Log, All);
17DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetProductsBySKUDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_ProductArray*, ProductArray);
18DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetViewerPurchasesDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_PurchaseArray*, PurchaseArray);
19DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetNextProductArrayPageDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_ProductArray*, ProductArray);
20DECLARE_DYNAMIC_DELEGATE_TwoParams(FConsumePurchaseDelegate, bool, bIsError, const FString&, ErrorMessage);
21DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetNextPurchaseArrayPageDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_PurchaseArray*, PurchaseArray);
22DECLARE_DYNAMIC_DELEGATE_ThreeParams(FLaunchCheckoutFlowDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_Purchase*, Purchase);
23DECLARE_DYNAMIC_DELEGATE_ThreeParams(FLaunchCheckoutFlow_V2Delegate, bool, bIsError, const FString&, ErrorMessage, UPico_Purchase*, Purchase);
24DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetSubscriptionStatusDelegate, bool, bIsError, const FString&, ErrorMessage, UPico_SubscriptionStatus*, SubscriptionStatus);
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 FLaunchCheckoutFlow_V2Delegate LaunchCheckoutFlow_V2Delegate;
54 FGetSubscriptionStatusDelegate GetSubscriptionStatusDelegate;
55
68 bool ConsumePurchase(const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
69
82 bool GetProductsBySKU(TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
83
94 bool GetNextProductsArrayPage(UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
95
107 bool GetViewerPurchases(FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
108
119 bool GetNextPurchaseArrayPage(UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
120
135 bool LaunchCheckoutFlow(const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
136
152 bool LaunchCheckoutFlowV2(const FString& SKU, const FString& Price, const FString& Currency, const FString& OuterId, FLaunchCheckoutFlow_V2Delegate InLaunchCheckoutFlow_V2Delegate);
153
166 bool GetSubscriptionStatus(const FString& SKU, FGetSubscriptionStatusDelegate InGetSubscriptionStatusDelegate);
167
168};
169
184UCLASS()
185class ONLINESUBSYSTEMPICO_API UOnlinePicoIAPFunction : public UBlueprintFunctionLibrary
186{
187 GENERATED_BODY()
188
189public:
190
191
205 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
206 static bool ConsumePurchase(UObject* WorldContextObject, const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
207
220 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
221 static bool GetProductsBySKU(UObject* WorldContextObject, TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
222
234 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
235 static bool GetNextProductsArrayPage(UObject* WorldContextObject, UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
236
249 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
250 static bool GetViewerPurchases(UObject* WorldContextObject, FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
251
263 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
264 static bool GetNextPurchaseArrayPage(UObject* WorldContextObject, UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
265
281 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
282 static bool LaunchCheckoutFlow(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
283
300 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
301 static bool LaunchCheckoutFlowV2(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, const FString& OuterId, FLaunchCheckoutFlow_V2Delegate InLaunchCheckoutFlow_V2Delegate);
302
316 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
317 static bool GetSubscriptionStatus(UObject* WorldContextObject, const FString& SKU, FGetSubscriptionStatusDelegate InGetSubscriptionStatusDelegate);
318
319};
320
329UCLASS(BlueprintType)
330class ONLINESUBSYSTEMPICO_API UPico_Product : public UObject
331{
332 GENERATED_BODY()
333
334private:
335 FString Description = FString();
336 FString DetailDescription = FString();
337 FString Price = FString();
338 FString Currency = FString();
339 FString Name = FString();
340 FString SKU = FString();
341 FString Icon = FString();
344 EPeriodType TrialPeriodUnit = EPeriodType::Unknown;
345 int32 TrialPeriodValue = -1;
346 FString OuterId = FString();
347 FString OriginalPrice = FString();
348 bool bIsContinuous = false;
349
350public:
351 void InitParams(ppfProduct* InppfProductHandle);
352
354 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
355 FString GetDescription();
356
358 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
359 FString GetDetailDescription();
360
362 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
363 FString GetPrice();
364
366 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
367 FString GetFormattedPrice();
368
370 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
371 FString GetCurrency();
372
374 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
375 FString GetName();
376
378 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
379 FString GetSKU();
380
382 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
383 FString GetIcon();
384
386 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
387 EAddonsType GetAddonsType();
388
390 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
391 EPeriodType GetPeriodType();
392
394 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
395 EPeriodType GetTrialPeriodUnit();
396
398 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
399 int32 GetTrialPeriodValue();
400
402 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
403 FString GetOuterId();
404
408 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
409 FString GetOriginalPrice();
410
412 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
413 bool GetIsContinuous();
414
415};
416
422UCLASS(BlueprintType)
423class ONLINESUBSYSTEMPICO_API UPico_ProductArray : public UObject
424{
425 GENERATED_BODY()
426
427private:
428
429 UPROPERTY()
430 TArray<UPico_Product*> ProductArray;
431 int32 Size = 0;
432 bool bHasNextPage;
433 FString NextPageParam = FString();
434
435public:
436 void InitParams(ppfProductArray* InppfProductArrayHandle);
437
439 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
440 UPico_Product* GetElement(int32 Index);
441
442 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
443 FString GetNextPageParam();
444
446 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
447 int32 GetSize();
448
450 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
451 bool HasNextPage();
452};
453
459UCLASS(BlueprintType)
460class ONLINESUBSYSTEMPICO_API UPico_Purchase : public UObject
461{
462 GENERATED_BODY()
463
464private:
465 int64 ExpirationTime = 0;
466 int64 GrantTime = 0;
467 FString ID = FString();
468 FString SKU = FString();
469 FString Icon = FString();
471 FString OuterId = FString();
472 EPeriodType CurrentPeriodType = EPeriodType::Unknown;
473 EPeriodType NextPeriodType = EPeriodType::Unknown;
474 int64 NextPayTime = 0;
476public:
477 void InitParams(ppfPurchase* InppfPurchaseHandle);
478
479
481 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
482 int64 GetExpirationTime();
483
485 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
486 int64 GetGrantTime();
487
489 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
490 FString GetID();
491
493 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
494 FString GetSKU();
495
497 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
498 FString GetIcon();
499
501 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
502 EAddonsType GetAddonsType();
503
505 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
506 EPeriodType GetCurrentPeriodType();
507
509 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
510 EPeriodType GetNextPeriodType();
511
513 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
514 FString GetOuterId();
515
517 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
518 int64 GetNextPayTime();
519
521 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
522 EDiscountType GetDiscountType();
523};
524
530UCLASS(BlueprintType)
531class ONLINESUBSYSTEMPICO_API UPico_PurchaseArray : public UObject
532{
533 GENERATED_BODY()
534
535private:
536
537 UPROPERTY()
538 TArray<UPico_Purchase*> PurchaseArray;
539 int32 Size = 0;
540 bool bHasNextPage;
541 FString NextPageParam = FString();
542
543public:
544 void InitParams(ppfPurchaseArray* InppfPurchaseArrayHandle);
545
547 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
548 UPico_Purchase* GetElement(int32 Index);
549
550 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
551 FString GetNextPageParam();
552
554 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
555 int32 GetSize();
556
558 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
559 bool HasNextPage();
560};
561
567UCLASS(BlueprintType)
568class ONLINESUBSYSTEMPICO_API UPico_SubscriptionStatus : public UObject
569{
570 GENERATED_BODY()
571
572private:
573 FString SKU = FString();
574 FString OuterId = FString();
575 int64 StartTime = 0;
576 int64 EndTime = 0;
577 EPeriodType CurrentPeriodType = EPeriodType::Unknown;
579 ECancelReason CancelReason = ECancelReason::None;
580 bool bIsFreeTrial = false;
581 int32 NextPeriod = -1;
582public:
583 void InitParams(ppfSubscriptionStatus* InppfSubscriptionStatusHandle);
584
586 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
587 FString GetSKU();
588
590 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
591 FString GetOuterId();
592
594 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
595 int64 GetStartTime();
596
598 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
599 int64 GetEndTime();
600
602 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
603 EPeriodType GetCurrentPeriodType();
604
606 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
607 EEntitlementStatus GetEntitlementStatus();
608
610 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
611 ECancelReason GetCancelReason();
612
614 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
615 bool GetIsFreeTrial();
616
618 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|SubscriptionStatus")
619 int32 GetNextPeriod();
620
621};
PicoIAPInterface class.
Definition: Pico_IAP.h:38
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 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.
OnlinePicoIAP Blueprint Function class.
Definition: Pico_IAP.h:186
UPico_ProductArray class.
Definition: Pico_IAP.h:424
UPico_Product class.
Definition: Pico_IAP.h:331
UPico_PurchaseArray class.
Definition: Pico_IAP.h:532
UPico_Purchase class.
Definition: Pico_IAP.h:461
UPico_SubscriptionStatus class.
Definition: Pico_IAP.h:569
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