This repository provides a step by step documentation for SumUp's native Android SDK, that enables you to integrate our proprietary card terminal(s) and its payment platform to accept credit and debit card payments (incl. VISA, MasterCard, American Express and more). The SDK communicates transparently to the card terminal(s) via Bluetooth (BLE 4.0). Upon initiating a checkout, the SDK guides your user using appropriate screens through each step of the payment process. As part of the process, SumUp provides also the card terminal setup screen, along with the cardholder signature verification screen. The checkout result is returned with the relevant data for your records.
No sensitive card data is ever passed through to or stored on the merchant’s phone. All data is encrypted by the card terminal, which has been fully certified to the highest industry standards (PCI, EMV I & II, Visa, MasterCard & Amex).
For more information about SumUp developer products, please refer to our SumUp API documentation.
minSdkVersion
26 or latertargetSDK
31 or laterAdd the repository to your gradle dependencies:
allprojects {
repositories {
maven { url 'https://maven.sumup.com/releases' }
}
}
Add the dependency to a module:
implementation 'com.sumup:merchant-sdk:5.0.3'
Initialize the SumUp components in your app:
public class SampleApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
SumUpState.init(this);
}
}
Before calling any features of the SumUp SDK, a registered SumUp merchant account needs to be logged in. Please go to https://me.sumup.com/developers to retrieve your Affiliate Key by entering the application ID of your app. (e.g. com.sumup.sdksampleapp)
SumUpLogin sumupLogin = SumUpLogin.builder(mAffiliateKey).build();
SumUpAPI.openLoginActivity(MainActivity.this, sumupLogin, 1);
Note: It is also possible to login an account with a token, without the user entering their SumUp login credentials in the SDK. Please refer to section Transparent Authentication
Once logged in, you can start using the SumUp SDK to accept card payments. If no account is logged in, SumUpAPI.Response.ResultCode.ERROR_NOT_LOGGED_IN
will be returned.
SumUpPayment payment = SumUpPayment.builder()
// mandatory parameters
.total(new BigDecimal("1.12")) // minimum 1.00
.currency(SumUpPayment.Currency.EUR)
// optional: to be used only if the card reader supports the feature, what can be checked with `SumUpApi.isTipOnCardReaderAvailable()`
.tipOnCardReader()
// optional: include a tip amount in addition to the total, ignored if `tipOnCardReader()` is present
.tip(new BigDecimal("0.10"))
// optional: add details
.title("Taxi Ride")
.receiptEmail("customer@mail.com")
.receiptSMS("+3531234567890")
// optional: Add metadata
.addAdditionalInfo("AccountId", "taxi0334")
.addAdditionalInfo("From", "Paris")
.addAdditionalInfo("To", "Berlin")
// optional: foreign transaction ID, must be unique!
.foreignTransactionId(UUID.randomUUID().toString()) // can not exceed 128 chars
// optional: skip the success screen
.skipSuccessScreen()
// optional: skip the failed screen
.skipFailedScreen()
.build();
SumUpAPI.checkout(MainActivity.this, payment, 2);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 2 && data != null) {
// Handle the response here
}
}
Several response fields are available when the callback activity is called:
The response flags are provided within the Bundle that is passed back to the callback activity:
int resultCode = getIntent().getExtras().getInt(SumUpAPI.Response.RESULT_CODE);
When a merchant is logged in, you can open this activity to access all the settings and options related to the card reader.
SumUpAPI.openCardReaderPage(MainActivity.this, 4);
prepareForCheckout()
offers the possibility to connect the card reader ahead of initiating the checkout which speeds up the overall checkout time.
To call this method, user needs to be logged in with a SumUp account and their card reader should already be setup. Next, call prepareForCheckout()
before initiating a checkout.
Note: Air and Solo card readers remain connected via BLE after each transaction while
prepareForCheckout()
is used when the card reader becomes disconnected (e.g. the reader is out of range, the host app looses focus, or the reader is turned off).
When setting up the SumUpPayment
object, the following optional parameters can be included:
A tip amount can be processed in addition to the total
using the tip
parameter. The tip amount will then be shown during the checkout process and be included in the response. Please note that a tip amount cannot be changed during/after the checkout.
This allows the customer to add a tip directly on the card reader, rather than prompting for a tip amount on the Android device.
A tip amount can be prompted directly in the card reader by using tipOnCardReader
parameter, if the card reader supports tipping. See example here for the field tipOnCardReader
.
Note: Not all card readers support this feature. To find out if the feature is supported for the last-saved card reader, you should always check
SumUpApi.isTipOnCardReaderAvailable()
. You must handle this case yourself in order to avoid no tip from being prompted. Please also note that if bothtip
andtipOnCardReader
are called then onlytipOnCardReader
amount will be considered during checkout if available.
The configureRetryPolicy()
feature allows you to set custom retry parameters for transaction result retrieval, using pollingInterval
, maxWaitingTime
, and disableBackButton
.
pollingInterval
and maxWaitingTime
should be provided in milliseconds, with default values of 2000 ms and 60000 ms, respectively. Setting disableBackButton
to true disables the back button during retries.maxWaitingTime
elapses with no result, the SDK returns SumUpAPI.ResultCode.ERROR_UNKNOWN_TRANSACTION_STATUS
. Pressing the back button (if enabled) during retries will also trigger this error.pollingInterval
exceeds maxWaitingTime
, maxWaitingTime
will automatically be adjusted to match. Negative values for either parameter default to 0.configureRetryPolicy()
is not used, the SDK defaults to returning SumUpAPI.ResultCode.ERROR_TRANSACTION_FAILED
.When using the SumUp payment as shown below:
SumupPayment.builder()
...
.foreignTransactionId(UUID.randomUUID().toString())
.configureRetryPolicy(2000, 60000, true)
.build();
If there are connectivity issues and the transaction status can not be retrieved, the API will return ERROR_UNKNOWN_TRANSACTION_STATUS
. In such cases, you can query the transaction status by calling SumUp transaction status API using the specified foreignTransactionId
.
The foreignTransactionID
identifier will be associated with the transaction and can be used to retrieve details related to the transaction. See API documentation for details. Please make sure that this ID is unique within the scope of the SumUp merchant account and sub-accounts. It must not be longer than 128 characters.
The foreignTransactionID is available when the callback activity is called: SumUpAPI.Param.FOREIGN_TRANSACTION_ID
To skip the success screen shown at the end of a successful transaction, the skipSuccessScreen
parameter can be used. When using this parameter your application is responsible for displaying the transaction result to the customer. In combination with the Receipts API your application can also send your own receipts, see API documentation for details. Please note success screens will still be shown when using the SumUp Air Lite readers.
To skip the failed screen shown at the end of a failed transaction, the skipFailedScreen
parameter can be used. When using this parameter your application is responsible for displaying the transaction result to the customer. Please note failed screens will still be shown when using the SumUp Air Lite readers.
To authenticate an account without the user typing in their SumUp credentials each time, you can generate an access token using OAuth2.0 and use it to transparently login to the SumUp SDK.
SumUpLogin sumupLogin = SumUpLogin.builder(mAffiliateKey).accessToken("MY_ACCESS_TOKEN").build();
SumUpAPI.openLoginActivity(MainActivity.this, sumupLogin, 1);
For information about how to obtain a token, please see the API Documentation.
If the token is invalid, SumUpAPI.Response.ResultCode.ERROR_INVALID_TOKEN
will be returned.
If a merchant account is currently logged in, it is possible to retrieve the data for this account.
if (!SumUpAPI.isLoggedIn()) {
// no merchant account currently logged in
} else {
Merchant currentMerchant = SumUpAPI.getCurrentMerchant();
}
SumUpAPI.logout();
buildTypes {
release {
// All ProGuard rules required by the SumUp SDK are packaged with the library
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
The SDK supports Google Location Services, to improve location accuracy and reduce power consumption.
In order to use it you need to add the dependency in build.gradle file
implementation "com.google.android.gms:play-services-location:19.0.1"
If the GLS dependency is not added to the project or Google Play Services are not installed on the mobile device the SumUp SDK will determine the location with the default Location Service provided by Android.
NOTE: Using GLS version 19.0.1 is recommended.
The following functions are handled by the SumUp APIs: