3DS Widget

Use Paydock's 3DS Widget to complete 3DS challenges. The 3DS Widget integrates with the Paydock JS client-sdk within a WebView component. Through this integration, your customer can authenticate the charge using the 3DS widget, which then communicates with the client-sdk, completes authentication and returns the charge event result. This also caters for both the Integrated 3DS and the Standalone 3DS flow.

iOS

How to use 3DS in your iOS application

1. Overview

The Three3DSView validates and authenticates the 3DS charge using the created 3DS token from your iOS app. This section provides a step-by-step guide on how to initialize and use the Three3DSView composable in your application.

The following sample code demonstrates the Three3DSView composable definition, as well as how to use it in your application:

ThreeDSView(
    token: String,
    baseURL: URL?,
    completionHandler: (ThreeDSResult) -> Void)

The widget returns an object that contains the status of the 3DS flow and the 3DS token.

2. Parameter definitions

MobileSDK.ThreeDSResult

NameDefinitionTypeMandatory/Optional
eventType of the event that happened in the 3DS flowEventTypeMandatory
charge3dsIdA 3DS IDStringMandatory

EventType enum represents all the possible outcomes of a 3DS flow allowing you to handle it.

MobileSDK.EventType

NameDefinitionTypeMandatory/Optional
chargeAuthSuccessRepresents a successful 3DS charge authorizationEnumCaseMandatory
chargeAuthRejectRepresents a rejected 3DS charge authorizationEnumCaseMandatory
chargeAuthChallengeRepresents a 3DS charge authorization with a challengeEnumCaseMandatory
chargeAuthDecoupledRepresents a decoupled 3DS charge authorizationEnumCaseMandatory
chargeAuthInfoRepresents an informational event related to a 3DS chargeEnumCaseMandatory
errorRepresents an unknown or unrecognized event typeEnumCaseMandatory

Android

How to use the 3DS Widget

1. Overview

This section provides a step-by-step guide on how to initialize and use the ThreeDSWidget composable in your application. The widget performs verifying payment using 3DS service.

The following sample code demonstrates the definition of the ThreeDSWidget:

@Composable
fun ThreeDSWidget(
    token: String,
    completion: (Result<ThreeDSResult>) -> Unit
) {...}

The following sample code example demonstrates the usage within your application:

// Initialize the GiftCardWidget
ThreeDSWidget(token = threeDSToken) { result ->
    result.onSuccess { threeDSResult ->
         // Handle success - Update UI or perform actions
        Log.d("ThreeDSWidget", "Payment successful. $threeDSResult")
    }.onFailure { exception ->
        // Handle failure - Show error message or take appropriate action
        Log.e("ThreeDSWidget", "Payment failed. Error: ${exception.message}")
    }
}

2. Parameter definitions

This subsection describes the various parameters required by the ThreeDSWidget composable. It provides information on the purpose of each parameter and its significance in configuring the behavior of the ThreeDSWidget.

ThreeDSWidget

Name Definition Type Mandatory/Optional
tokenThe 3DS token used for 3DS widget initialization.StringMandatory
completionResult callback with the 3DS authentication if successful, or error if not.(Result<ThreeDSResult>) -> UnitMandatory

ThreeDSResult

This subsection outlines the structure of the result or response object returned by the ThreeDSWidget composable. It details the format and components of the object, enabling you to handle the response effectively within your application.

The following sample code demonstrates the response structure:

data class ThreeDSResult(
    val event: EventType,
    val charge3dsId: String
)

Definition

Name Definition Type
eventThe type of event that occurred during 3DS processingEventType
charge3dsIdThe Charge ID associated with the 3DS transaction to return to the merchantString

EventType

Name Definition
CHARGE_AUTH_SUCCESSRepresents a successful 3DS charge authorization
CHARGE_AUTH_REJECTRepresents a rejected 3DS charge authorization
CHARGE_AUTH_CHALLENGERepresents a 3DS charge authorization with a challenge
CHARGE_AUTH_DECOUPLEDRepresents a decoupled 3DS charge authorization
CHARGE_AUTH_CHALLENGERepresents an informational event related to a 3DS charge
CHARGE_AUTH_INFORepresents an error event related to a 3DS charge
CHARGE_ERRORRepresents an unknown or unrecognized event type
UNKNOWNRepresents an unknown or unrecognized event type (default)

3. Callback Explanation

Completion Callback

The completion callback is invoked after the 3DS is completed. It receives a Result<ThreeDSResult> if the payment is authenticated. The callback is used to handle the outcome of the payment operation.