Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.appcharge.com/llms.txt

Use this file to discover all available pages before exploring further.

This article describes how to set up the Payment Links SDK for Android.

Requirements

Minimum target level24

Step 1 | Import the SDK

To import the Android Payment Links SDK, add the following implementation to your build.gradle file:
implementation("com.appcharge:android-payment-links:1.6.0")
Then add the following to your settings.gradle file:
repositories {
    mavenCentral()
}

Step 2 | Add Permissions

In the Manifest file, add the necessary permissions to access the network state and enable incoming deeplink over HTTPS:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
</queries>

Step 3 | Configure a URL Scheme

Next, add support for checkout activity and deeplink scheme:
 <activity
    android:name="com.appcharge.paymentlinks.CheckoutActivity"
		android:configChanges="orientation|screenSize"
    android:screenOrientation="unspecified"
    android:exported="true"
    android:launchMode="singleTask"
    tools:ignore="DiscouragedApi">
    <!-- Custom scheme -->
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="acnative-{IDENTIFIER}"/>
        <data android:host="action"/>
        <data android:scheme="https"/>
    </intent-filter>
</activity>
The intent-filter includes a scheme "acnative-{IDENTIFIER}". Change the {IDENTIFIER} to the last sequence of your package name. For example, if your package name is com.appcharge.mysupergame, the identifier will be mysupergame.This name must be lowercase with no spaces, according to the Android code style guide.

Step 4 | Set up foreground service for your checkout (Optional)

To improve checkout stability, you can enable a foreground service. This keeps your app prioritized while the checkout is open, helping prevent Android from closing or deprioritizing it during payment and network operations. To set up the checkout service:
  1. Add the following permissions to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
  1. Then register the service inside the <application> tag. When this service is enabled, Android may display a notification from your game while the checkout is open. To make sure the notification uses your game name instead of the package name, set android:label on the <application> tag:
<application android:label="APP_NAME">
  <!-- android:label is optional. -->
  <service android:name="com.appcharge.paymentlinks.CheckoutService" 
    android:exported="false" 
    android:foregroundServiceType="shortService" />  
</application>
If you’re upgrading an existing integration that already includes the CheckoutService declaration, update android:foregroundServiceType from dataSync to shortService in your manifest.
  1. After SDK initialization or before launching checkout, enable or disable the service in code:
BridgeAPI.setCheckoutServiceMode(true) // Enable
BridgeAPI.setCheckoutServiceMode(false) // Disable
By default, setCheckoutServiceMode is enabled. If you don’t want to use the checkout service, remove the related permissions and the CheckoutService declaration from your manifest file, or disable it using the SDK Bridge method above.