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
77 bool ConsumePurchase(const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
78
90 bool GetProductsBySKU(TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
91
101 bool GetNextProductsArrayPage(UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
102
113 bool GetViewerPurchases(FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
114
124 bool GetNextPurchaseArrayPage(UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
125
139 bool LaunchCheckoutFlow(const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
140
155 bool LaunchCheckoutFlowV2(const FString& SKU, const FString& Price, const FString& Currency, const FString& OuterId, FLaunchCheckoutFlow_V2Delegate InLaunchCheckoutFlow_V2Delegate);
156
157};
158
173UCLASS()
174class ONLINESUBSYSTEMPICO_API UOnlinePicoIAPFunction : public UBlueprintFunctionLibrary
175{
176 GENERATED_BODY()
177
178public:
179
180
193 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
194 static bool ConsumePurchase(UObject* WorldContextObject,const FString& SKU, FConsumePurchaseDelegate InConsumePurchaseDelegate);
195
207 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
208 static bool GetProductsBySKU(UObject* WorldContextObject, TArray<FString> ProductSKUs, int32 Count, FGetProductsBySKUDelegate InGetProductsBySKUDelegate);
209
220 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
221 static bool GetNextProductsArrayPage(UObject* WorldContextObject, UPico_ProductArray* InProductArray, FGetNextProductArrayPageDelegate InGetNextProductArrayPageDelegate);
222
234 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
235 static bool GetViewerPurchases(UObject* WorldContextObject, FGetViewerPurchasesDelegate InGetViewerPurchasesDelegate);
236
247 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
248 static bool GetNextPurchaseArrayPage(UObject* WorldContextObject, UPico_PurchaseArray* InPurchaseArray, FGetNextPurchaseArrayPageDelegate InGetNextPurchaseArrayPageDelegate);
249
264 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
265 static bool LaunchCheckoutFlow(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, FLaunchCheckoutFlowDelegate InLaunchCheckoutFlowDelegate);
266
282 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|IAP")
283 static bool LaunchCheckoutFlowV2(UObject* WorldContextObject, const FString& SKU, const FString& Price, const FString& Currency, const FString& OuterId, FLaunchCheckoutFlow_V2Delegate InLaunchCheckoutFlow_V2Delegate);
284};
285
292UCLASS(BlueprintType)
293class ONLINESUBSYSTEMPICO_API UPico_Product : public UObject
294{
295 GENERATED_BODY()
296
297private:
298 FString Description = FString();
299 FString DetailDescription = FString();
300 FString Price = FString();
301 FString Currency = FString();
302 FString Name = FString();
303 FString SKU = FString();
304 FString Icon = FString();
307 EPeriodType TrialPeriodUnit = EPeriodType::Unknown;
308 int32 TrialPeriodValue = -1;
309 FString OuterId = FString();
310 FString OriginalPrice = FString();
311 bool bIsContinuous = false;
312
313public:
314 void InitParams(ppfProduct* InppfProductHandle);
315
316 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
317 FString GetDescription();
318
319 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
320 FString GetDetailDescription();
321
322 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
323 FString GetPrice();
324
325 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
326 FString GetFormattedPrice();
327
328 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
329 FString GetCurrency();
330
331 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
332 FString GetName();
333
334 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
335 FString GetSKU();
336
337 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
338 FString GetIcon();
339
340 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
341 EAddonsType GetAddonsType();
342
343 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
344 EPeriodType GetPeriodType();
345
346 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
347 EPeriodType GetTrialPeriodUnit();
348
349 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
350 int32 GetTrialPeriodValue();
351
352 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
353 FString GetOuterId();
354
355 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
356 FString GetOriginalPrice();
357
358 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product")
359 bool GetIsContinuous();
360
361};
362
366UCLASS(BlueprintType)
367class ONLINESUBSYSTEMPICO_API UPico_ProductArray : public UObject
368{
369 GENERATED_BODY()
370
371private:
372
373 UPROPERTY()
374 TArray<UPico_Product*> ProductArray;
375 int32 Size = 0;
376 bool bHasNextPage;
377 FString NextPageParam = FString();
378
379public:
380 void InitParams(ppfProductArray* InppfProductArrayHandle);
381
382 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
383 UPico_Product* GetElement(int32 Index);
384
385 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
386 FString GetNextPageParam();
387
388 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
389 int32 GetSize();
390
391 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Product Array")
392 bool HasNextPage();
393};
394
398UCLASS(BlueprintType)
399class ONLINESUBSYSTEMPICO_API UPico_Purchase : public UObject
400{
401 GENERATED_BODY()
402
403private:
404 int64 ExpirationTime = 0;
405 int64 GrantTime = 0;
406 FString ID = FString();
407 FString SKU = FString();
408 FString Icon = FString();
410 FString OuterId = FString();
411 EPeriodType CurrentPeriodType = EPeriodType::Unknown;
412 EPeriodType NextPeriodType = EPeriodType::Unknown;
413 int64 NextPayTime = 0;
415public:
416 void InitParams(ppfPurchase* InppfPurchaseHandle);
417
418 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
419 int64 GetExpirationTime();
420
421 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
422 int64 GetGrantTime();
423
424 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
425 FString GetID();
426
427 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
428 FString GetSKU();
429
430 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
431 FString GetIcon();
432
433 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
434 EAddonsType GetAddonsType();
435
436 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
437 EPeriodType GetCurrentPeriodType();
438
439 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
440 EPeriodType GetNextPeriodType();
441
442 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
443 FString GetOuterId();
444
445 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
446 int64 GetNextPayTime();
447
448 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase")
449 EDiscountType GetDiscountType();
450};
451
455UCLASS(BlueprintType)
456class ONLINESUBSYSTEMPICO_API UPico_PurchaseArray : public UObject
457{
458 GENERATED_BODY()
459
460private:
461
462 UPROPERTY()
463 TArray<UPico_Purchase*> PurchaseArray;
464 int32 Size = 0;
465 bool bHasNextPage;
466 FString NextPageParam = FString();
467
468public:
469 void InitParams(ppfPurchaseArray* InppfPurchaseArrayHandle);
470
471 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
472 UPico_Purchase* GetElement(int32 Index);
473
474 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
475 FString GetNextPageParam();
476
477 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
478 int32 GetSize();
479
480 UFUNCTION(BlueprintPure, Category = "Pico Platform|IAP|Purchase Array")
481 bool HasNextPage();
482};
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:175
Definition: Pico_IAP.h:368
Definition: Pico_IAP.h:294
Definition: Pico_IAP.h:457
Definition: Pico_IAP.h:400
EDiscountType
Discount type.
Definition: OnlineSubsystemPicoNames.h:723
EPeriodType
Subscription period type.
Definition: OnlineSubsystemPicoNames.h:708
EAddonsType
Add-on type.
Definition: OnlineSubsystemPicoNames.h:697