Thawani Lamsa SDK (Android)
  • 📗Thawani Lamsa SDK (Android)
Powered by GitBook
On this page
  • Minimum Requirement
  • Get your Auth keys
  • Configure SDK in your app
  • Initiate the payment
  • Handling the Result

Thawani Lamsa SDK (Android)

You can integrate the Thawani Lamsa SDK (Tap & Pay) into your Android application.

Last updated 1 month ago

Minimum Requirement

  • Android devices with Build-in NFC (Near Field Communication)

  • Android minimum SDK 26

Get your Auth keys

Register your business with and create your branch and touchpoints. After creating a touchpoint, you can obtain an authorization key. Please note that the authorization key is the same as the touchpoint key.

Configure SDK in your app

Step 1: Add dependency resolution to your settings.gradle:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        // Add this line here
        maven {
            name = "GitHubPackages"
            url = uri("https://maven.pkg.github.com/ThawaniMobile/Lamsa-SDK")
            credentials {
                username = "ThawaniMobile"
                password = "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"
            }
        }
    }
}

Step 2: Add dependency in your build.gradle (App Level):

// Enable dataBinding
android {
    ...
    buildFeatures {
        dataBinding true
    }
}

// Add Thawani lamsa SDK dependency
dependencies {
    implementation("om.thawani:lamsa.sdk:0.0.22")
}

Step 3: Add Lamsa activity to your manifest.xml

<activity
    android:name="om.thawani.lamsa.sdk.LamsaSDK"
    android:parentActivityName=".MainActivity"
    android:theme="@style/Theme.LamsaSDK">
</activity>

Step 4: (conditional) if minifyEnabled true in your build.gradle:app please add this line in your proguard-rules.pro file

-keep class om.thawani.lamsa.sdk.**{*;}

Initiate the payment

Initiate the Lamsa SDK from your app

val intent = Intent(this, LamsaSDK::class.java)
val args = InitOptionsModel(
    amount = 1.0,
    authKey = "wjOcN7XEG7q6vlSWO15QRRRjn3JI8mimxGwANT38",
    remarks = "This payment from Thawani SDK", 
    isProduction = false,
    paymentOption = paymentOption.CARD_ACCEPT,
    autoCloseInMillis = 3000 //Optional, auto close after 3 second
)
intent.putExtra("SDKInitOptions", args)
this.startActivityForResult(intent, LAMSA_REQUEST_CODE)

Add this code in same class you initiate Lamsa (you can put your own value).

companion object{
    private const val LAMSA_REQUEST_CODE = 200
}

Here is the description of the parameters:

Name
Required
Type
Description

amount

Yes

Double

Amount to be paid

authKey

Yes

String

Auth key (Touch point)

remarks

No

String

Remarks for the payment

isProduction

Yes

Boolean

Specify whether it's for staging or production

paymentOption

No

PaymentOptions

Payment Options (Only for staging)

autoCloseInMillis

No

Integer

specify delay in milli second to auto close lamsa sdk after payment success or failed

Payment Options

Name
Description

PaymentOptions.CARD_ACCEPT

Card accepted

PaymentOptions.CARD_REJECT

Card rejected

PaymentOptions.THREE_D_S_ACCEPT

Card accepted (Credit Card)

PaymentOptions.THREE_D_S_REJECT

Card rejected (Credit Card)

Handling the Result

To handle the response from Lamsa SDK, you will use the PaymentResultModel. This model is employed to deserialize and structure the response. It provides the necessary information regarding the payment result.

Here is the description of the above model attributes

Name
Type
Description

success

Boolean

Whether the request success or not.

description

String

Description about payment.

paymentId

String

Identifier associated with the payment

amount

Double

The requested transaction amount

invoice

String

The payment invoice

paymentStatus

Int

Payment status

date

Date

Date of the transaction

Payment Status

Payment Status Code
Status
Description

1

Pending

Payment is pending

2

Success

Payment is successful

3

Failed

Payment is failed

To handle the response to the payment request, implement the onActivityResult method in your activity as follows:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == LAMSA_REQUEST_CODE) {
        // If payment success
        if (resultCode == Activity.RESULT_OK) {
            val result = data?.getSerializableExtra("result") as? PaymentResultModel
            if (result != null) {
                // Use result to get response data
                // var isPaymentStatus:Boolean? = result.success?:false

            } else {
                // Handle unexpected error
                // val error:String = "unexpected error occurred"
            }
        }
 
        // If payment cancelled or failed
        if (resultCode == Activity.RESULT_CANCELED) {
            val result =
                data?.getSerializableExtra("result") as? PaymentResultModel
            if (result != null) {
                // Use result to get response data
                // var isPaymentStatus:Boolean? = result.success?:false
            } else {
                // Handle unexpected error
                // val error:String = "unexpected error occurred"
            }
        }
    }
}

Note: Put your own authKey from and change isProduction to true when you go for production.

📗
Thawani
Thawani