For any question, we are one click away

Contact us

SDK Core process

Web View for 3DS

The diagram below shows the SDK Core payment process with 3DS redirect via Web View

sequenceDiagram participant MA as Mobile App participant MS as Mobile Server participant SDK as SDK participant PG as Payment Gateway participant ACS as ACS autonumber MA ->> MS: client creates an order MA ->> MA: client enters data MA -->> SDK: generate paymentToken MA ->> MS: send paymentToken to server MS ->> PG: call payment API alt Payment finished PG -->> MS: response with payment status (go to 14) else 3DS2 required PG -->> MS: response with 3DS redirect MS ->> MA: open Web View for 3DS MA ->> ACS: client enters password ACS -->> PG: redirect to Payment Gateway PG ->> PG: make payment PG -->> MA: redirect to returnUrl MA ->> MA: close Web View end opt Callback is configured PG -->> MS: webhook notification end MS ->> PG: check payment status MS ->> MA: show payment result to the client
  1. Client creates an order.

  2. Client fills in payment data in Mobile App.

  3. Mobile App calls SDK to create paymentToken. (Android: sdkCore.generateWithCard; iOS: CKCToken.generateWithCard)

    The public key used in the corresponding method is taken from the https://dev.bpcbt.com/payment/se/keys.do online resource. If multiple keys are available there, the first key should be used (note that the keys for UAT and production environments are different).

  4. Mobile App sends the paymentToken to Mobile Server.

  5. Mobile Server uses the paymentToken to make a payment via /payments request and saves unique payment Id that it gets in response.

    Pass paymentToken in paymentMethod -> card -> token parameter. Don't specify cvc, expiryMonth, expiryYear, and number parameters in this case.

  6. Mobile Server gets a response with no ACS redirect. It means that the payment is completed and we need to go to step 14.

  7. Mobile Server gets a response with ACS redirect.

  8. Mobile App opens Web View with ACS redirect data.

  9. Client enters their one time password to ACS form.

  10. ACS redirects the Client to Payment Gateway.

  11. Payment Gateway makes a payment.

  12. Payment Gateway redirects the Client to returnUrl, that can be used as a marker to close Web View.

  13. Mobile App closes Web View.

  14. Payment Gateway sends webhook notification to Merchant server (it must be configured by the Merchant in advance).

  15. Alternatively, the Merchant may get payment object and it's status by paymentId via /payments.

  16. Mobile App shows payment result to the Client.

IOS

iOS Integration

SDKCore.framework integration

You can integrate SDKCore.framework by adding it manually.

SDKCore.framework

Image 1. Adding the SDKCore.framework file

Image 2. Changing SDKCore.framework properties

Once done, import the framework in the ViewController.swift file.

//ViewController.swift
...
import SDKCore
...

How to work with API V2

External dependencies

For generation of the token, it is necessary to set the public key.

let publicKey: String =
    "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoIITqh9xlGx4tWA+aucb0V0YuFC9aXzJb0epdioSkq3qzNdRSZIxe/dHqcbMN2SyhzvN6MRVl3xyjGAV+lwk8poD4BRW3VwPUkT8xG/P/YLzi5N8lY6ILlfw6WCtRPK5bKGGnERcX5dqL60LhOPRDSYT5NHbbp/J2eFWyLigdU9Sq7jvz9ixOLh6xD7pgNgHtnOJ3Cw0Gqy03r3+m3+CBZwrzcp7ZFs41bit7/t1nIqgx78BCTPugap88Gs+8ZjdfDvuDM+/3EwwK0UVTj0SQOv0E5KcEHENL9QQg3ujmEi+zAavulPqXH5907q21lwQeemzkTJH4o2RCCVeYO+YrQIDAQAB-----END PUBLIC KEY-----"

Token generation method

let sdkCore = SdkCore()

  // TokenResult with NewPaymentMethod
  let newPaymentMethodParams = NewPaymentMethodParams(
       pan: "5536913776755304",
       cvc: "123",
       expiryMMYY: "12/22",
       cardholder: "Korotkov Alex",
       pubKey: publicKey
  )
  let newPaymentMethodConfig = SDKCoreConfig(
      paymentMethodParams: .newPaymentMethodParams(params: newPaymentMethodParams)
  )
  let tokenResult = sdkCore.generateWithConfig(config: newPaymentMethodConfig)

  // TokenResult with StoredPaymentMethod
  let storedPaymentMethodParams = StoredPaymentMethodParams(
      pubKey: publicKey,
      storedPaymentMethodId: "storedPaymentMethodId",
      cvc: "123"
  )
  let storedPaymentMethodConfig = SDKCoreConfig(
      paymentMethodParams: .storedPaymentMethodParams(params: storedPaymentMethodParams)
  )
  let tokenResult = sdkCore.generateWithConfig(config: storedPaymentMethodConfig)

iOS Configuration

Logging

Internal processes are logged with the SDKCore tag. You can also log your processes.

Logging is available through the Logger.shared object.

...
final class LoggerImplementation: LogInterface {

    func log(class: AnyClass, tag: String, message: String, exception: (any Error)?) {
        // Do something for logging
    }
}

Logger.shared.addLogInterface(logger: LoggerImplementation())
...

The default tag is SDKCore. You can set your own one if you like.

...
     Logger.shared.log(classMethod: type(of: self),
                       tag: "MyTag",
                       message: "My process...",
                       exception: nil)
...

Example Swift_core (no GUI)

Example of cryptogram formation

import UIKit
  import SDKCore

  final class MainViewController: UIViewController {

    private let cardNumberValidator = CardNumberValidator()
    private let cardExpiryValidator = CardExpiryValidator()
    private let cardCodeValidator = CardCodeValidator()
    private let cardHolderValidator = CardHolderValidator()
    private let sdkCore = SdkCore()

    private var cardNumberValidationResult: ValidationResult = .VALID
    private var cardExpiryValidationResult: ValidationResult = .VALID
    private var cardCodeValidationResult: ValidationResult = .VALID
    private var cardHolderValidationResult: ValidationResult = .VALID

    private func checkValidation() {
      cardNumberValidationResult = cardNumberValidator.validate(data: cardNumberValue)
      cardExpiryValidationResult = cardNumberValidator.validate(data: cardExpiryValue)
      cardCodeValidationResult = cardNumberValidator.validate(data: cardCodeValue)
      cardHolderValidationResult = cardNumberValidator.validate(data: cardHolderValue)
    }

    private func generateTokenResult() {
      let newPaymentMethodParams = NewPaymentMethodParams(
           pan: cardNumberValue,
           cvc: cardExpiryValue,
           expiryMMYY: cardExpiryValue,
           cardholder: cardHolderValue,
           pubKey: publicKey
      )

      let newPaymentMethodConfig = SDKCoreConfig(
          paymentMethodParams: .newPaymentMethodParams(params: newPaymentMethodParams)
      )
      let tokenResultWithNewPaymentMethod = sdkCore.generateWithConfig(config: newPaymentMethodConfig)


      let storedPaymentMethodParams = StoredPaymentMethodParams(
          pubKey: publicKey,
          storedPaymentMethodId: "storedPaymentMethodId",
          cvc: "123"
      )
      let storedPaymentMethodConfig = SDKCoreConfig(
          paymentMethodParams: .storedPaymentMethodParams(params: storedPaymentMethodParams)
      )
      let tokenResultWithStoredPaymentMethod = sdkCore.generateWithConfig(config: storedPaymentMethodConfig)
    }
  }

Models

NewPaymentMethodParams

Property nameData typeDefault valueOptionalDescription
panString-Nocard number
cvcString-Nosecret card code
expiryMMYYString-Noexpiry date for the card
cardHolderString-Yesfirst and last name of cardholder
pubKeyString-Nopublic key

StoredPaymentMethodParams

Property nameData typeDefault valueOptionalDescription
storedPaymentMethodIdString-Nonumber of a stored credential for the card
cvcString-Yessecret code for the card
pubKeyString-Nopublic key

TokenResult

Property nameData typeDefault valueOptionalDescription
tokenString-Yestoken as a string
errorsDictionary<ParamField, String>-Noerror while generating token

Field validation errors

ParamFieldErrorDescription
UNKNOWN-Unknown error
PANrequiredAn empty field is specified
invalidInvalid value
invalid-formatInvalid characters are used. Only numbers are available.
CVCrequiredAn empty field is specified
invalidInvalid value
EXPIRYrequiredAn empty field is specified
invalidInvalid value
invalid-formatThe format does not match the template MM/YY
CARDHOLDERrequiredAn empty field is specified
invalidInvalid value
invalid-formatInvalid characters are used. Only characters and spaces are available.
PUB_KEYrequiredAn empty field is specified
STORED_PAYMENT_METHOD_IDinvalidInvalid value
requiredAn empty field is specified

How to work with API V1

External dependencies

For generation of the token, it is necessary to set the public key.

let publicKey: String =
      "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoIITqh9xlGx4tWA+aucb0V0YuFC9aXzJb0epdioSkq3qzNdRSZIxe/dHqcbMN2SyhzvN6MRVl3xyjGAV+lwk8poD4BRW3VwPUkT8xG/P/YLzi5N8lY6ILlfw6WCtRPK5bKGGnERcX5dqL60LhOPRDSYT5NHbbp/J2eFWyLigdU9Sq7jvz9ixOLh6xD7pgNgHtnOJ3Cw0Gqy03r3+m3+CBZwrzcp7ZFs41bit7/t1nIqgx78BCTPugap88Gs+8ZjdfDvuDM+/3EwwK0UVTj0SQOv0E5KcEHENL9QQg3ujmEi+zAavulPqXH5907q21lwQeemzkTJH4o2RCCVeYO+YrQIDAQAB-----END PUBLIC KEY-----"

Token generation method

let sdkCore = SdkCore()

let cardParams = CardParams(
     pan: "4111111111111111",
     cvc: "123",
     expiryMMYY: "12/28",
     cardholder: "John Smith",
     mdOrder: "mdOrder",
     pubKey: publicKey
)

let cardParamsConfig = SDKCoreConfig(
    paymentMethodParams: .cardParams(params: cardParams)
)
let tokenResult = sdkCore.generateWithConfig(config: cardParamsConfig)

let bindignParams = BindingParams(
    pubKey: publicKey,
    bindingId: "das",
    cvc: "123",
    mdOrder: "mdOrder"
)
let bindingParamsConfig = SDKCoreConfig(
    paymentMethodParams: .bindingParams(params: bindignParams)
)
let tokenResult = sdkCore.generateWithConfig(config: bindingParamsConfig)

Models

CardParams

Property nameData typeDefault valueOptionalDescription
mdOrderString-Noorder number
panString-Nocard number
cvcString-Nosecret card code
expiryMMYYString-Noexpiry date for the card
cardHolderString-Yesfirst and last name of cardholder
pubKeyString-Nopublic key

BindingParams

Property nameData typeDefault valueOptionalDescription
mdOrderString-Noorder number
bindingIdString-Nonumber of a stored credential for the card
cvcString-Yessecret code for the card
pubKeyString-Nopublic key

Field validation errors

ParamFieldErrorDescription
UNKNOWN-Unknown error
PANrequiredAn empty field is specified
invalidInvalid value
invalid-formatInvalid characters are used. Only numbers are available.
CVCrequiredAn empty field is specified
invalidInvalid value
EXPIRYrequiredAn empty field is specified
invalidInvalid value
invalid-formatThe format does not match the template MM/YY
CARDHOLDERrequiredAn empty field is specified
invalidInvalid value
invalid-formatInvalid characters are used. Only characters and spaces are available.
BINDING_IDrequiredAn empty field is specified
invalidInvalid value
MD_ORDERrequiredAn empty field is specified
invalidInvalid value
PUB_KEYrequiredAn empty field is specified

Android

Android Integration

Connecting to a Gradle project by adding .aar library files

You must add the sdk_core-release.aar library file to the libs folder, then specify the dependency of the added library.

build.gradle.kts

allprojects {
    repositories {
        // ...
        flatDir {
            dirs("libs")
        }
    }
}

dependencies {
    // dependency is mandatory to add
    implementation(group = "", name = "sdk_core-release", ext = "aar")
}

build.gradle

allprojects {
    repositories {
        // ...
        flatDir {
            dirs 'libs'
        }
    }
}

dependencies {
    // dependency is mandatory to add
    implementation(group: '', name: 'sdk_core-release', ext: 'aar')
}

How to work with API V2

External dependencies

For generation of the token it is necessary to set the public key.

val publicKey: String =
    "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoIITqh9xlGx4tWA+aucb0V0YuFC9aXzJb0epdioSkq3qzNdRSZIxe/dHqcbMN2SyhzvN6MRVl3xyjGAV+lwk8poD4BRW3VwPUkT8xG/P/YLzi5N8lY6ILlfw6WCtRPK5bKGGnERcX5dqL60LhOPRDSYT5NHbbp/J2eFWyLigdU9Sq7jvz9ixOLh6xD7pgNgHtnOJ3Cw0Gqy03r3+m3+CBZwrzcp7ZFs41bit7/t1nIqgx78BCTPugap88Gs+8ZjdfDvuDM+/3EwwK0UVTj0SQOv0E5KcEHENL9QQg3ujmEi+zAavulPqXH5907q21lwQeemzkTJH4o2RCCVeYO+YrQIDAQAB-----END PUBLIC KEY-----"

Token generation method

val context: Context //android context for getting string resources
val sdkCore: SDKCore = SDKCore(context)

// TokenResult with NewPaymentMethod
val newPaymentMethodCardParams = NewPaymentMethodCardParams(
       pan = "4111111111111111",
       cvc = "123",
       expiryMMYY = "12/28",
       cardHolder = "John Smith",
       pubKey= publicKey
  )
val newPaymentMethodConfig = SDKCoreConfig(paymentCardParams = newPaymentMethodCardParams)
val tokenResult = sdkCore.generateWithConfig(config = newPaymentMethodConfig)

// TokenResult with NewPaymentMethodStoredCard
val newPaymentMethodStoredCardParams = NewPaymentMethodStoredCardParams(
      pubKey = publicKey,
      storedPaymentId = "storedPaymentMethodId",
      cvc = "123"
  )
val storedPaymentMethodConfig = SDKCoreConfig(paymentCardParams = newPaymentMethodStoredCardParams)
val tokenResult = sdkCore.generateWithConfig(config = storedPaymentMethodConfig)

Android Configuration

Logging

Internal processes are logged with the SDK-Core tag. You can also log your processes.

Logging is available through the Logger object.

...
    Logger.addLogInterface(object : LogInterface {
        override fun log(classMethod: Class<Any>, tag: String, message: String, exception: Exception?) {
                Log.i(tag, "$classMethod: $message", exception)
            }
        })
...

The default tag is SDK-Core. You can set your own one if you like.

...
     Logger.log(this.javaClass, "MyTag", "My process...", null)
...

Example Kotlin_core (no GUI)

Example of cryptogram formation

import net.payrdr.mobile.payment.sdk.core.SDKCore
import net.payrdr.mobile.payment.sdk.core.TokenResult
import net.payrdr.mobile.payment.sdk.core.model.BindingParams
import net.payrdr.mobile.payment.sdk.core.model.CardParams
import net.payrdr.mobile.payment.sdk.core.validation.BaseValidator
import net.payrdr.mobile.payment.sdk.core.validation.CardCodeValidator
import net.payrdr.mobile.payment.sdk.core.validation.CardExpiryValidator
import net.payrdr.mobile.payment.sdk.core.validation.CardHolderValidator
import net.payrdr.mobile.payment.sdk.core.validation.CardNumberValidator
import net.payrdr.mobile.payment.sdk.core.validation.OrderNumberValidator

class MainActivity : AppCompatActivity() {
    // initialization of validators for card information entry fields
    private val cardNumberValidator by lazy { CardNumberValidator(this) }
    private val cardExpiryValidator by lazy { CardExpiryValidator(this) }
    private val cardCodeValidator by lazy { CardCodeValidator(this) }
    private val cardHolderValidator by lazy { CardHolderValidator(this) }
    private val orderNumberValidator by lazy { OrderNumberValidator(this) }
    private val sdkCore by lazy { SDKCore(context = this) }

    override fun onCreate(savedInstanceState: Bundle?) {
        // installation of validators on the card information entry fields
        cardNumberInput.setupValidator(cardNumberValidator)
        cardExpiryInput.setupValidator(cardExpiryValidator)
        cardCodeInput.setupValidator(cardCodeValidator)
        cardHolderInput.setupValidator(cardHolderValidator)
        mdOrderInput.setupValidator(orderNumberValidator)

        // creation of an object and initialization of fields for a new card
        val params = NewPaymentMethodCardParams(
            pan = cardNumberInput.text.toString(),
            cvc = cardCodeInput.text.toString(),
            expiryMMYY = cardExpiryInput.text.toString(),
            cardHolder = cardHolderInput.text.toString(),
            pubKey = pubKeyInput.text.toString()
        )
        // method call to get the cryptogram for a new card
        sdkCore.generateWithConfig(SDKCoreConfig(params))

        // Creation of an object and initialization of fields for the linked card
        val params = NewPaymentMethodStoredCardParams(
            storedPaymentId = "storedPaymentMethodId",
            cvc = "123",
            pubKey = pubKeyInput.text.toString()
        )
        // method call to get the cryptogram for the linked card
        sdkCore.generateWithConfig(SDKCoreConfig(params))
    }
}

Models

NewPaymentMethodCardParams

Property nameData typeDefault valueOptionalDescription
panString-Nocard number
cvcString-Nosecret card code
expiryMMYYString-Noexpiry date for the card
cardHolderString-Nofirst and last name of the cardholder
pubKeyString-Nopublic key

NewPaymentMethodStoredCardParams

Property nameData typeDefault valueOptionalDescription
storedPaymentIdString-Nonumber of a stored credential for the card
cvcString-Nosecret code for the card
pubKeyString-Nopublic key

TokenResult

Property nameData typeDefault valueOptionalDescription
tokenString-Notoken as string
errorsMap<ParamField, String>-Noerror while generating token

Field validation errors

ParamFieldErrorDescription
PANrequiredAn empty field is specified
invalidInvalid value
invalid-formatInvalid characters are used. Only numbers are available.
CVCrequiredAn empty field is specified
invalidInvalid value
EXPIRYrequiredAn empty field is specified
invalidInvalid value
invalid-formatThe format does not match the template MM/YY.
CARDHOLDERrequiredAn empty field is specified
invalidInvalid value
invalid-formatInvalid characters are used. Only characters and spaces are available.
PUB_KEYrequiredAn empty field is specified
STORED_PAYMENT_IDrequriredAn empty field is specified
invalidInvalid value

How to work with API V1

External dependencies

For generation of the token, it is necessary to set the public key.

val publicKey: String =
    "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoIITqh9xlGx4tWA+aucb0V0YuFC9aXzJb0epdioSkq3qzNdRSZIxe/dHqcbMN2SyhzvN6MRVl3xyjGAV+lwk8poD4BRW3VwPUkT8xG/P/YLzi5N8lY6ILlfw6WCtRPK5bKGGnERcX5dqL60LhOPRDSYT5NHbbp/J2eFWyLigdU9Sq7jvz9ixOLh6xD7pgNgHtnOJ3Cw0Gqy03r3+m3+CBZwrzcp7ZFs41bit7/t1nIqgx78BCTPugap88Gs+8ZjdfDvuDM+/3EwwK0UVTj0SQOv0E5KcEHENL9QQg3ujmEi+zAavulPqXH5907q21lwQeemzkTJH4o2RCCVeYO+YrQIDAQAB-----END PUBLIC KEY-----"

Token generation method

// TokenResult with CardParams
val cardParams: CardParams = CardParams(
    mdOrder = "mdOrder",
    pan = "4111111111111111",
    cvc = "123",
    expiryMMYY = "12/28",
    cardHolder = "John Smith",
    pubKey = "publicKey"
)
val tokenResult = sdkCore.generationWithConfig(paymentCardParams = cardParams)

// TokenResult with BindingParams
val bindingParams: BindingParams = BindingParams(
    mdOrder = "mdOrder",
    bindingID = "das",
    cvc = "123",
    pubKey = "publicKey"
)

val tokenResult = sdkCore.generationWithConfig(paymentCardParams = bindingParams)
Categories:
eCommerceSDKAPI V2
Categories
Search results