{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["json-schema"]},"type":"markdown"},"seo":{"title":"Create Instance","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":["openapi"],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"create-instance","__idx":0},"children":["Create Instance"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"taptopaysdkcreateinstancetyroenv-appcontext-options","__idx":1},"children":["TapToPaySdk.createInstance(tyroEnv, appContext, options)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Application"]}," class create an instance of the TapToPaySdk by invoking static method ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TapToPaySdk.createInstance(tyroEnv, appContext, options)"]}," in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onCreate()"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"parameters","__idx":2},"children":["Parameters"]},{"$$mdtype":"Tag","name":"JsonSchema","attributes":{"schema":{"type":"object","properties":{"tyroEnv":{"type":"TyroEnv","description":"The `TyroEnv` requires the `PosInfo` and `ConnectionProvider` in the constructor. There are 3 TyroEnv subclasses to use based on the desired environment: `TyroEnvStub`, `TyroEnvDev`, and `TyroEnvProd`."},"applicationContext":{"type":"Context","description":"The applicationContext from the Application. This function must be called inside onCreate() otherwise the context is null."},"options":{"type":"TyroOptions","description":"Options to configure the SDK such as screen orientation."}},"required":["tyroEnv","applicationContext"]},"options":{"schemaExpansionLevel":3},"schemaResolved":{"openapi":"3.1.0","components":{"schemas":{"__root":{"type":"object","properties":{"tyroEnv":{"type":"TyroEnv","description":"The `TyroEnv` requires the `PosInfo` and `ConnectionProvider` in the constructor. There are 3 TyroEnv subclasses to use based on the desired environment: `TyroEnvStub`, `TyroEnvDev`, and `TyroEnvProd`."},"applicationContext":{"type":"Context","description":"The applicationContext from the Application. This function must be called inside onCreate() otherwise the context is null."},"options":{"type":"TyroOptions","description":"Options to configure the SDK such as screen orientation."}},"required":["tyroEnv","applicationContext"]}}}},"schemaResolvedErrors":[]},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"tyroenv","__idx":3},"children":["TyroEnv"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/in-person-payments/tap-to-pay/android/sdk/tyro-env"},"children":["TyroEnv"]}," for more info."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"tyrooptions","__idx":4},"children":["TyroOptions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Optional parameters to provide to the SDK."]},{"$$mdtype":"Tag","name":"JsonSchema","attributes":{"schema":{"type":"object","properties":{"screenOrientation":{"type":"TyroScreenOrientation","description":"Sets the screen orientation for Tyro UI. For smaller devices like mobile phone, only `PORTRAIT` is supported.","enum":["PORTRAIT","REVERSE_PORTRAIT","SENSOR","LANDSCAPE","REVERSE_LANDSCAPE"]},"themeMode":{"type":"TyroThemeMode","description":"Sets the theme mode for Tyro UI. Defaults to `SYSTEM`.","enum":["LIGHT","DARK","SYSTEM"]},"hapticFeedbackEnabled":{"type":"Boolean","description":"Enables the haptic feedback for Tyro Embedded Payment SDK. Defaults to `true`."}},"required":[]},"options":{"schemaExpansionLevel":3},"schemaResolved":{"openapi":"3.1.0","components":{"schemas":{"__root":{"type":"object","properties":{"screenOrientation":{"type":"TyroScreenOrientation","description":"Sets the screen orientation for Tyro UI. For smaller devices like mobile phone, only `PORTRAIT` is supported.","enum":["PORTRAIT","REVERSE_PORTRAIT","SENSOR","LANDSCAPE","REVERSE_LANDSCAPE"]},"themeMode":{"type":"TyroThemeMode","description":"Sets the theme mode for Tyro UI. Defaults to `SYSTEM`.","enum":["LIGHT","DARK","SYSTEM"]},"hapticFeedbackEnabled":{"type":"Boolean","description":"Enables the haptic feedback for Tyro Embedded Payment SDK. Defaults to `true`."}},"required":[]}}}},"schemaResolvedErrors":[]},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"example-implementation","__idx":5},"children":["Example Implementation"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create an instance of the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TapToPaySdk"]}," in your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Application"]}," class."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","header":{"controls":{"copy":{}}},"source":"// Kotlin Sample Code\nimport android.app.Application\nimport com.tyro.taptopay.sdk.api.TapToPaySdk\nimport com.tyro.taptopay.sdk.api.TapToPaySdk.Companion.createInstance\nimport com.tyro.taptopay.sdk.api.TyroEnv\nimport com.tyro.taptopay.sdk.api.TyroEnvDev\nimport com.tyro.taptopay.sdk.api.TyroEnvProd\nimport com.tyro.taptopay.sdk.api.TyroEnvStub\nimport com.tyro.taptopay.sdk.api.TyroOptions\nimport com.tyro.taptopay.sdk.api.TyroScreenOrientation\nimport com.tyro.taptopay.sdk.api.data.PosInfo\n\nclass SdkDemoApplication : Application() {\n    lateinit var tapToPaySDK: TapToPaySdk\n\n    override fun onCreate() {\n        super.onCreate()\n        tapToPaySDK = createTapToPaySdk()\n    }\n\n    @Suppress(\"KotlinConstantConditions\")\n    private fun createTapToPaySdk(): TapToPaySdk {\n        val tyroEnv: TyroEnv =\n            when (BuildConfig.FLAVOR) {\n                \"stub\" -> TyroEnvStub()\n                \"dev\" ->\n                    TyroEnvDev(\n                        connectionProvider = SdkDemoConnectionProvider(),\n                    )\n                else ->\n                    TyroEnvProd(\n                        connectionProvider = SdkDemoConnectionProvider(),\n                    )\n            }\n        return createInstance(tyroEnv, applicationContext, TyroOptions(TyroScreenOrientation.PORTRAIT, TyroThemeMode.SYSTEM, hapticFeedbackEnabled = true)).apply {\n            setPosInfo(\n                PosInfo(\n                    posName = \"Demo\",\n                    posVendor = \"Tyro Payments\",\n                    posVersion = \"1.0\",\n                    siteReference = \"Sydney\",\n                ),\n            )\n        }\n    }\n}\n","lang":"kotlin"},"children":[]}]},"headings":[{"value":"Create Instance","id":"create-instance","depth":1},{"value":"TapToPaySdk.createInstance(tyroEnv, appContext, options)","id":"taptopaysdkcreateinstancetyroenv-appcontext-options","depth":2},{"value":"Parameters","id":"parameters","depth":3},{"value":"TyroEnv","id":"tyroenv","depth":4},{"value":"TyroOptions","id":"tyrooptions","depth":4},{"value":"Example Implementation","id":"example-implementation","depth":2}],"frontmatter":{"title":"Create Instance","seo":{"title":"Create Instance"}},"lastModified":"2026-09-02T01:02:13.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/in-person-payments/tap-to-pay/android/sdk/create-instance","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}