TWINT Payment Integration with myPOS Smart SDK

TWINT is a widely used mobile payment method in Switzerland, allowing users to pay by scanning a QR code from their mobile app. With the myPOS Smart SDK, you can easily initiate and handle TWINT payments from your Android application.

Initiate a TWINT Payment

Use the following one-liner to launch a TWINT QR code payment screen:

MyPOSAPI.openTwintPaymentActivity(MainActivity.this, 10.0, Currency.CHF, TWINT_REQUEST_CODE);
  • 10.0 – Transaction amount
  • Currency.CHF – Currency (Swiss Franc)
  • TWINT_REQUEST_CODE – Request code to identify the transaction in onActivityResult

This method opens a screen that displays the TWINT QR code. The customer scans it to complete the payment.

Handle the Payment Result

Override onActivityResult() to handle the transaction result:

@Override
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();
                return;
            }

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

Best Practices

  • Always use a unique requestCode to identify the TWINT transaction.
  • Validate the result using transactionResult == TransactionProcessingResult.TRANSACTION_SUCCESS.
  • Use fallback logic or alternative payment prompts for failed or cancelled transactions.

Tip: TWINT is best suited for quick retail checkouts, restaurants, and contactless kiosk environments in Switzerland.