주요 콘텐츠로 건너뛰기

Android SDK 참조

Aghanim Android SDK는 안드로이드 앱 내에서 체크아웃을 사용할 수 있도록 합니다.

Native UI
Native UI

Native UI

통합

SDK 통합을 위해서는 사전 조건과 Integrate → Android에서 상세 지침을 참조하세요.

방법 참조

소비되지 않은 주문 가져오기

결제가 완료되었지만 아직 제공되지 않은 주문을 확인하려면 getUnconsumed 또는 getUnconsumedAsync 메서드를 사용하세요.

import com.aghanim.android.sdk.common.api.result.ApiResult
import android.util.Log

when (val unconsumedResult = aghanim.orders.getUnconsumed()) {
is ApiResult.Success -> {
// Player has paid but not granted items from orders
val unconsumedOrderIds = unconsumedResult.value
// TODO: Save order IDs for further consuming and granting
}

is ApiResult.Failure -> {
// Log debug information for troubleshooting
Log.e("Orders", "Failed to get unconsumed orders: ${unconsumedResult.error}")
// TODO: Handle error
}
}

지불한 주문 소모

플레이어가 주문을 통해 구매한 아이템을 제공했음을 SDK가 인식하도록 하려면 consume 또는 consumeAsync 메서드를 사용하세요.

import com.aghanim.android.sdk.common.api.result.ApiResult
import android.util.Log

when (val consumeResult = aghanim.orders.consume(orderId)) {
is ApiResult.Success -> {
// Paid orders are marked as consumed
Log.d("Orders", "Order $orderId is successfully consumed")
// TODO: Grant items in order to player
}

is ApiResult.Failure -> {
// Log debug information for troubleshooting
Log.e("Orders", "Failed to consume order: ${consumeResult.error}")
// TODO: Handle error
}
}

플레이어 ID 설정

현재 SDK 인스턴스에 대해 플레이어 ID를 한 번 설정하려면 setPlayerId 메서드를 사용하세요. SDK는 이후 모든 메서드 호출에서 ID를 사용합니다.

aghanim.setPlayerId(playerId)
파라미터유형필수 여부설명
playerId문자열플레이어의 고유 ID.

아이템 가져오기

현지화된 가격으로 아이템을 가져오려면 items.get 또는 items.getAsync 메서드를 사용하세요. 이 메서드는 SKU Management → Items에서 생성된 아이템을 반환하며, 플레이어의 지역에 따라 가격이 현지화됩니다.

import com.aghanim.android.sdk.common.api.result.ApiResult
import android.util.Log

when (val result = aghanim.items.get(
skus = listOf("your-item-sku"),
)) {
is ApiResult.Success -> {
val items = result.value
items.forEach { item ->
// Use item.name, item.price.display, item.imageUrl to populate your store
Log.d("Items", "${item.name}: ${item.price.display}")
}
}

is ApiResult.Failure -> {
// Log debug information for troubleshooting
Log.e("Items", "Failed to get items: ${result.error}")
// TODO: Handle error
}
}
파라미터형식필수 여부설명
skusList<String>가져올 아이템 SKU 목록(최대 50개).
localeLocale아니요가격 형식 지정용 Locale. 지원되는 Locale의 전체 목록은 Checkout → Locales에서 확인하세요.

Checkout 아이템 생성

아이템 표현을 생성하려면 CheckoutItem 메소드를 사용하십시오. 아이템은 SKU 관리 → 항목에서 이미 생성되어 있어야 합니다.

import com.aghanim.android.sdk.checkout.core.api.models.CheckoutItem

val checkoutItem = CheckoutItem(
sku = "CRS-82500"
)
파라미터형식필수 여부설명
sku문자열대시보드에서의 아이템 SKU.
name문자열아니요대시보드에서의 아이템 이름.
description문자열아니요대시보드에서의 아이템 설명.
imageUrl문자열아니요대시보드에서의 아이템 이미지 URL.
quantityint아니요아이템 수량.

리디렉션 동작 생성

플레이어가 결제를 성공적으로 완료한 후 리디렉션 동작을 선택하려면 RedirectSettings 메소드를 사용하십시오.

플레이어가 결제를 완료하면, SDK는 즉시 backToGameUrl의 딥 링크로 리디렉션합니다.

import com.aghanim.android.sdk.common.api.models.order.RedirectSettings
import com.aghanim.android.sdk.common.api.models.order.RedirectMode

val redirectSettings = RedirectSettings(
mode = RedirectMode.IMMEDIATE
)
파라미터유형필수 여부설명
modeRedirectMode리디렉션 모드. 가능한 값: Immediate, Delayed, NoRedirect.
delaySecondsintDelayed이면 예초 단위의 지연. Delayed 모드에서는 기본값이 5입니다.

UI 설정 생성

Checkout의 외관 모드를 설정하려면 UiSettings 메서드를 사용하세요.

SDK는 시스템 설정에 따라 적절한 외관 모드를 자동으로 감지하고 적용합니다.

import com.aghanim.android.sdk.checkout.core.api.models.UiSettings
import com.aghanim.android.sdk.checkout.core.api.models.UiMode

val uiSettings = UiSettings(
mode = UiMode.AUTO
)
파라미터유형필수 여부설명
modeUiModeUI 모드. 가능한 값: Auto, Dark, Light.

체크아웃 파라미터 생성

플레이어가 결제 양식에서 보는 것을 나타내는 체크아웃 파라미터를 생성하려면 CheckoutParams 메소드를 사용하십시오.

네이티브 UI 실행 모드에서는 체크아웃 파라미터 생성이 더 간단합니다. 체크아웃이 브라우저를 사용해 실행되지 않기 때문에 backToGameUrl을 전달할 필요가 없습니다.

import com.aghanim.android.sdk.checkout.core.api.models.CheckoutParams
import com.aghanim.android.sdk.common.api.models.common.Locale

val checkoutParams = CheckoutParams(
items = listOf(checkoutItem),
customMessage = "Holiday Sale!",
locale = null
)
파라미터유형필수 여부설명
itemsList<CheckoutItem>항목의 목록입니다.
metadataMap<string, string>아니요추적 목적으로 "키-값" 쌍으로 구조화된 메타데이터.
priceTemplateId문자열아니요현지화된 가격을 위해 가격 포인트 가져오기에서 가격 템플릿 ID를 가져옵니다.
locale문자열아니요아이템 이름 및 설명 현지화를 위한 로케일. 지원되는 Locale의 전체 목록은 Checkout → Locales에서 확인하세요.
customMessage문자열아니요체크아웃 페이지의 메시지.
backToGameUrl문자열아니요플레이어를 앱으로 복귀시키는 딥링크 URL. 제공되지 않을 경우 자동 생성됩니다.
redirectSettingsRedirectSettings아니요결제 후 리다이렉트 행동.
uiSettingsUiSettings아니요Checkout 외관 설정.

체크아웃 시작

Checkout 프로세스를 시작하려면 startCheckout 또는 startWebCheckout 메서드를 사용하세요. 이 메서드는 제공된 checkout params로 주문을 생성하고 Checkout UI를 엽니다. 성공 값이 주문 ID인 ApiResult<String>를 반환합니다.

시작 모드는 플레이어의 경험을 완전히 제어하는 네이티브 UI를 사용합니다.

import com.aghanim.android.sdk.checkout.ui.api.startCheckout
import com.aghanim.android.sdk.common.api.result.ApiResult
import android.util.Log

when (val result = aghanim.startCheckout(
context = context,
checkoutParams = checkoutParams,
)) {
is ApiResult.Success -> {
// Order is created and checkout has launched successfully
val orderId = result.value
// TODO: Save order ID for further granting or tracking
}

is ApiResult.Failure -> {
// Log debug information for troubleshooting
Log.e("Checkout", "Failed to launch Checkout: ${result.error}")
// TODO: Show user-friendly error message to player
}
}
파라미터형식필수 여부설명
contextActivity현재 Activity.
checkoutParamsCheckoutParamsCheckout 구성.

Checkout 표시

기존 주문에 대해 Checkout UI를 표시하려면 presentCheckout 또는 presentWebCheckout 메서드를 사용하세요. 서버 간 주문 생성으로부터 주문 ID가 있거나, 이전에 중단된 checkout을 재개할 때 이를 사용하세요.

이 실행 모드는 플레이어 경험을 완전히 제어할 수 있는 Native UI를 사용합니다.

import com.aghanim.android.sdk.checkout.ui.api.presentCheckout
import com.aghanim.android.sdk.common.api.result.ApiResult
import android.util.Log

when (val result = aghanim.presentCheckout(
context = context,
orderId = orderId,
)) {
is ApiResult.Success -> {
// Checkout has launched successfully for the existing order
val presentedOrderId = result.value
}

is ApiResult.Failure -> {
// Log debug information for troubleshooting
Log.e("Checkout", "Failed to present Checkout: ${result.error}")
// TODO: Show user-friendly error message to player
}
}
파라미터유형필수 여부설명
contextActivity현재 Activity.
orderIdString열 기존 주문의 ID.

도움이 필요하세요?
통합팀에 문의하십시오 [email protected]