앱이 Play 스토어에서 디지털 상품과 정기 결제를 판매할 수 있도록 허용하는 것 외에도 Google Play 결제는 카탈로그, 가격 및 정기 결제, 유용한 보고서, 사용자에게 이미 익숙한 Play 스토어에서 제공하는 결제 흐름을 관리할 수 있는 도구를 제공합니다. 이는 Play 스토어에 게시되어 디지털 상품을 판매하는 애플리케이션에도 적용되는 요구사항입니다.
Chrome 88은 신뢰할 수 있는 웹 활동을 Payment Request API 및 Digital Goods API와 통합하여 Google Play 결제를 통해 구매 흐름을 구현할 수 있는 오리진 트라이얼과 함께 출시됩니다. 이 오리진 트라이얼은 ChromeOS 버전 89에서도 사용할 수 있을 것으로 예상됩니다
Android 앱과의 통합을 쉽게 하기 위해 신뢰할 수 있는 웹 활동팀은 android-browser-helper에 확장 프로그램 라이브러리를 도입합니다. 이 가이드에서는 이 라이브러리를 기존 애플리케이션에 통합하는 데 필요한 변경사항을 보여줍니다.
참고: 이 도움말에서는 Android 앱 통합을 설명합니다. Bubblewrap을 사용하여 애플리케이션을 빌드하는 경우 이 도구를 사용하여 앱을 업데이트할 수 있습니다. Bubblewrap의 구현은 이 문제에서 추적하고 있습니다. 이 가이드는 Bubblewrap을 사용하여 앱을 업데이트하지 않는 사용자를 대상으로 합니다.
build.gradle
결제 확장 프로그램 라이브러리 자체는 android-browser-helper
의 2.1.0
버전에 종속됩니다. 애플리케이션에서 이보다 크거나 같은 버전을 사용하고 있는지 확인하세요.
또한 결제 광고 확장 라이브러리의 구현 선언을 추가해야 합니다.
dependencies {
...
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.1.0'
implementation 'com.google.androidbrowserhelper:billing:1.0.0-alpha05'
}
DelegationService.java
android-browser-helper는 앱에서 직접 사용할 수 있는 기본 DelegationService
와 함께 제공됩니다.
결제 확장 프로그램을 사용하는 경우 DelegationService
의 약간 맞춤설정된 버전이 필요합니다.
이렇게 하려면 원래 클래스를 확장하고 onCreate()
를 재정의하는 고유한 DelegationService
클래스를 만들어야 합니다. onCreate()
내에서 애플리케이션을 Digital Goods API의 핸들러로 등록하는 단일 메서드 호출을 추가해야 합니다.
package com.example.yourapp;
import com.google.androidbrowserhelper.playbilling.digitalgoods.DigitalGoodsRequestHandler;
import com.google.androidbrowserhelper.trusted.DelegationService;
public class DelegationService
extends com.google.androidbrowserhelper.trusted.DelegationService {
@Override
public void onCreate() {
super.onCreate();
registerExtraCommandHandler(new DigitalGoodsRequestHandler(getApplicationContext()));
}
}
AndroidManifest.xml
Android 매니페스트에서 자체 구현의 위임 라이브러리 참조를 변경해야 합니다. 상응하는 service
선언에서 com.google.androidbrowserhelper.trusted.DelegationService
을 새로 만든 클래스로 바꿉니다.
<service
android:name=".DelegationService"
android:exported="true">
<intent-filter>
<action android:name="android.support.customtabs.trusted.TRUSTED_WEB_ACTIVITY_SERVICE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
또한 결제 라이브러리에는 Android 매니페스트에 추가해야 하는 두 가지 새로운 구성요소, 즉 브라우저에서 연결하여 애플리케이션이 결제를 지원하는지 확인할 수 있는 서비스와 결제 흐름 자체를 처리하는 활동이 도입되었습니다.
<activity
android:name="com.google.androidbrowserhelper.playbilling.provider.PaymentActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="keyboardHidden|keyboard|orientation|screenLayout|screenSize"
android:exported="true">
<intent-filter>
<action android:name="org.chromium.intent.action.PAY" />
</intent-filter>
<meta-data
android:name="org.chromium.default_payment_method_name"
android:value="https://play.google.com/billing" />
</activity>
<!-- This service checks who calls it at runtime. -->
<service
android:name="com.google.androidbrowserhelper.playbilling.provider.PaymentService"
android:exported="true" >
<intent-filter>
<action android:name="org.chromium.intent.action.IS_READY_TO_PAY" />
</intent-filter>
</service>
Digital Goods API 및 Google Play 결제 자세히 알아보기
이 도움말에서는 신뢰할 수 있는 웹 활동을 사용하는 Android 애플리케이션에 특히 필요한 단계를 다루었지만 Google Play Billing API에는 자체 용어가 있으며 클라이언트 및 백엔드 구성요소를 포함합니다. 프로덕션의 애플리케이션에 통합하기 전에 Google Play 결제 및 Digital Goods API 문서를 읽고 개념을 이해하는 것이 좋습니다.