SDK Integration

This article will guide you through the integration of a native payment experience in your mobile shop.

Accepting payment in your app involves 4 steps:

  1. Preparing checkout (configure with amount, currency and other information),
  2. Collecting shopper payment details,
  3. Creating and submitting transaction,
  4. Requesting payment result.

iOS and Android SDK provide tools to help you with steps 2 and 3.
For steps 1 and 4 you will need to communicate to your own backend API. These steps are not included in SDK API due to security reasons.

Demo app

You are welcome to get started with our demo application. You can start making test transactions without any efforts including setting up a server, we provide a test integration server for you. Please note, that it is configured for demo purposes only.

The demo app is provided along with SDK since version 2.5.0.

NOTE: Before running the application, make sure SDK files are copied to the demo app folder. Find more details in the readme.txt file.

Todo Java Script

Install the SDK

#import <OPPWAMobile/OPPWAMobile.h>

NOTE: If you integrate SDK to the Swift app, please see the Apple guide Importing Objective-C into Swift to check how to import Objective-C headers correctly.

In your checkout controller or wherever else you handle payments, create the OPPPaymentProvider variable and initialize it with test mode, e.g. in the viewDidLoad method:

Set Up Your Server

To start working with our SDK, you should expose two APIs on your backend for your app to communicate with:

  • Endpoint 1: Creating a checkout ID,
  • Endpoint 2: Getting result of payment.

See detailed instruction in our guide Set Up Your Server.

Request Checkout ID

Your app should request a checkout ID from your server. This example uses our sample integration server; please adapt it to use your own backend API.

Collect and validate shopper payment details

NOTE: To learn more about shopper result URL refer to Asynchronous payments guide.

You can also validate each parameter separately before creating an OPPPaymentParams object. iOS SDK provides convenience validation methods for each payment parameter. See code sample for card number validation:

[Optional] Brand detection for card payments

The system is able to automatically detect the brand by analyzing credit card number. The feature can be activated in BIP at ‘Administration’ -> ‘Processing’ -> ‘Processing Settings’ -> ‘Activate automatic brand detection for missing brands of credit card accounts’.

Since the mSDK version 2.25.0 you can create class="ios hidden">OPPCardPaymentParams without specifying a payment brand.
Use special constructor for it (sample below) or just pass empty string instead of payment brand in the standard constructor.

Submit a transaction

NOTE: To support asynchronous payments you need to make additional changes in your app. See Asynchronous payments tutorial for more details.

Request Payment Status

Finally your app should request the payment status from your server (again, adapt this example to your own setup).

To get resourcePath you should make additional request to the server.

Testing

The sandbox environment only accepts test payment parameters.

You can find test values for credit cards and bank accounts in our Testing Guide.

Go to Production

1. Talk to your account manager to get the live credentials.
3. Change your backend to use the correct API endpoints and credentials.

Note: Android

Install the SDK

// this name must match the library name defined with an include: in your settings.gradle file
implementation project(":oppwa.mobile")

implementation "androidx.appcompat:appcompat:x.x.x"
implementation "com.google.android.material:material:x.x.x"
implementation "com.google.android.gms:play-services-base:x.x.x"

3. In addition, declare the “INTERNET” permission before the application tag:

Set Up Your Server

To start working with our SDK, you should expose two APIs on your backend for your app to communicate with:

  • Endpoint 1: Creating a checkout ID,
  • Endpoint 2: Getting result of payment.

See detailed instruction in our guide Set Up Your Server.

Request Checkout ID

Your app should request a checkout ID from your server. This example uses our sample integration server; please adapt it to use your own backend API.

Collect and validate shopper payment details

NOTE: To learn more about shopper result URL refer to Asynchronous payments guide.

You can also validate each parameter separately before creating an PaymentParams object. Android mSDK provides convenience validation methods for each payment parameter. See code sample for card number validation:

[Optional] Brand detection for card payments

The system is able to automatically detect the brand by analyzing credit card number. The feature can be activated in BIP at ‘Administration’ -> ‘Processing’ -> ‘Processing Settings’ -> ‘Activate automatic brand detection for missing brands of credit card accounts’.

Since the mSDK version 2.25.0 you can create  class="android hidden">CardPaymentParams without specifying a payment brand.
Use special constructor for it (sample below) or just pass empty string instead of payment brand in the standard constructor.

Submit a transaction

NOTE: To support asynchronous payments you need to make additional changes in your app. See Asynchronous payments tutorial for more details.

NOTE: To avoid a ‘javax.net.ssl.SSLProtocolException: SSL handshake aborted’ on the devices running Android 4.4 (API level 19) and below you need to call installIfNeeded() method of the ProviderInstaller. You can place this call in your first Activity. See more info here.

NOTE: ServiceConnection service deprecated, please use OPPPaymentProvider instead.

Now, let the class implement the ITransactionListener interface. Implement the following ITransactionListener methods:

NOTE: The getErrorInfo() method of the PaymentError can be used to get more details about the error.

Request Payment Status

Finally your app should request the payment status from your server (again, adapt this example to your own setup).

To get the resourcePath you should make the additional request to the server.

Testing

The sandbox environment only accepts test payment parameters.

You can find test values for credit cards and bank accounts in our Testing Guide.

Go to Production

1. Talk to your account manager to get the live credentials.

Or simply init OPPPaymentPaymentProvider with ProviderMode.LIVE.

3. Change your backend to use the correct API endpoints and credentials.