settings.gradle.kts:create method of the FreedomAPI class. This method requires three parameters:| Enum Constant | Description |
|---|---|
KZ | Kazakhstan region. |
UZ | Uzbekistan region. |
KG | Kyrgyzstan region. |
PaymentView shows the payment page, the card form and 3DS. It is required for createPaymentPage, createPaymentFrame, addNewCard and confirmCardPayment; other methods work without it.<kz.freedompay.paymentsdk.api.view.PaymentView
android:id="@+id/paymentView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>onLoadingStateChanged listener:SdkConfiguration data class. This class acts as a central container, encapsulating two key components: UserConfiguration for customer-specific settings and OperationalConfiguration for general operational parameters.SdkConfiguration object is passed to the SDK via freedomApi.setConfiguration().| Property | Type | Description |
|---|---|---|
userPhone | String? | Customer's phone number. If provided, it will be displayed on the payment page. If null, the user will be prompted to enter it. |
userContactEmail | String? | Customer's contact email. |
userEmail | String? | Customer's email address. If provided, it will be displayed on the payment page. If null, the user will be prompted to enter it. |
| Property | Type | Description | Default Value |
|---|---|---|---|
testingMode | Boolean? | Enables or disables test mode. If null, the value is inherited from the merchant's settings. A non-null value will override the merchant's setting. | null |
language | Language? | Sets the language of the payment page. See Language enum for available options. If null, the value is inherited from the merchant's settings. A non-null value will override the merchant's setting. | null |
lifetime | Int | Duration, in seconds, for which the payment page remains valid for completing a payment. | 1800 |
autoClearing | Boolean? | Activates automatic clearing of payments. If null, the value is inherited from the merchant's settings. A non-null value will override the merchant's setting. | null |
checkUrl | String? | URL to which the payment check will be sent. | null |
resultUrl | String? | URL to which the payment result will be sent. | null |
requestMethod | HttpMethod? | HTTP method used for requests to checkUrl or resultUrl. See HttpMethod enum. Defaults to GET if checkUrl or resultUrl is set. | HttpMethod.GET (if checkUrl or resultUrl is not null, otherwise null) |
| Enum Constant | Description |
|---|---|
KZ | SDK uses the Kazakh language. |
RU | SDK uses the Russian language. |
EN | SDK uses the English language. |
| Enum Constant | Description |
|---|---|
GET | SDK uses the HTTP GET method. |
POST | SDK uses the HTTP POST method. |
SdkConfiguration and pass it to the freedomApi.setConfiguration() method:onResult on the main thread.createPaymentPage or createPaymentFrame method on your FreedomAPI instance. This method handles the presentation of the payment page/frame within the previously configured PaymentView.PaymentView has been set using freedomApi.setPaymentView() prior to calling them.| Parameter | Type | Description |
|---|---|---|
paymentRequest | StandardPaymentRequest | Essential details required to initiate a new payment. See StandardPaymentRequest model. |
onResult | (FreedomResult<PaymentResponse>) -> Unit | Callback function that will be invoked upon the completion of the payment process. See PaymentResponse model. |
FreedomResult<PaymentResponse> object, which can be either:PaymentResponse object.getPaymentStatus method.| Parameter | Type | Description |
|---|---|---|
paymentId | Long | Unique identifier of the payment you want to check. |
includeLastTransactionInfo | Boolean? | Optional. When true, includes details of the most recent transaction in the response. |
onResult | (FreedomResult<Status>) -> Unit | Callback function that will be invoked with the result of the payment status. See Status model. |
FreedomResult<Status> object, which can be either:Status object.autoClearing property within the OperationalConfiguration of your SdkConfiguration.makeClearingPayment method to explicitly initiate the clearing (final capture) of funds for a previously authorized payment. This method gives you the flexibility to clear an amount that may be different from the original amount specified when the payment was created (e.g., for partial captures).| Parameter | Type | Description | Constraints/Notes |
|---|---|---|---|
paymentId | Long | Unique identifier of the payment you want to clear. | |
amount | Float? | Amount to be cleared. If null, the full amount of the original authorized payment will be cleared. | Optional. Defaults to null. Must be between 0.01 and 99999999.00 if provided. Cannot exceed the authorized amount. |
onResult | (FreedomResult<ClearingStatus>) -> Unit | Callback function that will be invoked with the result of the clearing operation. See ClearingStatus model. |
FreedomResult<ClearingStatus> object, which can be either:ClearingStatus object.autoClearing property within the OperationalConfiguration of your SdkConfiguration.makeCancelPayment method to reverse an authorized payment, effectively unblocking the amount on the customer's card. This ensures that the funds will not be charged.| Parameter | Type | Description |
|---|---|---|
paymentId | Long | Unique identifier of the payment you want to cancel. |
onResult | (FreedomResult<PaymentResponse>) -> Unit | Callback function that will be invoked with the result of the cancellation attempt. See PaymentResponse model. |
FreedomResult<PaymentResponse> object, which can be either:PaymentResponse object.makeRevokePayment method allows you to process a full or partial refund for a completed payment.| Parameter | Type | Description | Constraints/Notes |
|---|---|---|---|
paymentId | Long | Unique identifier of the payment you want to revoke (refund). | |
amount | Float? | Amount of funds to return. If null, the full amount of the original debited payment will be refunded. | Optional. Defaults to null. Must be between 0.01 and 99999999.00 if provided. Cannot exceed the authorized amount. |
onResult | (FreedomResult<PaymentResponse>) -> Unit | Callback function that will be invoked with the result of the refund process. See PaymentResponse model. |
FreedomResult<PaymentResponse> object, which can be either:PaymentResponse object.addNewCard method facilitates the secure tokenization and addition of a new payment card to a customer's profile. This process allows future payments to be made without requiring the customer to re-enter their card details.PaymentView has been set using freedomApi.setPaymentView() prior to calling it, as it will display a web-based form within the PaymentView for the customer to securely enter their card details.| Parameter | Type | Description | Constraints/Notes |
|---|---|---|---|
userId | String | Identifier for a user to associate this new card with. | Must contain 1-50 characters. Also, must match regex ^[a-zA-Z0-9_-]+$. |
orderId | String? | Unique identifier for this order within your system. | Optional. Defaults to null. Must contain 1-50 characters. |
onResult | (FreedomResult<PaymentResponse>) -> Unit | Callback function that will be invoked upon the completion of the card addition process. See PaymentResponse model. |
FreedomResult<PaymentResponse> object, which can be either:PaymentResponse object.getAddedCards method allows you to retrieve a list of payment cards that have been previously added and tokenized for a specific user.| Parameter | Type | Description | Constraints/Notes |
|---|---|---|---|
userId | String | Identifier of the user whose added cards you wish to retrieve. | Must contain 1-50 characters. Also, must match regex ^[a-zA-Z0-9_-]+$. |
onResult | (FreedomResult<List<Card>>) -> Unit | Callback function that will be invoked upon the completion of the card retrieval operation. See Card model. |
FreedomResult<List<Card>> object, which can be either:Card objects.removeAddedCard method allows you to securely remove a previously tokenized payment card associated with a specific user.| Parameter | Type | Description | Constraints/Notes |
|---|---|---|---|
userId | String | Identifier of the user from whom the card will be removed. | Must contain 1-50 characters. Also, must match regex ^[a-zA-Z0-9_-]+$. |
cardToken | String | Unique token of the card to be removed. This token is obtained when the card is added (via addNewCard or retrieved using getAddedCards. | Must contain 1 or more characters. |
onResult | (FreedomResult<RemovedCard>) -> Unit | Callback function that will be invoked upon the completion of the card removal operation. See RemovedCard model. |
FreedomResult<RemovedCard> object, which can be either:RemovedCard object.createCardPayment method is used to initiate a payment using a previously tokenized (saved) card.createCardPayment is a two-stage process. After successfully calling this method, the created payment must be confirmed using either the confirmCardPayment or confirmDirectPayment method to finalize the transaction.| Parameter | Type | Description |
|---|---|---|
paymentRequest | TokenizedPaymentRequest | Essential details required to initiate a new payment with previously tokenized card. See TokenizedPaymentRequest model. |
onResult | (FreedomResult<PaymentResponse>) -> Unit | Callback function that will be invoked with the result of the payment initiation. See PaymentResponse model. |
FreedomResult<PaymentResponse> object, which can be either:PaymentResponse object.confirmCardPayment method is used to finalize a payment that was previously initiated with a saved card using createCardPayment.PaymentView has been set using freedomApi.setPaymentView() prior to calling it, as it will display a web-based form within the PaymentView for CVC entry and 3DS authentication.| Parameter | Type | Description |
|---|---|---|
paymentId | Long | Unique identifier of the payment to confirm. This paymentId is obtained from the createCardPayment method. |
onResult | (FreedomResult<PaymentResponse>) -> Unit | Callback function that will be invoked upon the completion of the payment process. See PaymentResponse model. |
FreedomResult<PaymentResponse> object, which can be either:PaymentResponse object.confirmDirectPayment method is used to finalize a payment that was previously initiated with a saved card using createCardPayment. Unlike confirmCardPayment, it does not open PaymentView: the client does not enter the CVC.| Parameter | Type | Description |
|---|---|---|
paymentId | Long | Unique identifier of the payment to confirm. This paymentId is obtained from the createCardPayment method. |
onResult | (FreedomResult<PaymentResponse>) -> Unit | Callback function that will be invoked with the result of the payment process. See PaymentResponse model. |
FreedomResult<PaymentResponse> object, which can be either:PaymentResponse object.WalletConstants.ENVIRONMENT_TEST): Google asks for screenshots of the payment flow.PaymentsClient to WalletConstants.ENVIRONMENT_PRODUCTION (see step 3) and make a payment with a real card.build.gradle.kts file:AndroidManifest.xml to enable the Google Pay API:<application>
...
<!-- Enables the Google Pay API -->
<meta-data android:name="com.google.android.gms.wallet.api.enabled"
android:value="true" />
</application>PayButton to your XML layout file where you want it to appear:<com.google.android.gms.wallet.button.PayButton
android:id="@+id/buttonPaymentByGoogle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>PaymentsClient in your activity:Wallet.getPaymentsClient method is used to get an instance of PaymentsClient. It has the following environments:| Parameter | Value |
|---|---|
ENVIRONMENT_PRODUCTION | Production environment |
ENVIRONMENT_TEST | Test environment |
createPaymentDataRequest() is a method that returns a PaymentDataRequest object. This object defines the parameters and requirements for the payment data request, such as payment methods, shipping address, and more.loadPaymentData() initiates an asynchronous task to load payment data using the provided request.AutoResolveHelper.resolveTask<PaymentData>()is used to handle the payment data loading task.REQUEST_CODE is a request code used to identify the result of the task in the onActivityResult method.createPaymentDataRequest():PaymentDataRequest.newBuilder() creates a new builder for the payment data request.setTransactionInfo() sets transaction information, such as the total payment amount and currency code.PaymentMethodTokenizationParameters.newBuilder() creates a builder for the payment method tokenization parameters.setPaymentMethodTokenizationType() sets the tokenization type (e.g., a payment gateway).addParameter() adds parameters for the payment gateway, such as gateway and gatewayMerchantId.setPaymentMethodTokenizationParameters() sets the tokenization parameters in the payment data request.onActivityResult method:onActivityResult is used to handle the results returned by the Google Pay integration activity.data is the object containing the data returned by the activity.Activity.RESULT_OK indicates the successful completion of the operation.AutoResolveHelper.RESULT_ERROR indicates that an error occurred while resolving the request.payWithGooglePay method is the final step in processing a Google Pay payment with the SDK. After you have obtained the Google Pay token (see Step 4.3), pass it to this method together with the payment details.PaymentView set with freedomApi.setPaymentView() before the call: see Integrating the PaymentView.PaymentView.PaymentView, the payment fails with PaymentViewIsNotInitialized.| Parameter | Type | Description |
|---|---|---|
paymentRequest | StandardPaymentRequest | Essential details required to make a payment. amount and currency must match the ones in your Google Pay request. See StandardPaymentRequest model. |
token | String | Encrypted payment token received from the Google Pay API. This token contains the sensitive card data securely. |
force3DS | Boolean | Optional. Defaults to false. Set to true to require 3-D Secure for this payment. |
onResult | (FreedomResult<PaymentResponse>) -> Unit | Callback function that will be invoked with the final result of the Google Pay payment. See PaymentResponse model. |
PaymentResponse object. Check its status:Success: the payment is completed.Error: the payment was declined (for example, 3-D Secure failed). The code and description explain why.PaymentView with the bank's page and hides it once the payment gets a final status. There is no time limit for the user to complete it.PaymentView (paymentView.visibility = View.GONE). The SDK then returns the latest known status.FreedomResult.Error.NetworkError, the payment may still have been made. Check its status by orderId before letting the user pay again. Always set orderId in StandardPaymentRequest.onResult callback) return their outcome encapsulated within a FreedomResult sealed interface.FreedomResult interface has two primary states: Success for successful completion and Error for any failures.value: T: Holds the actual result data of the operation. The type T will vary depending on the specific method called (e.g., PaymentResponse, List<Card>, Status).Error interface is a sealed hierarchy itself, providing distinct types of errors for more precise handling.amount out of range, userId format mismatch).errors: List<ValidationErrorType>: A list detailing all specific validation errors that occurred. For a comprehensive list of types, refer to the ValidationErrorType table.errorCode: Int: A numerical code representing a specific transaction error. You can find an up-to-date reference of error codes here.errorDescription: String?: A human-readable description of the transaction error, if available.Protocol: Indicates an issue with the communication protocol or an unexpected response from the API.code: Int: An HTTP status code or an internal protocol error code.body: String?: The raw response body or a human-readable description of the protocol error, if available.Connectivity: Indicates problems related to the device's network connection. This sealed interface includes the following specific errors:ConnectionFailed: The network connection could not be established.ConnectionTimeout: The network request timed out.Integrity: An issue with the integrity of the network connection (e.g., SSL/TLS certificate issues).Unknown: A general network error occurred that does not fall into more specific categories.SdkNotConfigured: The SDK is not configured.SdkCleared: The SDK methods were called after freedomApi.clear(), which clears the SDK state and stops further operations.ParsingError: An error occurred while parsing data (e.g., a response from the server could not be deserialized).WebView: Errors specifically related to the internal WebView component used for displaying payment pages or frames. This sealed interface includes the following specific errors:PaymentViewIsNotInitialized: A method requiring PaymentView was called, but freedomApi.setPaymentView() has not been called or the view is not ready.Failed: A general error occurred during the payment process within the WebView, without a more specific cause.StandardPaymentRequest data class encapsulates the essential details required to initiate a new payment transaction.| Parameter | Type | Description | Constraints/Notes |
|---|---|---|---|
amount | Float | Total amount of the payment. | Must be between 0.01 and 99999999.00. |
currency | Currency? | Currency of the payment. See Currency enum for available options. | Optional. Defaults to null. |
description | String | Description of the payment. | |
userId | String? | Identifier for the user making the payment. | Optional. Defaults to null. Must contain 1-50 characters. Also, must match regex ^[a-zA-Z0-9_-]+$. |
orderId | String? | Unique identifier for this payment order within your system. | Optional. Defaults to null. Must contain 1-50 characters. |
extraParams | HashMap<String, String>? | Optional map of additional key-value pairs to pass custom data with the payment. | Optional. Defaults to null. |
TokenizedPaymentRequest data class is used to create payments with a previously saved and tokenized card, requiring the card's unique token along with standard payment details.| Parameter | Type | Description | Constraints/Notes |
|---|---|---|---|
amount | Float | Total amount of the payment to be charged to the saved card.. | Must be between 0.01 and 99999999.00. |
currency | Currency? | Currency of the payment. See Currency enum for available options. | Optional. Defaults to null. |
description | String | Description of the payment. | |
cardToken | String | Unique token representing the saved card that will be used for this payment. This token is obtained from addNewCard or getAddedCards. | Must contain 1 or more characters. |
userId | String | Identifier for the user making the payment. | Must contain 1-50 characters. Also, must match regex ^[a-zA-Z0-9_-]+$. |
orderId | String | Unique identifier for this payment order within your system. | Must contain 1-50 characters. |
extraParams | HashMap<String, String>? | Optional map of additional key-value pairs to pass custom data with the payment. | Optional. Defaults to null. |
PaymentResponse data class represents the result of a payment operation: the payment IDs and the status, including Error.| Property | Type | Description |
|---|---|---|
status | PaymentResponse.Status | Status of the operation. |
paymentId | Long | Unique identifier for this payment. |
merchantId | String | ID of the merchant associated with the payment. |
orderId | String? | Order ID provided during payment creation. |
| Property | Type | Description |
|---|---|---|
New | data object | Payment has been created but no processing has started yet. |
Waiting | data object | Payment is pending further action or confirmation. |
Processing | data object | Payment is actively being handled by the system or provider. |
Incomplete | data object | Indicates that the payment was initiated but did not reach a final state within the allotted time. |
Success | data object | Payment was completed successfully and funds have been confirmed. |
Unknown(val value: String) | data class | Status value is not recognized by the SDK, possibly due to a new or unexpected status from the backend. |
Error(val code: String, val description: String) | data class | Payment failed, with an error code and description available for diagnosis. |
| Property | Type | Description |
|---|---|---|
status | String | Result of the request: always ok. An error is returned as FreedomResult.Error. |
paymentId | Long | Unique identifier for this payment. |
orderId | String? | Order ID provided during payment creation. |
currency | String | Currency code of the payment. |
amount | Float | Original amount of the payment. |
canReject | Boolean? | Indicates if the payment can still be cancelled. |
paymentMethod | String? | Payment method, for example bankcard or mobile_commerce; none if the client has not chosen it yet. |
paymentStatus | String? | Status of the payment: new, waiting, process, success or error. See Get payment status. |
clearingAmount | Float? | Total amount that has been cleared (captured) for this payment. |
revokedAmount | Float? | Total amount that has been cancelled for this payment. |
refundAmount | Float? | Total amount that has been refunded. |
cardName | String? | Name on the card used for the payment. |
cardPan | String? | Masked Primary Account Number (PAN) of the card. |
revokedPayments | List<RevokedPayment>? | List of individual cancelled transactions associated with this payment. |
refundPayments | List<RefundPayment>? | List of individual refund transactions associated with this payment. |
reference | Long? | System-generated reference number for the payment. |
captured | Boolean? | Indicates if the funds for the payment have been captured. |
createDate | String | Date and time when the payment was created. |
authorizationCode | String? | Authorization code for the payment, including alphanumeric values. |
authCode | Int? | Deprecated numeric authorization code. Use authorizationCode instead. |
failureCode | String? | Code indicating why the payment failed. |
failureDescription | String? | Human-readable reason for the payment failure. |
lastTransactionInfo | LastTransactionInfo? | Details of the most recent transaction associated with this payment. |
| Property | Type | Description |
|---|---|---|
paymentId | Long? | ID of the cancelled payment. |
paymentStatus | String? | Status of the cancel operation: success, process or error. |
| Property | Type | Description |
|---|---|---|
paymentId | Long? | ID of the refund payment. |
paymentStatus | String? | Status of the refund operation: success, process or error. |
amount | Float? | Amount that was refunded in this transaction. |
paymentDate | String? | Date and time of the refund. |
reference | Long? | System-generated reference number for the refund. |
| Property | Type | Description |
|---|---|---|
status | String | Status of the last transaction: waiting, process, success, error or incomplete. |
failureCode | String? | Code indicating why the transaction failed. |
failureDescription | String? | Human-readable reason for the transaction failure. |
| Type | Description |
|---|---|
Success(val amount: Float) | Indicates that the clearing operation was successful. amount: The amount that was successfully cleared. |
ExceedsPaymentAmount | Indicates that the requested clearing amount exceeded the originally authorized payment amount. |
Failed | Indicates that the clearing operation failed. |
| Property | Type | Description |
|---|---|---|
status | String? | Status of the operation. |
merchantId | String? | ID of the merchant. |
recurringProfileId | String? | ID assigned to a user's recurring payment profile |
cardToken | String? | Token used to reference this card for future payments. |
cardHash | String? | Masked Primary Account Number (PAN) of the card. |
createdAt | String? | Date and time when the card was added. |
| Property | Type | Description |
|---|---|---|
status | String? | Status of the operation. |
merchantId | String? | ID of the merchant. |
cardHash | String? | Masked Primary Account Number (PAN) of the card. |
deletedAt | String? | Date and time when the card was deleted. |
| Enum Constant | Description |
|---|---|
INVALID_MERCHANT_ID | Provided merchant ID is invalid or missing. |
INVALID_SECRET_KEY | Provided secret key is invalid or missing. |
INVALID_PAYMENT_AMOUNT | Payment amount is outside the allowed range (0.01 - 99999999.00). |
INVALID_ORDER_ID | Provided order ID does not meet the specified length constraints. |
INVALID_USER_ID | Provided user ID does not meet the specified format or length constraints. |
INVALID_CARD_TOKEN | Provided card token does not meet the specified length constraints. |
Currency enum defines all supported currency codes that can be used when specifying payment amounts.| Enum Constant | Description |
|---|---|
KZT | Kazakhstani tenge. |
RUB | Russian ruble. |
USD | US dollar. |
UZS | Uzbek sum. |
KGS | Kyrgyzstani som. |
EUR | Euro. |
HKD | Hong Kong dollar. |
GBP | British pound. |
AED | United Arab Emirates dirham. |
CNY | Chinese yuan. |
KRW | South Korean won. |
INR | Indian rupee. |
THB | Thai baht. |
UAH | Ukrainian hryvnia. |
AMD | Armenian dram. |
BYN | Belarusian ruble. |
PLN | Polish złoty. |
CZK | Czech koruna. |
AZN | Azerbaijani manat. |
GEL | Georgian lari. |
TJS | Tajikistani somoni. |
CAD | Canadian dollar. |
MDL | Moldovan leu. |
TRY | Turkish lira. |