Giter VIP home page Giter VIP logo

xendit-sdk-android's Introduction

xendit-sdk-android

The Xendit Android SDK makes it easy to collect sensitive credit card information without that data ever having to touch your server.

Requirements

The Xendit SDK is compatible with Android 2.3.3 and above.

Installation

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

Examples

Visit and try the app module to see an example of how the SDK works. Additionally, we've provided some examples below:

Initializing Xendit

Xendit xendit = new Xendit(getApplicationContext(), "xnd_public_development_O4uGfOR3gbOunJU4frcaHmLCYNLy8oQuknDm+R1r9G3S/b2lBQR+gQ==");

Creating a single-use token

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.

Creating a multiple-use token

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
    }
});

Creating a 3ds authentication

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
    }
});

Creating a charge

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

xendit-sdk-android's People

Contributors

0505gonzalez avatar afik avatar hakiemaul avatar

Watchers

James Cloos avatar ctianju avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.