TWINT is a popular mobile payment method in Switzerland. Users can connect their bank account or cards with the TWINT application, and pay with TWINT by scanning a QR code.


You can easily initiate a TWINT payment from your application by using only one line of code:


MyPOSAPI.openTwintPaymentActivity(MainActivity.this, 10.0, Currency.CHF, TWINT_REQUEST_CODE);


This will open a screen displaying the TWINT QR code that the client should scan.


After the client has completed the payment, you can handle the results back in your application with the following code:


protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    // The same request code as when calling MyPOSAPI.openTwintPaymentActivity
    if (requestCode == TWINT_REQUEST_CODE) {

        // The transaction was processed, handle the response
        if (resultCode == RESULT_OK) {
            if (data == null) {
                // Something went wrong and the result couldn't be returned properly
                Toast.makeText(this, "Payment failed", Toast.LENGTH_SHORT).show();

            int transactionResult = data.getIntExtra("status", TransactionProcessingResult.TRANSACTION_FAILED);

            Toast.makeText(this, "Twint transaction has completed. Result: " + transactionResult, Toast.LENGTH_SHORT).show();

            // TODO: handle each transaction response accordingly
            if (transactionResult == TransactionProcessingResult.TRANSACTION_SUCCESS) {
                // Transaction is successful
	        // Add your own relevant business logic for when the payment succeeds

        } else {
            // The user cancelled the transaction
            Toast.makeText(this, "Twint cancelled", Toast.LENGTH_SHORT).show();