The developer.datatrans.com Developer Hub

Welcome to the developer.datatrans.com developer hub. You'll find comprehensive guides and documentation to help you start working with developer.datatrans.com as quickly as possible, as well as support if you get stuck. Let's jump right in!

Mobile SDK

Accept payments on your iOS or Android apps: Our mobile SDKs support your entire payment and registration process and simplify the integration of any payment method in your mobile apps. Completely outsource your payment processes to us from inside your native apps. We also take care of redirecting your users to 3D Secure processes and enable smooth app switches to other payment applications including PayPal, Twint, and PostFinance.

Enhanced Support for App Clips (iOS) and Instant Apps (Android)!

Starting 2.0.0, the Mobile SDK for iOS and Android can now be linked to your projects with only third-party dependencies that are required in your project - that way the size of our SDK within your projects can be reduced. That will be useful for App Clips (iOS) and Instant Apps (Android)! Send us a message anytime by using this link if you have questions about our new SDKs. If you want to read what was renewed, please click here.

Process Overview

To start a transaction via our SDK, you will need to call our init endpoint ¹ to receive a mobileToken ². For any new operation you should retrieve a new mobileToken. A mobileToken is valid for 30 minutes. The mobileToken can now be sent to your mobile application and used to start the SDK ³. Once your customer completes the transaction ⁴ we will return the transaction information to your defined webhook and to the delegate ⁵ defined in your application.

Distribution & Download

Access the latest version of our SDKs by following the links below and link the latest release to your app projects.



Github Repository: Link
iOS SDK Reference: Link
Release Notes: Link

Supported iOS Versions: 11 +


JFrog Repository: Link
Android SDK Reference: Link
Release Notes: Link

Supported Android Versions: 5.0 +

Features

Easy Integration: Integrate many of our payment methods easily to your iOS and Android projects. Smart, modern and secure UI components to master online payments in your apps.

Card Scanner: Let your customers scan their card information easily with our prebuilt card scanner. No time wasted with entering card information.

3DS 2.0 / SCA Ready: The iOS and Android SDK takes over the complexity of the 3DS process. We remain in charge of redirecting users whenever 3D authentication is required to the 3DS process of their bank and back to the SDK.

Smooth App-Switch: Do you offer payment methods like Twint or PostFinance that require the user to confirm the payment in a separate mobile app? The library switches smoothly to external apps and back to the SDK.

Tokens and Fast Checkouts: Save your customers’ payment information for later use and offer fast checkouts in your app. Delegate the selection of a saved payment method to the library.

Theme Support: Style various items according to your corporate identity if needed. We also support the native dark theme of iOS and Android.

Easy Integration: Integrate many of our payment methods easily to your iOS & Android projects. Smart, modern and secure UI components to master online payments in your apps.

Card Scanner: Let your customers scan their card information easily with our prebuilt card scanner. No time wasted with entering card information.

3DS 2.0 / SCA Ready: The iOS & Android SDK takes over the complexity of the 3DS process. We remain in charge of redirecting users whenever 3D authentication is required to the 3DS process of their bank and back to the SDK.

Smooth App-Switch: Do you offer payment methods like Twint or PostFinance that require the user to confirm the payment in a separate mobile app? The library switches smoothly to external apps and back to the SDK.

Tokens and Fast Checkouts: Save your customers’ payment information for later use and offer fast checkouts in your app. Delegate the selection of a saved payment method to the library.

Theme Support: Style various items according to your corporate identity if needed. We also support the native dark theme of iOS and Android.

Initializing Transactions

To create a payment with our Mobile SDKs, you will need to initialize a mobileToken via a server-to-server call first. Call our init endpoint with your desired parameters and the option returnMobileToken and we'll return a mobileToken ready to be used with our SDKs. Please note that a mobileToken is only valid for 30 minutes. If you wish to do a dedicated registration, you must omit the parameter amount. Please read our section saving payment information for more details.

You need to specify at least one payment method during your init call to retrieve a mobileToken. If you do the preselection of the payment method on your end, simply send the array paymentMethods including only one payment method to directly show the final payment screen of that specific payment method. If you wish to display several payment methods on our Mobile SDK, you can simply extend the array with further payment methods. The order of the payment methods in your init call defines the order that is displayed in our SDKs.

If a payment method requires specific customer, shipping, or billing information, you may include it as well during your init payload. This is usually necessary for invoice payments.

curl 'https://api.sandbox.datatrans.com/v1/transactions' \
--header 'Authorization: Basic {{basicAuth}}' \
--header 'Content-Type: application/json' \
--data-raw '{
	"currency": "CHF",
	"refno": "Test-1234",
	"amount": 100,
	"paymentMethods": ["ECA","VIS","PAP","TWI"],
	"option": {
		"returnMobileToken": true
	}
}'

Now that you have retrieved a mobileToken, you can continue with the initialization of our iOS or Android SDK.

iOS Integration

For iOS, you can add the SDK to your project by adding a new Swift package dependency in Xcode. By default, enable all packages presented in the package selection. If you are building an App Clip project, you may select only your required packages, which will depend on your payment methods and flows. Please reach out to our support if you are unsure about what packages you required. Besides adding the packages via a Swift package dependency, you can also add the SDK via Cocoapods with pod 'Datatrans'.

Call the library with your mobile token to start a transaction. You can optionally specify further options and pass tokens for fast checkouts with our provided classes. Below is an example of the suggested minimum options to start a transaction with iOS (Swift, Objective-C). Please read our detailed class description for iOS to discover more initialization options.

let transaction = Transaction(mobileToken: String)
transaction.delegate = self // you must implement your TransactionDelegate here
transaction.options.appCallbackScheme = "your_scheme"
transaction.options.testing = true
transaction.options.useCertificatePinning = true
transaction.start(presentingController: navigationController)
DTTransaction* transaction = [[DTTransaction alloc] initWithMobileToken:mobileToken ];
transaction.delegate = self;  // you must implement your TransactionDelegate here
transaction.options.appCallbackScheme = @"your_scheme";
transaction.options.testing = YES;
transaction.options.useCertificatePinning = YES;
[transaction startWithPresentingController:self.navigationController];

Additional Requirements for iOS

For the card scanner to work, a usage description for the camera use will be required in your .plist file. If you do not provide a description for the camera use, the app will crash when starting the card scanner. If you are integrating Twint or PostFinance Card in your app, an automatic app switch to the payment application and back to the SDK will be possible. For iOS projects, however, you will have to add an array LSApplicationQueriesSchemes to your .plist file and the necessary schemes as Strings. This enables your iOS application to do an app switch to Twint or PostFinance applications.

#CameraUsage
Key    :  Privacy - Camera Usage Description   
Value  :  $(PRODUCT_NAME) requires camera access to scan cards.

#Twint
Key    :  LSApplicationQueriesSchemes
Value  :  [ ... , "twint-issuer1", "twint-issuer2", ... , "twint-issuer50" ]

#PostFinance
Key    :  LSApplicationQueriesSchemes
Value  :  [ ... , "postfinance-epayment" ]
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) requires camera access to scan cards.</string>
<key>LSApplicationQueriesSchemes</key>
<array>
	<string>twint-issuer1</string>
	<string>twint-issuer2</string>
	<string>twint-issuer3</string>
	<string>twint-issuer4</string>
	<string>twint-issuer5</string>
	<string>twint-issuer6</string>
	<string>twint-issuer7</string>
	<string>twint-issuer8</string>
	<string>twint-issuer9</string>
	<string>twint-issuer10</string>
	<string>twint-issuer11</string>
	<string>twint-issuer12</string>
	<string>twint-issuer13</string>
	<string>twint-issuer14</string>
	<string>twint-issuer15</string>
	<string>twint-issuer16</string>
	<string>twint-issuer17</string>
	<string>twint-issuer18</string>
	<string>twint-issuer19</string>
	<string>twint-issuer20</string>
	<string>twint-issuer21</string>
	<string>twint-issuer22</string>
	<string>twint-issuer23</string>
	<string>twint-issuer24</string>
	<string>twint-issuer25</string>
	<string>twint-issuer26</string>
	<string>twint-issuer27</string>
	<string>twint-issuer28</string>
	<string>twint-issuer29</string>
	<string>twint-issuer30</string>
	<string>twint-issuer31</string>
	<string>twint-issuer32</string>
	<string>twint-issuer33</string>
	<string>twint-issuer34</string>
	<string>twint-issuer35</string>
	<string>twint-issuer36</string>
	<string>twint-issuer37</string>
	<string>twint-issuer38</string>
	<string>twint-issuer39</string>
	<string>twint-issuer40</string>
	<string>twint-issuer41</string>
	<string>twint-issuer42</string>
	<string>twint-issuer43</string>
	<string>twint-issuer44</string>
	<string>twint-issuer45</string>
	<string>twint-issuer46</string>
	<string>twint-issuer47</string>
	<string>twint-issuer48</string>
	<string>twint-issuer49</string>
	<string>twint-issuer50</string>
  <string>postfinance-epayment</string>
</array>

To enable Apple Pay in your iOS projects, you will need to create an Apple merchant identifier, upload a certificate to your Datatrans merchant settings and activate the Apple Pay capability in XCode. Please refer to the section Apple Pay via Mobile SDK to correctly enable Apple Pay for your XCode project.

To correctly process PayPal transactions in your iOS projects, you will need to include an additional component from PayPal called 'PPRiskMagnes'. This is an optional library if you link our SDK via Swift Package Manager. If you linked the SDK via CocoaPods, the component will automatically be added to your project.

Android Integration

For Android projects, you can link the repo and dependencies via Gradle as demonstrated below.

repositories {
	...
	maven { url 'https://datatrans.jfrog.io/artifactory/mobile-sdk/' }
}

dependencies {
	...
	implementation 'ch.datatrans:android-sdk:2.0.0'
}

Call the library with your mobile token to start a transaction. You can optionally specify further options and pass tokens for fast checkouts with our provided classes. Below is an example of the suggested minimum options to start a transaction with Android (Kotlin, Java). Please read our detailed class description for Android to discover more initialization options.

val transaction = Transaction(mobileToken)
transaction.listener = this // this refers to Android's Activity
transaction.options.appCallbackScheme = "your_scheme"
transaction.options.isTesting = true
transaction.options.useCertificatePinning = true
TransactionRegistry.startTransaction(this, transaction)
Transaction transaction = new Transaction(mobileToken);
transaction.setListener(this); // this refers to Android's Activity
transaction.getOptions().setAppCallbackScheme("your_scheme");
transaction.getOptions().setTesting(true);
transaction.getOptions().setUseCertificatePinning(true);
TransactionRegistry.INSTANCE.startTransaction(this, transaction);

If you are building an Instant app, you may exclude specific packages that are not required in your project. This will depend on your payment methods and flows. Please reach out to our support if you are unsure about what packages you can exclude.

dependencies {
	...
	implementation ('ch.datatrans:android-sdk:2.0.0') {
		exclude group: 'io.card', module: 'android-sdk'
	}
}

The table below lists all the dependencies which can be excluded. Do not exclude a dependency if it is required by a payment method you included in your init request.

Feature
Group
Module

Credit Card Scanner

io.card

android-sdk

Google Pay

com.google.android.gms

play-services-wallet

PayPal

com.paypal.risk

android-magnessdk

Samsung Pay

com.samsung.android.sdk

samsungpay

Twint

ch.twint.payment

twint-sdk-android

Additional Requirements for Android

If you are integrating PayPal you must add various entries to your app manifest. You will run into technical issues if you do not define the requirements below.

For PayPal payments, an external web process is used. After this web process has finished, a callback to your app is issued. In order to receive this callback, you need to define the Datatrans relay activity with an intent filter in your AndroidManifest.xml for a defined scheme. Keep in mind that the URI scheme must be unique to the shopping app and the activity. Do not use actual protocols or file types such as http, mailto, pdf etc., or generic names such as ticket. An example would be the package name extended by an identifier dtsdk.

<activity
	android:name="ch.datatrans.payment.ExternalProcessRelayActivity"
	android:launchMode="singleTask"
	android:enabled="false"
	android:theme="@android:style/Theme.Translucent.NoTitleBar">
	<intent-filter>
		<action android:name="android.intent.action.VIEW" />
		<category android:name="android.intent.category.DEFAULT" />
		<category android:name="android.intent.category.BROWSABLE" />
		<data android:scheme="your.package.name.dtsdk" />
	</intent-filter>
</activity>

Auto Settlements

Settle your transactions automatically or in two steps with the parameter autoSettle during your init calls. If you do not specify anything in your init request, your transactions will not be settled automatically. Please refer to the section settling a transaction for more information on deferred settlements and the related server to server request.

"autoSettle": true

Saving Payment Information

Save card or payment method details after your customer has finalized their payment or registration. Not all payment methods support a registration with a payment. Please refer to our tokenization overview to see which payment methods require a dedicated registration. Please also read our section saving payment information for more details. Payment methods that do not support tokenization will be automatically omitted.

The payment method information will be returned by the SDK, in our webhook, and can be additionally retrieved by checking the status of a transaction.

"amount": 1000,	// Omit the parameter amount for dedicated registrations
"option": {
	"createAlias": true	// Required to save a card (not needed for dedicated registrations)
}

You can convert the returned SavedPaymentMethod class to a JSON object by using the function toJson.

Fast Checkouts

Fast checkouts or one-click checkouts can also be performed with our SDKs. For card payments, include the object card with alias, expiryMonth, and expiryYear in your init payload and we will continue with the authorization automatically once the SDK was initialized. This is useful for payments where you want your customers to complete a transaction quickly while also supporting 3D Secure. For other payment methods (eg. Twint, PayPal, or PostFinance Card) include the object of the payment method (eg. TWI) and the corresponding alias.

Only one payment method should be included in the array paymentMethods. You may also avoid calling the SDK with aliases for this to work properly.

"card": {
	"alias": "{{cardAlias}}",
	"expiryMonth": 12,
	"expiryYear": 25
},
"paymentMethods": ["VIS"]
"TWI": {
	"alias": "{{twintAlias}}"
},
"paymentMethods": ["TWI"]

Another option would be to start the SDK with the saved payment method selection screen.

Saved Payment Method Selection

Unlike our Redirect and Lightbox integration, you can call our SDK with previously saved payment methods (alias). You can even include multiple aliases per card brand (eg. two Visa aliases). This is useful if you want the user to finalize their payment with one click with a previously registered card. To initialize the library with an alias, you may refer to the class SavedPaymentMethod and its sub-classes (eg. SavedCard) for payment methods requiring more than just the alias to create a payment.

After the Transaction

After the transaction has been completed, you can refer to the class TransactionSuccess that will return the details of the transaction, including the payment method, the transaction unique identifier, and the token if one was created. If the transaction failed, you will have to refer to the class TransactionError for further details instead. You may also implement TransactionDelegate (iOS) and TransactionListener (Android) to be notified when a transaction is successfully finalized, encounters an error, or canceled by the user. We will also return the transaction information to your defined webhook.

Styling the Theme

You can style various colors in our Mobile SDKs to match your corporate identity. Check the graphic below to see what color properties can be defined. On iOS, you can define your preferred colors within the class ThemeConfiguration. On Android you can set theming options in your project’s color XML resource file, typically colors.xml. Use the color key names as defined in the table below.

Property
Description
iOS
Android

Background Color¹

Background color of the navigation bars. If this is not specified, the navigation bars will be transparent.

barBackgroundColor

dtpl_bar_background_color

Bar Link Color²

Color of the buttons in the navigation bars. If this is not specified, the color will be the color set in Link Color.

barLinkColor

dtpl_bar_link_color

Bar Title Color³

Color of the title within the navigation bars. If this is not specified, the color will be the text color. The text color is either white or black and cannot be customized.

barTitleColor

dtpl_bar_title_color

Button Color

Background color of large buttons, such as the Pay button. If this is not specified, the color will be the color set in Link Color.

buttonColor

dtpl_button_color

Button Text Color

Text color of large buttons, such as the Pay button. If this is not specified, the color will be set to white.

buttonTextColor

dtpl_button_text_color

Link Color

Color of text-only buttons or links and the text cursor. If this is not specified, the link color will be in a blue tone.

linkColor

dtpl_link_color

Webhook

After any transaction that was processed via our Mobile SDK integration, we will call your webhook with all relevant transaction information. You can define your webhook URL within your merchant configuration. We include our mobileToken in a HTTP header and a transactionId in the payload to let you match Mobile SDK transactions. Any server to server request to modify an existing transaction has to be made with our transactionId. Please refer to our page After The Payment for more information on actions you can make after a payment has been completed.

Within our SDK integration, your webhook will always be called synchronously after a transaction has been completed. Once your webhook has responded, the SDK will continue to the next state (success, error or cancel). We only try to call your webhook once. If it fails, no additional calls will be performed. Please let us know if we should call your webhook for registrations too as this is not active by default.

{
  "transactionId" : "{{transactionId}}",
  "type" : "payment",
  "status" : "authorized",
  "currency" : "CHF",
  "refno" : "Test-1234",
  "paymentMethod" : "ECA",
  "detail" : {
    "authorize" : {
      "amount" : 1000,
      "acquirerAuthorizationCode" : "113009"
    }
  },
  "customer" : {
    "firstName" : "Test",
    "lastName" : "Test"
  },
  "card" : {
    "alias" : "{{cardAlias}}",
    "masked" : "520000xxxxxx0007",
    "expiryMonth" : "12",
    "expiryYear" : "29",
    "info" : {
      "brand" : "MCI CREDIT",
      "type" : "credit",
      "usage" : "consumer",
      "country" : "MY",
      "issuer" : "DATATRANS"
    },
    "3D" : {
      "authenticationResponse" : "Y"
    }
  },
  "history" : [ {
    "action" : "init",
    "amount" : 1000,
    "source" : "api",
    "date" : "20XX-09-14T09:25:27Z",
    "success" : true,
    "ip" : "85.0.141.184"
  }, {
    "action" : "authorize",
    "amount" : 1000,
    "source" : "redirect",
    "date" : "20XX-09-14T09:25:26Z",
    "success" : true,
    "ip" : "85.0.141.184"
  } ]
}

Language Support

Our iOS and Android Mobile SDK integrations are currently translated and supported in the following languages:

English en

German de

French fr

Italian it

Please get in touch should you need an additional language to be added for your checkout or if you find a translation error.

Updated about 22 hours ago

Mobile SDK


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.