Initializing the Android SDK
In order to process 3DS card payments in your application, you need two components:
- The Paysafe API Client
- The ThreeDSecureService
Initializing the Paysafe API Client
The Paysafe API Client is the component that handles the HTTP communication with the Paysafe REST APIs. Pass the following parameters during its initialization from the application:
- Merchant User ID (registered Paysafe API Key username)
- Merchant Paysafe Password (registered Paysafe API Key password)
- Merchant Account Number (registered Paysafe Account Number)
- Environment (TEST/ LIVE)
There are a couple more things that you can set when creating a client, like the connection timeout and the request timeout. You can also enable/disable the logging of all HTTP requests and responses handled by the client. We strongly recommend enabling the logging for your test builds only and disable them in production. The logging is turned off by default.
Here is an example of initializing the Paysafe API Client:
PaysafeApiClient client = new PaysafeApiClient.Builder() .withApiKey(<Your Merchant User ID>) .withApiSecret(<Your Merchant Paysafe Password>) .withAccountId(<Your Merchant Account Number>) .withEnvironment(Environment.TEST) .withConnectionTimeout(<Timeout for new connections, 10 sec by default>) .withRequestTimeout(<Timeout for HTTP requests, 10 sec by default>) .withHttpLoggingEnabled(true) .build();
Initializing the ThreeDSecureService
The ThreeDSecureService provides the logic for generating a device fingerprint and handling an incoming 3DS challenge.
Here is an example of creating an instance of the ThreeDSecureService:
threeDSecureService = new ThreeDSecureService.Builder() .withContext(<Your app context>) .withApiClient(client) // the client from the previous step .build();
Optionally, you can provide customization options for the 3DS challenge screens when initializing the ThreeDSecureService.