The Xendit Android SDK makes it easy to collect sensitive credit card information without that data ever having to touch your server.
The Xendit SDK is compatible with Android 2.3.3 and above.
Maven:
<dependency>
<groupId>com.xendit</groupId>
<artifactId>xendit-android</artifactId>
<version>1.1.0</version>
<type>pom</type>
</dependency>
Gradle:
compile 'com.xendit:xendit-android:1.1.0'
Ivy:
<dependency org='com.xendit' name='xendit-android' rev='1.1.0'>
<artifact name='xendit-android' ext='pom' ></artifact>
</dependency>
For more information, visit https://bintray.com/xendit/android/xendit-sdk-android
Visit and try the app
module to see an example of how the SDK works. Additionally, we've provided some examples below:
Xendit xendit = new Xendit(getApplicationContext(), "xnd_public_development_O4uGfOR3gbOunJU4frcaHmLCYNLy8oQuknDm+R1r9G3S/b2lBQR+gQ==");
Card card = new Card("4000000000000002", "12", "2017", "123");
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
}
});
createSingleUseToken
accept 4 parameters: Card
object, amount, an optional shouldAuthenticate
boolean, and a TokenCallback
. shouldAuthenticate
will be set to true if you don't pass this value.
Card card = new Card("4000000000000002", "12", "2017", "123");
xendit.createMultipleUseToken(card, 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
}
});
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
}
});
When you're ready to charge a card, use the private key on your backend to call the charge endpoint. See our API reference at https://xendit.github.io/apireference/#create-charge