Using Xendit Android SDK
Initiating Xendit Object
Before using the SDK, you need to instantiate Xendit object
...
Xendit xendit = new Xendit(getApplicationContext(), YOUR_PUBLIC_API_KEY);
...
Create Credit Card Token
To create token, you first need to create Card object, the information should be collected from your card form interface in your own application. To instantiate Card object you need:
- Credit card number
- Credit card expiry month (MM)
- Credit card expiry year (YYYY)
- Credit card verification number (3 numbers in the back)
...
Card card = new Card("4000000000000002", "12", "2017", "123");
...
After creating the object, you need to call createSingleUseToken or createMultipleUseToken depending on your use case. In case you use createSingleUseToken with shouldAuthenticate
parameter as true, you will also get authentication ID as the success response.
...
xendit.createSingleUseToken(card, 75000, true, new TokenCallback() {
@Override
public void onSuccess(Token token) {
// Handle successful tokenization
System.out.println("Token ID: " + token.getId());
}
@Override
public void onError(XenditError xenditError) {
// Handle error
}
});
...
Create Authentication (3DS)
For multiple use token, you need to separately call createAuthentication method using the token ID that you get from createMultipleUseToken method. During the authentication process, we will display a webview in front of your application for user to securely do the OTP (one time password) or any other means of authentication depending on the issuing bank.
String tokenId = "sample-token-id";
int amount = 50000;
xendit.createAuthentication(tokenId, amount, new AuthenticationCallback() {
@Override
public void onSuccess(Authentication authentication) {
// Handle successful authentication
System.out.println("Authentication ID: " + authentication.getId());
}
@Override
public void onError(XenditError xenditError) {
// Handle error
}
});
Dynamic 3DS
Dynamic 3DS is a way for you to authenticate a card when it is needed. So you can get higher conversion due to:
- Less one step to charge your end customer (only for card that has high success rate in purchasing)
We will notify you when to authenticate a card or not. You will get should_3ds as one of the response of our tokenization function from Android SDK, what you need to know about it:
- When the value is true, you need to authenticate this card
- When the value is false, you do not need to authenticate this card
Last Updated on 2023-06-02