You can use conekta-android for tokenize credit cards.
You have two methods to integrate conekta-android. Use artifacts or include our module.
The artifact contains everything you need to start.
This example uses mavenCentral to install the .aar (conektasdk) artefact.
repositories {
mavenCentral()
}
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'io.conekta:conektasdk:2.1'
}
Now just Sync gradle
This is an example about how to create Android Apps importing conekta module.
-
Clone this project
-
On your Android Studio go to:
File -> New -> Import Module
and findconektasdk
folder on your file system. -
Go to
File -> Project Structure...
, this will open a window, then choose on Modules section your app, then click on Dependencies tab, then click on + button, and on Module dependency dialog, chooseconektasdk
.
Just import all conekta classes from com.conekta namespace
// Your code....
import io.conekta.conektasdk.Conekta;
import io.conekta.conektasdk.Card;
import io.conekta.conektasdk.Token;
import org.json.JSONObject;
// Your code...
private Activity activity = this;
Conekta.setPublicKey("key_KJysdbf6PotS2ut2"); //Set public key
Conekta.setApiVersion("0.3.0"); //Set api version (optional)
Conekta.collectDevice(activity); //Collect device
Card card = new Card("Josue Camara", "4242424242424242", "332", "11", "2017");
Token token = new Token(activity);
token.onCreateTokenListener( new Token.CreateToken(){
@Override
public void onCreateTokenReady(JSONObject data) {
try {
//TODO: Create charge
Log.d("Token::::", data.getString("id"));
} catch (Exception err) {
//TODO: Handle error
Log.d("Error: " + err.toString());
}
}
});
token.create(card);//Create token
// Your code below....
Just add
-keep class com.conekta.** { ; }
Developed in Mexico by Conekta in. Available with MIT License.
If you are a comfortable working with a range of backend languages (Java, Python, Ruby, PHP, etc) and frameworks, you have solid foundation in data structures, algorithms and software design with strong analytical and debugging skills. Send us your CV and GitHub to [email protected]