# Getting Started

{% hint style="info" %}
To download the PayContactless embedded SDK, you will be provided with secure credentials (username and password).

Follow the steps below to configure your project and fetch the SDK dependency.
{% endhint %}

Depending on your build setup, add the Maven repository block to either:

* `build.gradle` (Groovy DSL), or
* `settings.gradle.kts` (Kotlin DSL)

{% hint style="warning" %}
We recommend keeping this credential in your local.properties file
{% endhint %}

{% tabs %}
{% tab title="Kotlin DSL" %}

```kts
//dependencyResolutionManagement block
dependencyResolutionManagement {
    repositories {
        maven {
            name = "ProphiusNexus"
            url = uri("https://nexus.prophius-api.com/repository/maven-releases/")

            // Load Nexus credentials from local.properties
            val localPropsFile = rootDir.resolve("local.properties")
            if (localPropsFile.exists()) {
                val props = Properties().apply {
                    load(localPropsFile.inputStream())
                }
                credentials {
                    username = props.getProperty("YOUR USERNAME") ?: ""
                    password = props.getProperty("YOUR PASSWORD") ?: ""
                }
            } else {
                println("⚠️ Warning: local.properties not found. Credentials are missing.")
            }
        }

        // Optional defaults
        google()
        mavenCentral()
    }
}
```

{% endtab %}

{% tab title="Java/Groovy DSL" %}

```gradle
allprojects {
    repositories {
        maven {
            name = "ProphiusNexus"
            url = uri("https://nexus.prophius-api.com/repository/maven-releases/")

            // Load Nexus credentials from local.properties
            def localProps = new Properties()
            def localPropsFile = rootProject.file("local.properties")
            if (localPropsFile.exists()) {
            localProps.load(new FileInputStream(localPropsFile))
            localProps.each { key, value ->
                project.ext.set(key.toString(), value)
            }
            
            credentials {
                username = project.findProperty("YOUR USERNAME") ?: ""
                password = project.findProperty("YOUR PASSWORD") ?: ""
            }
            } else {
                println("⚠️ Warning: local.properties not found.Credentials are missing.")
            }
            
        }

        // Optional defaults
        google()
        mavenCentral()
    }
}
```

{% endtab %}
{% endtabs %}

Add the SDK dependency in your module level build.gradle file of the project like below.

```gradle
implementation 'com.prophius:paycontactlesssdk.embed.stage:3.4.18'
```

{% hint style="info" %}
SDK does not allow to run the app on debug. The application must be release build.

Check Security Mechanisms section for the other restriction.
{% endhint %}

{% content-ref url="../security-mechanisms" %}
[security-mechanisms](https://developer.prophius.com/developer-console/merchant-embed-sdk/security-mechanisms)
{% endcontent-ref %}

{% hint style="danger" %}
This version of the SDK must be used in integration phase by developer. For the internal and external tests, the version of SDK must never be used.
{% endhint %}

## Required Dependencies <a href="#id-6.-dependencies" id="id-6.-dependencies"></a>

SDK needs some third party libraries and the integrator app must have these dependencies. The libraries which is shared below should be added to the build.gradle file.

```gradle
// Room
implementation "androidx.room:room-runtime:2.7.0"
annotationProcessor "androidx.room:room-compiler:2.7.0"

// SQLCipher
implementation "net.zetetic:android-database-sqlcipher:4.5.0"

// Gson
implementation "com.google.code.gson:gson:2.10.1"

// Lottie
implementation "com.airbnb.android:lottie:3.4.0"

// Google Play Services
implementation "com.google.android.gms:play-services-base:18.6.0"

// Google Play Integrity
implementation "com.google.android.play:integrity:1.4.0"

// OkHttp3
implementation "com.squareup.okhttp3:okhttp:4.12.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.10.0"
// Material
implementation "com.google.android.material:material:1.9.0"

```

{% hint style="warning" %}
In order to support schemas' branding animations, jetifier tools must be enabled on your project. The following configuration must be added on your `gradle.properties` file.&#x20;

<pre class="language-kotlin"><code class="lang-kotlin"><strong># Automatically convert third-party libraries to use AndroidX
</strong><strong>android.enableJetifier=true
</strong></code></pre>

{% endhint %}

**Using the PayContactless Embed SDK Library**

Before accessing the functions within the PayContactless Embed SDK library, there are a few steps to follow:

1. **Initialization**: Begin by calling the `start` method.
2. **Accessing the SDK**: Utilize the `getInstance` method. This will allow you to access various methods under `PayContactlessEmbed`.
3. **Required Parameters:**
   * **Context:** Application context&#x20;
   * **Organization Id:** Predefined organization identenfier&#x20;
   * **Google Clould Project Number:** Project Number of your project on Google Cloud

{% hint style="warning" %}
PayContactless Embed SDK uses Play Integrity API for Automatic integrity protection. You need to enable Integrity API on your project and share required credentioans to the PayContactless team. Please check Play Integrity Configuration section.
{% endhint %}

{% content-ref url="../production-preparation/play-integrity-configuration" %}
[play-integrity-configuration](https://developer.prophius.com/developer-console/merchant-embed-sdk/production-preparation/play-integrity-configuration)
{% endcontent-ref %}

Remember to pass the these parameters as arguments when invoking the `start` method.

By adhering to these steps, you'll ensure the proper and utilization of the PayContactless Embed SDK library functions.

A sample method is highlighted below;

```kotlin
PayContactlessEmbed.getInstance().start(context, organizationId, googleCloudProjectNumber)
```

Where context (app context), organization (Integer), and the googleCloudProjectId (String).

{% hint style="info" %}
**Important Recommendation for Using PayContactlessEmbed SDK**

For optimal functionality and seamless integration, it is strongly advised to invoke the `start` method of `PayContactlessEmbed` within the `onCreate` method of your application.
{% endhint %}

PaycontaclessEmbed needs the acvitiy result to parse the Payment activity reponse. The `onAcitivtyResult` method of the SDK must be called in current activity's `onActivityResult` method.

```kotlin
PayContactlessEmbed.getInstance().onActivityResult(requestCode,resultCode,data)
```

A sample usage is highlighted below;

```kotlin
  override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        PayContactlessEmbed.getInstance().onActivityResult(requestCode,resultCode,data)
    }
```
