Android SDK

A library is available to call credit check of customers in Android mobile apps. The whole process takes place in the same way as with the Twisto.js library on the web.

Just as on the web, you need to have encrypted data from your e-shop server. The public key is also used to identify requests.

The secret key must never get into the mobile application code. Perform all requests with the secret key only from the server.

Installation

If you are using a gradle, just add to the file build.gradle extra dependency:

dependencies { api 'cz.twisto.sdk.android:twisto:1.+' } repositories { maven { url "https://maven.twisto.cz" } }

Implementation

First, you need to initialize a class instance Twisto:

public class MainActivity extends AppCompatActivity { private Twisto twisto; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String publicKey = ""; // You can find your public key in administration twisto = new Twisto(this, new TwistoCheckCallback() { @Override public void onAccepted(String transactionId) { } @Override public void onRejected(String transactionId, String reason) { } @Override public void onError() { } }, publicKey); } }

After submitting the order data to the e-shop server, adding the previous orders data, and encrypting with secret key, the data will be sent back to the application where it will be passed to Twisto library. In the same activity is called Twisto.check method:

String payload = "…"; twisto.check(payload);

The method check will send customer data to Twisto servers and trigger asynchronous evaluation. Your requests, including error messages, can be found in the e-shop administration.

The evaluation ends by calling one of the TwistoCheckCallback interface methods:

  • onAccepted - the order was approved, the argument transactionId contains the transaction code used to create the order on the eshop server side.
  • onRejected - the order was declined, the argument reason contains the text of the error message that should be displayed to the user. The user should be offered an alternative payment method.
  • onError - an error occurred due to invalid request or connection failure.