Usage
Integrating iOS SDK
For more information, see Integrating iOS SDK,
/// - Parameters:
/// - apiKey: Paysafe API key
/// - environment: Paysafe environment
init(
apiKey: String,
environment: PaysafeEnvironment
)
Pass the following parameters:
Parameter | Required | Type | Description |
---|---|---|---|
apiKey | true | String | The Base64-encoded version of the single-use token API key is used to authenticate with the Payment Hub REST API. |
environment | true | PaysafeEnvironment | PaysafeEnvironment is an enum type with the following cases:
|
Example
let paysafe3DS = Paysafe3DS(
apiKey: "<api-key>",
environment: .production
)
Start challenge
Use your provider API or service to generate a paymentHandle.
Using the paymentHandle, you can start the 3DS challenge by calling the following method. It returns a publisher that publishes a String representing either the deviceFingerprintingId or a PSError object:
/// Paysafe3DS method used to initiate the 3D Secure flow.
///
/// - Note: Paysafe3DSOptions
/// * accountId: Merchants account id
/// * cardBin: Card bin
/// - Parameters:
/// - options: Paysafe3DSOptions
/// - Returns:Publisher that publishes a String representing the deviceFingerprintingId or a PSError.
/// - Note: PSError
/// * badRequest
/// * notFound
/// * serverError
/// * parsingError
/// * unknown
/// * threeDSServiceError
/// * threeDSUserCancelled
/// * threeDSTimeout
/// * threeDSFailedValidation
/// * threeDSUnknown
public func initiate3DSFlow(
using options: Paysafe3DSOptions
) -> AnyPublisher<String, PSError>
Paysafe3DS parameters
Parameter | Required | Type | Description |
---|---|---|---|
accountId | true | String | The id of the selected merchant account to use for processing the payment. If you are a merchant, this field is required only if you have more than one account configured for the same payment method and currency. If you are a partner using a shared API key, this field is mandatory. |
cardBin | true | String | This is the card Bank Identification Number (BIN). This is typically the first 6–8 digits of the card. |
Usage example
let threeDSOptions = Paysafe3DSOptions(
accountId: "<account-id>",
bin: "<card-bin or network-bin>"
)
paysafe3DS.initiate3DSFlow(
using: threeDSOptions
).flatMap { deviceFingerprintingId in
print(deviceFingerprintingId)
}
Once you have received the deviceFingerprintingId from the Paysafe mobile SDK you should include it in your Authentication request along with the other required fields and contextual data.
- See our full API documentation for a complete description of the parameters required for the Authentication request.
When the authentication is complete, Paysafe interprets the directory server response and returns a response containing the status and threeDResult* parameters along with the authenticationId.
- If status=COMPLETED, then you should consult the Liability Shift matrix to determine whether to proceed with the Authorization request.
- If status=PENDING and threeDResult=C then the card issuer has challenged the authentication request and requires additional verification. In this situation the merchant should continue with the challenge flow.
- You can find more details about this flows here: Paysafe Developer: Overview.
Challenge
Use your provider API or service to authenticate your deviceFingerprint to generate challengePayload and then launch 3DS Challenge.
Method signature
/// Start challenge for `pending` authentication status then finalize the authentication.
///
/// - Parameters:
/// - payload: SDK challenge payload provided by the /authentications endpoint, a base64 encoded string
public func startChallenge(
using payload: String?
) -> AnyPublisher<String, PSError>
Usage example
let challengePayload = ... // authenticating using the deviceFingerprintId
paysafe3DS.startChallenge(
using: challengePayload
).flatMap { authenticationId in
print("authenticationId")
}