Onerway
Mobile SDKs

Android SDK

Install and configure the Onerway Android SDK, present native checkout, and handle client results, app returns, and Google Pay.

The SDK handles the payment interface and payment interactions. Your server creates payments, confirms final results, and fulfills orders.

Prerequisites and environment

Android 8.0 (API 26) or later is required. The examples use Kotlin.

Prepare a merchant account and server-side signing credentials for the same environment, server endpoints for creating payments and receiving notifications, and the SDK package. Keep credentials on your server. For payment methods that require authentication or an external redirect, configure returnUrl when creating the payment. Complete the relevant wallet configuration before enabling a native wallet.

Install the SDK

Download and extract

Obtain the onerway-android-<SDK_VERSION>.zip offline Maven distribution from Onerway. Replace <SDK_VERSION> with the actual version, using the same version for the package and the Maven dependency.

The recommended location after extraction is your project root:

YourAndroidProject/
├── app/
├── local-maven/
│   └── onerway-android-<SDK_VERSION>/
│       └── com/onerway/sdk/...
├── settings.gradle.kts
└── build.gradle.kts

The ZIP contains local Maven repositories for the SDK modules. Do not copy only an individual AAR. Gradle still resolves third-party dependencies from google() and mavenCentral().

Configure the Maven repository

In settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri(rootDir.resolve("local-maven/onerway-android-<SDK_VERSION>"))
        }
    }
}

For the Groovy DSL, configure settings.gradle:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("${rootDir}/local-maven/onerway-android-<SDK_VERSION>")
        }
    }
}

The Maven URL must point to the repository root containing the com/ directory.

Add the dependency

In app/build.gradle.kts:

android {
    defaultConfig {
        minSdk = 26
    }
}

dependencies {
    implementation("com.onerway.sdk:onerway-android:<SDK_VERSION>")
}

For the Groovy DSL:

dependencies {
    implementation "com.onerway.sdk:onerway-android:<SDK_VERSION>"
}

You only need to add the onerway-android dependency.

Verify the dependency

Run Gradle Sync, then run:

./gradlew :app:dependencies --configuration debugRuntimeClasspath

The dependency tree should include:

com.onerway.sdk:onerway-android:<SDK_VERSION>

Initialize and configure

Runtime environment

The SDK environment must match the environment in which your server created the payment. Always setting environment explicitly is recommended; avoid relying on its default value.

environment selects the SDK runtime environment and has type OnerwayEnvironment.

ValueEnvironmentDescription
PRODUCTIONProductionUses production merchant configuration
SANDBOXSandboxUses sandbox accounts and payment sessions

The default is SANDBOX. For production, pass OnerwayEnvironment.PRODUCTION.

Initialize the SDK

Call configure in the Application.onCreate method used by your app. The class name below is an example. If you already have a custom Application class, add the initialization code to that class.

OnerwaySDK.configure(context, config)

package com.example.app

import android.app.Application
import com.onerway.sdk.core.OnerwayConfig
import com.onerway.sdk.core.OnerwayEnvironment
import com.onerway.sdk.core.OnerwaySDK
import com.onerway.sdk.core.OnerwayThemeMode

class MerchantApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        OnerwaySDK.configure(
            context = applicationContext,
            config = OnerwayConfig(
                environment = OnerwayEnvironment.PRODUCTION,
                locale = null,
                themeMode = OnerwayThemeMode.FOLLOW_HOST,
            ),
        )
    }
}

Register the Application class your app uses in app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:name=".MerchantApplication">
        <!-- Keep your app's existing components. -->
    </application>
</manifest>

The SDK already provides the network permission, checkout Activity, and Google Pay configuration. You do not need to declare them again in your app's AndroidManifest.xml. For return configuration, see “Handle authentication, external redirects, and returns to your app”.

Configuration options

Set the following fields in OnerwayConfig:

FieldTypeDefaultDescription
environmentOnerwayEnvironmentSANDBOXRuntime environment: PRODUCTION or SANDBOX
localeString?OmittedLanguage tag; see Languages for supported values
paymentMethodsSet<String>?OmittedPayment method display allowlist, using the payment method identifiers returned by the server
brandColorInt?OmittedARGB brand color; when omitted, uses the color returned by the server, or the SDK default if the server does not provide a valid color
themeModeOnerwayThemeModeFOLLOW_HOSTAppearance mode; see the table below
themeModeDescription
FOLLOW_HOSTUses the host Activity's light or dark appearance when checkout opens and keeps it unchanged throughout this payment
LIGHTAlways light
DARKAlways dark

paymentMethods uses dynamic payment method identifiers returned by the API, with no fixed enum. When omitted, checkout displays the methods available for the order. An empty set leaves no available methods: the SDK returns sdk_error / no_available_payment_methods and closes checkout. This option only filters the display; it does not enable methods absent from the server configuration or change their order.

Languages

locale supports these language tags:

ar, de, en, es, fi, fr, it, ja, ko, nl, no, pl, pt, ru, sv, th, vi, zh-cn, zh-tw.

When omitted, the SDK reads the app or system language. Unsupported languages fall back to en.

Obtain a payment session from your server and present checkout

Obtain a payment session from your server

  1. Your app calls your own server endpoint for creating a payment.
  2. Your server uses merchantNo and its signing credentials to sign and create the payment as described in Create an SDK transaction. Set paymentMode=APP and osType=ANDROID. Follow that endpoint's requirements for other parameters and conditionally required fields.
  3. Your server saves the mapping between your order, paymentId, and the returned transaction identifier, then returns paymentId to your app.
  4. Your app calls the native SDK with a non-empty paymentId.

Keep signing keys, secret, request signing, and Webhook signature verification on your server.

Your own session endpoint can return an object such as the following. You define the endpoint name and object format:

{
  "merchantTxnId": "YOUR_ORDER_ID",
  "paymentId": "PAYMENT_ID_FROM_ONERWAY"
}

If the payment requires authentication or an external redirect, configure your HTTPS returnUrl when your server creates the payment. The notifyUrl notification endpoint receives payment notifications on your server. The return restores the interaction; the notification confirms the order. Neither replaces the other.

Call the SDK

Call the SDK from your existing payment entry point. The wrapper class below is an example; you can also call OnerwayCheckout.present directly.

OnerwayCheckout.present(activity, params, callback)

ParameterTypeRequiredDescription
activityActivityYesThe currently visible host Activity
paramsCheckoutParamsYesContains a non-empty paymentId: String
callback(PaymentResult) -> UnitYesRuns on the main thread, at most once per presentation
import android.app.Activity
import com.onerway.sdk.core.CheckoutParams
import com.onerway.sdk.core.PaymentReasonType
import com.onerway.sdk.core.PaymentResult
import com.onerway.sdk.ui.OnerwayCheckout

class OnerwayCheckoutLauncher {
    private var isPresenting = false

    fun present(
        activity: Activity,
        paymentId: String,
        onResult: (PaymentResult) -> Unit,
    ) {
        if (isPresenting) return

        isPresenting = true
        try {
            OnerwayCheckout.present(
                activity = activity,
                params = CheckoutParams(paymentId = paymentId),
            ) { result ->
                isPresenting = false
                onResult(result)
            }
        } catch (error: RuntimeException) {
            isPresenting = false
            throw error
        }
    }
}

fun handlePaymentResult(result: PaymentResult) {
    val reason = result.reason
    when {
        reason?.type == PaymentReasonType.CANCELED -> {
            showOrderPage()
        }
        result.paymentStatus == "S" -> {
            verifyOnMerchantServer(result.paymentId)
        }
        result.paymentStatus == "P" || result.paymentStatus == "A" -> {
            showPending(result.paymentId)
        }
        result.paymentStatus == "N" -> {
            showNotCompleted(result.paymentId)
        }
        reason != null -> {
            showCheckoutError(reason.code)
        }
        else -> {
            verifyOnMerchantServer(result.paymentId)
        }
    }
}

Implement showOrderPage, verifyOnMerchantServer, showPending, showNotCompleted, and showCheckoutError in your app. These methods should retain the current order and confirm its status with your server. In particular, do not create a new order solely because the result is N or the user cancels.

Call requirements:

  • Call OnerwaySDK.configure first.
  • Call on the main thread and pass the currently visible Activity. From a Fragment, use requireActivity().
  • Present only one checkout at a time within the same process.
  • An empty paymentId returns sdk_error / invalid_payment_id through the callback.
  • Calling before initialization or opening a second checkout concurrently throws an exception.
  • The callback runs on the main thread, at most once per presentation.

Handle client payment results

PaymentResult

FieldTypeDescription
paymentIdStringPayment session identifier
transactionIdString?Server transaction identifier; null until available
paymentMethodString?Payment method obtained by the SDK; null until available
paymentStatusString?Non-empty values are S, P, A, or N; null on cancellation or error, in which case read reason
reasonPaymentReason?Cancellation or error reason

Payment statuses and merchant handling

When checkout ends, handle paymentStatus as follows:

paymentStatusMeaningMerchant handling
SThe SDK has received a successful payment resultShow success; fulfill the order after your server confirms the result
PThe payment is processing or the result still needs confirmationShow a confirmation-in-progress message and continue querying from your server
AThe SDK has received an authorized resultFollow your server's pre-authorization and capture results; do not treat this as funds having been collected
NThe SDK has received a payment-not-completed resultConfirm the order status with your server; do not automatically create a new order based only on this value

When the user cancels or the SDK exits with an error result, paymentStatus is null. Read reason.type and reason.code for the reason. After cancellation, an error, or a network timeout, query the order status from your server to confirm it. Handle results using reason.type and reason.code. Do not determine order status from an error message.

The SDK handles payment retries, authentication, and external redirects. If the user only cancels wallet authorization or dismisses a recoverable error message, checkout remains open and the completion callback does not run.

PaymentResult, the return URL, and SDK pages are for client interactions only. Base fulfillment, shipping, account top-ups, and accounting on results confirmed by a signature-verified Webhook or a server-side query, and process them idempotently by merchant order. The end of the client flow does not mean the server-side order has reached a final state.

Reason types

reason.type.rawValueDescription
canceledThe customer closed the entire checkout
validation_errorLocal parameter or form validation error; reserved, not returned in the current version
api_errorPayment API or backend business error
sdk_errorSDK configuration, invocation, network, or internal error

PaymentReason

FieldTypeDescription
typePaymentReasonTypeReason category; see Reason types
codeStringReason code for application logic and troubleshooting
messageString?Display or diagnostic information; do not use it to determine payment status
paramString?Related parameter
declineCodeString?Reserved; always null in the current version
errorsList<PaymentFieldError>?Reserved; always null in the current version

Optional fields are null when no corresponding information is available.

Payment identifiers

IdentifierSourcePurpose
merchantTxnIdGenerated by your serverAssociates the payment with your order
paymentIdCreate SDK transaction responseOpens checkout and identifies the payment session
transactionIdSDK result callbackIdentifies the server transaction

transactionId is the server transaction identifier obtained by the SDK and is null until available. The same paymentId may have different transaction identifiers after payment attempts or retries. Associate the transaction using the value in the current callback, and confirm its final status on your server.

Handle authentication, external redirects, and returns to your app

The SDK automatically opens authentication or external payment pages in the system browser. Some payment methods redirect to a third-party app instead.

After payment, the platform redirects the user to the returnUrl configured when you created the payment, and the system opens your app directly. The platform handles the return. The SDK does not need to participate, and you do not need to pass the return URL to the SDK. Handling after return depends on whether the original SDK session is still active; see After returning to your app.

Configure the return URL

  1. When your server creates the payment, set returnUrl to a URL that opens your app. A domain-verified HTTPS App Link is recommended:
    https://pay.example.com/payment/return
    
  2. Your app must be able to receive this URL through its routing. For an HTTPS App Link, associate the domain with your app using assetlinks.json. You do not need to add a dedicated Activity for this purpose.
  3. If you need a custom scheme, such as myapp://payment/return, first confirm with Onerway whether the current order type supports it.

After returning to your app

  • If the original checkout is still alive, the SDK automatically queries the payment status when it returns to the foreground and invokes the callback once. You do not need to listen for the browser closing, confirm the payment again, or implement polling.
  • If the app has restarted, the original checkout has closed, or the query fails, query your server from your order page to confirm the result.
  • Do not use status, amounts, or other parameters in the return URL to determine the payment result. Use a server-side query or Webhook for the final status.

OnerwayCheckout.resumeFromReturn is an optional recovery method that brings a still-active checkout to the foreground or restores a session when needed. It is not part of the standard integration steps. Omitting it does not affect the return or server-side order queries.

OnerwayCheckout.resumeFromReturn(activity, uri, callback): Boolean

ParameterTypeDescription
activityActivityThe current return-link entry Activity
uriUri?Return URL whose HTTPS scheme, domain, and path your app has validated
callback(PaymentResult) -> UnitResult callback for a rebuilt session; an active session keeps the original present callback

Call configure first, using configuration consistent with the original payment. true means the SDK handled the link; it does not mean payment succeeded. false means the SDK did not handle it, and your order page must confirm the result with your server. Do not use status parameters in the URL to determine payment success.

Platform wallets

Google Pay app integration and production approval

Before enabling Google Pay, complete the Android app integration configuration and production approval.

  1. Manage your integration details in your Google Pay & Wallet Console, and confirm the business details and app ownership.
  2. Follow the Google Pay Android production guide to add your Android app, submit integration screenshots, and request production access.
  3. Confirm with Onerway that your Google Pay merchant and gateway configuration is active. The SDK uses the configuration returned by the server for the current order; the server supplies the gateway parameters.
  4. Verify on a physical device using a release-signed build, and complete Google's review and publishing requirements.

The current SDK uses the Google Pay production environment in PRODUCTION and the Google Pay test environment in SANDBOX. The Onerway SDK environment, merchant configuration, and Google app production access must all meet the requirements.

When the server includes Google Pay and the device passes the availability check, the SDK displays the official button. You do not need to implement wallet button submission or handle wallet tokens yourself.

Closing the Google Pay authorization page cancels only that wallet operation. Checkout remains open, and the SDK does not immediately invoke your callback. For testing and display requirements, see the Google Pay Android integration checklist.

Debugging, integration verification, and further references

Troubleshooting

SymptomWhat to check
Gradle cannot find the SDKWhether the ZIP was fully extracted, the Maven URL points to the root containing com/, and the versions match
Duplicate classes or dependency conflictsRun :app:dependencies and check for manually added duplicate dependencies
SDK is not initializedWhether the Application class actually used by the app is registered in the Manifest and configure runs
invalid_payment_idWhether your server returns a valid paymentId, without extra spaces or truncation
Order fails to loadWhether paymentId was created in the environment selected by the SDK
Checkout opens more than onceRepeated taps on the payment button or repeated calls to present in onResume
No callback receivedWhether the SDK result page is still open, the user returned to the original checkout, or the app restarted or the original session ended
paymentStatus is nullRead reason.type and reason.code; the status is null for cancellations and errors
App Link does not open the appManifest, assetlinks.json, package name, signing certificate fingerprint, domain, and path
The app opens after a return but the order is not updatedQuery the order from your server on your order page; do not rely on return URL parameters
The optional recovery method returns falseWhether paymentId matches and the session has expired
Google Pay is not displayedBackend configuration, physical device, wallet account, and merchant and gateway configuration

When reporting an issue, provide the SDK version, app version, build type, masked paymentId, time of occurrence, Android version, reproduction steps, and reason.code. Do not send card numbers, CVV, full payment tokens, merchant keys, or unmasked user information.

Integration verification

Test at least: a normal payment; authentication success and cancellation; wallet cancellation; repeated taps; network interruptions; P/A/N results; unknown or null results; returning from an external redirect to the original session; confirming results from your order page after an app restart; repeated return handling; and Webhooks arriving more than once or before the client result.

For every scenario, check that the app and server order mappings agree, processing is deduplicated by merchant order, fulfillment for S waits for server confirmation, A is not treated as successful collection, and closing the page or a timeout is not incorrectly recorded as failure. Any transactionId returned to your app's business module must be the transaction identifier confirmed by your server. After testing, recheck App Links and native wallets using a release-signed build.

After an app interruption, restore the order and query the existing payment from your server before deciding whether to continue. Do not automatically resubmit while processing or when the result is unknown, and do not create a new order just because a page disappears.

Further scenarios and references