Skip to content

Commit

Permalink
chore: added comments and moved to dedicated folder
Browse files Browse the repository at this point in the history
  • Loading branch information
YermekG committed Jan 9, 2025
1 parent 91f1e9f commit d503d3d
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Engine/DeveloperSettings.h"
#include "ApplicationConfig.h"
#include "TransakConfig.h"
#include "Transak/TransakConfig.h"

#include "ImmutablePluginSettings.generated.h"

Expand Down
2 changes: 1 addition & 1 deletion Source/Immutable/Public/Immutable/ImmutableUtilities.h
Original file line number Diff line number Diff line change
@@ -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. */
Expand Down
237 changes: 237 additions & 0 deletions Source/Immutable/Public/Immutable/Transak/TransakConfig.h
Original file line number Diff line number Diff line change
@@ -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<FString>& 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<FString>& 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<FString> 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<FString> CryptoCurrencyList;

/**
* The theme color code for the widget main color. It is used for buttons,
*/
UPROPERTY(EditDefaultsOnly, Category = "Theme")
FLinearColor ThemeColor;
};
16 changes: 15 additions & 1 deletion Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class SWebBrowser;
class SBluWebBrowser;
#endif


/**
*
* A custom web browser widget for Transak transactions.
*/
UCLASS()
class IMMUTABLE_API UTransakWebBrowser : public UWidget
Expand All @@ -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);

Expand Down
Loading

0 comments on commit d503d3d

Please sign in to comment.