diff --git a/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp b/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp index 1f2d148..1a0250b 100644 --- a/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp +++ b/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp @@ -3,7 +3,7 @@ #include "PlatformHttp.h" #include "Immutable/ImmutableUtilities.h" -#include "Immutable/TransakConfig.h" +#include "Immutable/Transak/TransakConfig.h" #if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) #include "SWebBrowser.h" diff --git a/Source/Immutable/Public/Immutable/ImmutablePluginSettings.h b/Source/Immutable/Public/Immutable/ImmutablePluginSettings.h index fa1acff..7bd7aa8 100644 --- a/Source/Immutable/Public/Immutable/ImmutablePluginSettings.h +++ b/Source/Immutable/Public/Immutable/ImmutablePluginSettings.h @@ -2,7 +2,7 @@ #include "Engine/DeveloperSettings.h" #include "ApplicationConfig.h" -#include "TransakConfig.h" +#include "Transak/TransakConfig.h" #include "ImmutablePluginSettings.generated.h" diff --git a/Source/Immutable/Public/Immutable/ImmutableUtilities.h b/Source/Immutable/Public/Immutable/ImmutableUtilities.h index 6c788d2..adc8cb6 100644 --- a/Source/Immutable/Public/Immutable/ImmutableUtilities.h +++ b/Source/Immutable/Public/Immutable/ImmutableUtilities.h @@ -1,6 +1,6 @@ #pragma once #include "ApplicationConfig.h" -#include "TransakConfig.h" +#include "Transak/TransakConfig.h" /** A wrapper struct around various Immutable namespace utility and support methods. */ diff --git a/Source/Immutable/Public/Immutable/Transak/TransakConfig.h b/Source/Immutable/Public/Immutable/Transak/TransakConfig.h new file mode 100644 index 0000000..7c02a07 --- /dev/null +++ b/Source/Immutable/Public/Immutable/Transak/TransakConfig.h @@ -0,0 +1,237 @@ +#pragma once + +#include "TransakConfig.generated.h" + + +UENUM() +enum class ETransakEnvironment : uint8 +{ + Sandbox, + Production, +}; + +/** + * @class UTransakConfig + * @brief Configuration settings for Transak widget. + */ +UCLASS(Abstract, Blueprintable, ClassGroup = Immutable) +class UTransakConfig : public UObject +{ + GENERATED_BODY() + +public: + /** + * Get the URL based on the current environment setting. + * @return The URL corresponding to the current environment setting. + */ + FString GetURL() const + { + switch (Environment) + { + case ETransakEnvironment::Production: + return TEXT("https://global.transak.com/"); + default: + case ETransakEnvironment::Sandbox: + return TEXT("https://global-stg.transak.com/"); + } + } + + /** + * Get the API key based on the current environment. + * @return The API key corresponding to the current environment. + */ + FString GetAPIKey() const + { + switch (Environment) + { + case ETransakEnvironment::Production: + return TEXT("ad1bca70-d917-4628-bb0f-5609537498bc"); + default: + case ETransakEnvironment::Sandbox: + return TEXT("d14b44fb-0f84-4db5-affb-e044040d724b"); + } + } + + /** + * @details More details could be found under the class parameter + * @return Network as FString + */ + const FString& GetNetwork() + { + return Network; + } + + /** + * @details More details could be found under the class parameter + * @return DefaultFiatCurrency as FString + */ + const FString& GetDefaultFiatCurrency() + { + return DefaultFiatCurrency; + } + + /** + * @details More details could be found under the class parameter + * @return DefaultFiatAmount as FString + */ + const FString& GetDefaultFiatAmount() + { + return DefaultFiatAmount; + } + + /** + * @details More details could be found under the class parameter + * @return DefaultCryptoCurrency as FString + */ + const FString& GetDefaultCryptoCurrency() + { + return DefaultCryptoCurrency; + } + + /** + * @details More details could be found under the class parameter + * @return DefaultPaymentMethod as FString + */ + const FString& GetDefaultPaymentMethod() + { + return DefaultPaymentMethod; + } + + /** + * @details More details could be found under the class parameter + * @return DisablePaymentMethods as array of FString + */ + const TArray& GetDisablePaymentMethods() + { + return DisablePaymentMethods; + } + + /** + * @details More details could be found under the class parameter + * @return bIsAutoFillUserData as bool + */ + bool IsAutoFillUserData() + { + return bIsAutoFillUserData; + } + + /** + * @details More details could be found under the class parameter + * @return bDisableWalletAddressForm as bool + */ + bool DisableWalletAddressForm() + { + return bDisableWalletAddressForm; + } + + /** + * @details More details could be found under the class parameter + * @return CryptoCurrencyList as array of FString + */ + const TArray& GetCryptoCurrencyList() + { + return CryptoCurrencyList; + } + + /** + * @details More details could be found under the class parameter + * @return ThemeColor as FLinearColor + */ + const FLinearColor& GetThemeColor() + { + return ThemeColor; + } + +protected: + /** + * Specifies the environment for transactions. + * @note The default environment is set to the Sandbox environment. + */ + UPROPERTY(EditDefaultsOnly, Category = "General") + ETransakEnvironment Environment = ETransakEnvironment::Sandbox; + + /** + * The default payment method you would prefer the customer to buy/sell with. + * If you pass this param, the payment method will be selected by default and the customer can + * also select another payment method. + */ + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + FString DefaultPaymentMethod; + + /** + * The three letter code of the fiat currency your user will send/receive while buying/selling cryptocurrency. + * Users can change the fiat currency if this is passed. If the fiat currency is not supported by + * a specific product type (BUY/SELL) then the default widget will load with all the supported fiat + * currencies for that product type. + */ + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + FString DefaultFiatCurrency; + + /** + * An integer amount representing how much the customer wants to spend/receive. + * Users can change the fiat amount if this is passed. + */ + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + FString DefaultFiatAmount; + + /** + * The default cryptocurrency you would prefer the customer to buy/sell. + * If you pass this param, the currency will be selected by default, but the customer will + * still be able to select another cryptocurrency. Please ensure that the currency code passed by + * you is available for the specific product type (BUY/SELL). + * If you pass a value that is not supported by BUY/SELL, then the default widget will load. + */ + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + FString DefaultCryptoCurrency; + + /** + * Crypto network that you would allow your customers to buy. + * You can get the supporting networks by opening http://global.transak.com and then go to + * cryptocurrencies select screen. Only the cryptocurrencies supported by this network for + * the specific product type (BUY/SELL) will be shown in the widget. + * If the network selected is not supported by a product type (BUY/SELL) then the default widget will + * all supported networks will be shown. + */ + UPROPERTY(EditDefaultsOnly, Category = "Transak") + FString Network; + + /** + * A comma-separated list of payment methods you want to disable and hide from the customers. + * Refer here to the list of supported params for the payment method. + */ + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + TArray DisablePaymentMethods; + + /** + * When true, then the email address will be auto-filled, but the screen will not be skipped. + * User can edit their email address, basic data like first name & the address. + * This parameter will be ignored if email or userData are not passed. + */ + UPROPERTY(EditDefaultsOnly, Category = "User") + bool bIsAutoFillUserData = true; + + /** + * When true, the customer will not be able to change the destination address of + * where the cryptocurrency is sent to. + */ + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + bool bDisableWalletAddressForm = true; + + /** + * A comma-separated list of cryptoCurrencies that you would allow your customers to buy/sell. + * Only these crypto currencies will be shown in the widget. This will be a string of comma + * separated values each of which will represent a valid cryptoCurrency code. + * Please ensure that the crypto currency codes passed in the list are available for the specific + * product type (BUY/SELL). If even one of the crypto currency codes in the list is supported by + * the specific product type (BUY/SELL), then it will be honored, otherwise the default widget will + * load for the product type for which none of the crypto currency codes are supported. + */ + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + TArray CryptoCurrencyList; + + /** + * The theme color code for the widget main color. It is used for buttons, + */ + UPROPERTY(EditDefaultsOnly, Category = "Theme") + FLinearColor ThemeColor; +}; diff --git a/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h b/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h index f543e84..00ed377 100644 --- a/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h +++ b/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h @@ -12,8 +12,9 @@ class SWebBrowser; class SBluWebBrowser; #endif + /** - * + * A custom web browser widget for Transak transactions. */ UCLASS() class IMMUTABLE_API UTransakWebBrowser : public UWidget @@ -24,9 +25,22 @@ class IMMUTABLE_API UTransakWebBrowser : public UWidget DECLARE_MULTICAST_DELEGATE(FOnWhenReady); public: + /** + * Check if the web browser widget is ready to be loaded. + * + * @return True if the widget is ready, false otherwise. + */ UFUNCTION(BlueprintPure) bool IsReady() const; + /** + * Loads Transak widget with provided user data. + * + * @param WalletAddress The wallet address to load. + * @param Email The email associated with the user. + * @param ProductsAvailed The products availed by the user. + * @param ScreenTitle The title of the screen to load. + */ UFUNCTION(BlueprintCallable) void Load(const FString& WalletAddress, const FString& Email, const FString& ProductsAvailed, const FString& ScreenTitle); diff --git a/Source/Immutable/Public/Immutable/TransakConfig.h b/Source/Immutable/Public/Immutable/TransakConfig.h deleted file mode 100644 index b998970..0000000 --- a/Source/Immutable/Public/Immutable/TransakConfig.h +++ /dev/null @@ -1,139 +0,0 @@ -#pragma once -#include "ImmutableEnums.h" - -#include "TransakConfig.generated.h" - - -UENUM() -enum class ETransakEnvironment : uint8 -{ - Sandbox, - Production, -}; - -/** - * @class UTransakConfig - * @brief Configuration settings for Passport and various APIs. - * @details This class stores configuration settings such as URLs, chain names, contract addresses, - * client IDs, and environment settings for the zkEVM API, Orderbook API, and Passport. - */ -UCLASS(Abstract, Blueprintable, ClassGroup = Immutable) -class UTransakConfig : public UObject -{ - GENERATED_BODY() - -public: - FString GetURL() const - { - switch (Environment) - { - case ETransakEnvironment::Production: - return TEXT("https://global.transak.com/"); - default: - case ETransakEnvironment::Sandbox: - return TEXT("https://global-stg.transak.com/"); - } - } - - FString GetAPIKey() const - { - switch (Environment) - { - case ETransakEnvironment::Production: - return TEXT("ad1bca70-d917-4628-bb0f-5609537498bc"); - default: - case ETransakEnvironment::Sandbox: - return TEXT("d14b44fb-0f84-4db5-affb-e044040d724b"); - } - } - - const FString& GetNetwork() - { - return Network; - } - - const FString& GetDefaultFiatCurrency() - { - return DefaultFiatCurrency; - } - - const FString& GetDefaultFiatAmount() - { - return DefaultFiatAmount; - } - - const FString& GetDefaultCryptoCurrency() - { - return DefaultCryptoCurrency; - } - - const FString& GetDefaultPaymentMethod() - { - return DefaultPaymentMethod; - } - - const TArray& GetDisablePaymentMethods() - { - return DisablePaymentMethods; - } - - bool IsAutoFillUserData() - { - return bIsAutoFillUserData; - } - - bool DisableWalletAddressForm() - { - return bDisableWalletAddressForm; - } - - const TArray& GetCryptoCurrencyList() - { - return CryptoCurrencyList; - } - - const FLinearColor& GetThemeColor() - { - return ThemeColor; - } - -protected: - // UPROPERTY(EditDefaultsOnly, Category = "Transak") - // FString URL; - // - // UPROPERTY(EditDefaultsOnly, Category = "Transak") - // FString APIKey; - - UPROPERTY(EditDefaultsOnly, Category = "General") - ETransakEnvironment Environment = ETransakEnvironment::Sandbox; - - UPROPERTY(EditDefaultsOnly, Category = "Fiat") - FString DefaultPaymentMethod; - - UPROPERTY(EditDefaultsOnly, Category = "Fiat") - FString DefaultFiatCurrency; - - UPROPERTY(EditDefaultsOnly, Category = "Fiat") - FString DefaultFiatAmount; - - UPROPERTY(EditDefaultsOnly, Category = "Fiat") - FString DefaultCryptoCurrency; - - UPROPERTY(EditDefaultsOnly, Category = "Transak") - FString Network; - - UPROPERTY(EditDefaultsOnly, Category = "Fiat") - TArray DisablePaymentMethods; - - UPROPERTY(EditDefaultsOnly, Category = "User") - bool bIsAutoFillUserData = true; - - UPROPERTY(EditDefaultsOnly, Category = "Fiat") - bool bDisableWalletAddressForm = true; - - UPROPERTY(EditDefaultsOnly, Category = "Fiat") - TArray CryptoCurrencyList; - - UPROPERTY(EditDefaultsOnly, Category = "Theme") - FLinearColor ThemeColor; -};