Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Androidのアプリ内課金をAACで実装する
Search
syarihu
April 10, 2019
Programming
4
18k
Androidのアプリ内課金をAACで実装する
In-tamachi Billing Nightで発表した資料です。
https://billing-night.connpass.com/event/125510/
syarihu
April 10, 2019
Tweet
Share
More Decks by syarihu
See All by syarihu
[DroidKaigi 2024] Android ViewからJetpack Composeへ 〜Jetpack Compose移行のすゝめ〜 / From Android View to Jetpack Compose: A Guide to Migration
syarihu
2
2.1k
[shibuya.apk #46] Composableの枠を超えてアニメーションする / Animation beyond Composable
syarihu
0
9
[shibuya.apk #41] Jetpack Composeでグリッドに柔軟にスペースを入れたい
syarihu
0
2.6k
[DroidKaigi 2022] 詳解Google Playの新しい定期購入 ~オファーの活用や実装例を添えて~
syarihu
0
3.2k
5分で分かるGoogle Playの新しいサブスクリプション / Google Play new subscription 2022
syarihu
1
1.7k
[DroidKaigi 2021] Google Play 定期購入 比例配分モード完全攻略ガイド / Google Play Subscription Proration Mode Complete Guide
syarihu
1
7.4k
[Money Forward Tech Drive] What's new in Google Play [Recap #io21]
syarihu
0
530
[Android 11 Meetups] Google Play Commerce からのアップデート / Android 11 Meetups Google Play Commerce
syarihu
4
2.8k
[potatotips #70] license-list-pluginを使ってOSSライセンス画面を自動生成する / license-list-plugin
syarihu
4
4.5k
Other Decks in Programming
See All in Programming
いかにして不足・不整合なくデータ移行したか
tjmtmmnk
1
970
4年間変わらなかった YOUTRUSTのアーキテクチャ
daiki1003
2
710
gopls を改造したら開発生産性が高まった
satorunooshie
7
140
Go言語でターミナルフレンドリーなAIコマンド、afaを作った/fukuokago20_afa
monochromegane
2
110
Cloud Adoption Framework にみる組織とクラウド導入戦略
tomokusaba
2
690
テスト駆動開発✅️
akitoshiga
1
180
Honoの来た道とこれから
yusukebe
17
2.5k
offers_20241022_imakiire.pdf
imakurusu
1
140
Vertical Architectures for Scalable Angular Applications
manfredsteyer
PRO
0
240
Vaporモードを大規模サービスに最速導入して学びを共有する
kazukishimamoto
3
3.2k
Re:proS_案内資料
rect
0
210
Kubernetes for Data Engineers: Building Scalable, Reliable Data Pipelines
sucitw
1
110
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
Embracing the Ebb and Flow
colly
84
4.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
13
1.8k
Unsuck your backbone
ammeep
668
57k
Become a Pro
speakerdeck
PRO
24
4.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Facilitating Awesome Meetings
lara
49
6k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Building an army of robots
kneath
302
42k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Gamification - CAS2011
davidbonilla
80
5k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Transcript
Androidの アプリ内課金を AACで実装する In-tamachi Billing Night 2019/04/10 (Wed) @syarihu
Taichi Sato (@syarihu) • Money Forward, Inc. ◦ Android Engineer
• TechBooster
None
勉強会開催の経緯
None
年額課金をリリース! • 月額課金に加えて年額課金がで きるようになった • 年額課金を実装する際、課金周 りの知見が少なくて困った
None
アプリ内課金の勉強会開催へ • そんな感じでつぶやいてみた • 「ええやん」ってなって開催するこ とになった
アプリ内課金の勉強会開催へ • Subscriptionだと定期購読だけ になってしまうので In-tamachi Billing Nightになっ た
Androidのアプリ内課金を AACで実装する
定期購入とは?
定期購入とは? • Play Consoleで管理可能な アプリ内アイテムは3種類ある
定期購入とは? • 管理対象アイテム • 定期購入 • 特典アイテム
定期購入とは? • 管理対象アイテム • 定期購入 • 特典アイテム
定期購入とは? • 週、月、3ヶ月、6ヶ月、年間のい ずれかの期間で定期的に課金で きるアイテム • 新規購入者に対して、無料期間 やお試し価格の設定も可能
定期購入とは? • ある定期購入アイテムから 別の定期購入アイテムへのアッ プグレードまたはダウングレード を行う仕組みも提供
定期購入のアップグレードと ダウングレード • ユーザーは定期購入期間の終了 を待たず、グレード変更可能 • 変更前のプランですでに無料期 間を終えている場合は 新たに無料期間は発生しない
定期購入のアップグレードと ダウングレード • グレード変更を行うと現在有効な 定期購入はただちにキャンセルさ れ、新たな定期購入が作成され る
定期購入のアップグレードと ダウングレード • 最初の支払いは前の定期購入の 未使用分を使い切ったあとから 始まる
月額プラン 500円 / 月 プラン変更 2019年04月15日 年額プラン 5,500円 / 年
支払い日 2019年04月01日
月額プラン 500円 / 月 プラン変更 2019年04月15日 年額プラン 5,500円 / 年
支払い日 2019年04月01日 500円 / 30日 = 16.66円 / 日 250円分使用
月額プラン 500円 / 月 プラン変更 2019年04月15日 年額プラン 5,500円 / 年
支払い日 2019年04月01日 500円 / 30日 = 16.66円 / 日 250円分使用
月額プラン 500円 / 月 プラン変更 2019年04月15日 年額プラン 5,500円 / 年
支払い日 2019年04月01日 500円 / 30日 = 16.66円 / 日 250円分使用 前プランの残り = 250円
月額プラン 500円 / 月 プラン変更 2019年04月15日 年額プラン 5,500円 / 年
支払い日 2019年04月01日 500円 / 30日 = 16.66円 / 日 250円分使用 前プランの残り = 250円 5,500円 / 365日 = 15.07円 / 日
月額プラン 500円 / 月 プラン変更 2019年04月15日 年額プラン 5,500円 / 年
支払い日 2019年04月01日 500円 / 30日 = 16.66円 / 日 250円分使用 前プランの残り = 250円 5,500円 / 365日 = 15.07円 / 日 250円 / 15.07円 = 1日分使用可能 (16.58円)
月額プラン 500円 / 月 プラン変更 2019年04月15日 年額プラン 5,500円 / 年
支払い日 2019年04月01日 500円 / 30日 = 16.66円 / 日 250円分使用 前プランの残り = 250円 5,500円 / 365日 = 15.07円 / 日 250円 / 15.07円 = 1日分使用可能 (16.58円) 新プラン支払い開始 2019年04月17日
定期購入のアップグレードと ダウングレード • 2019年04月17日以降は毎年04 月17日に課金が発生する
定期購入のアップグレードと ダウングレード • 定期購入アイテム間のアップグ レードやダウングレードの関係性 はPlay Consoleで何か 設定するわけではない
定期購入のアップグレードと ダウングレード • 古いプランから新しいプランへ移 行するといった関連付けは実装 をする際に行う
定期購入のアップグレードと ダウングレード • たとえば年額プランから月額プラ ンへのアップグレードをするなど の見せ方も開発者が定義する
Google Play Billing Libraryを利用する
Google Play BIlling Library • アプリ内課金に便利なクラスを提 供するライブラリ • Google Playアプリとの通信を行
うIn-app Billing APIの操作もライ ブラリ内部に隠蔽されている
Google Play BIlling Library
Google Play BIlling Library AACも利用するので一緒に入れておく
ViewModelでBillingClient を管理する
ViewModelでBillingClientを管理する
ViewModelでBillingClientを管理する
ViewModelでBillingClientを管理する
Google Playのアプリ内 課金サービスに接続する
BillingClientStateListenerの実装と startConnectionの実行
BillingClientStateListenerの実装と startConnectionの実行
BillingClientStateListenerの実装と startConnectionの実行
LifecycleObserverを使って onCreateで接続を開始する
LifecycleObserverを使って onCreateで接続を開始する
LifecycleObserverを使って onCreateで接続を開始する
ViewModelの破棄時に接続を解除する
ViewModelの破棄時に接続を解除する
LiveDataで状態を管理する
各状態を表すsealedクラス
各状態を表すsealedクラス
各状態を表すsealedクラス
BillingStatusをLiveDataで管理する
BillingStatusをLiveDataで管理する
BillingStatusをLiveDataで管理する
BillingStatusをLiveDataで管理する
アプリ内アイテムを 管理する
アプリ内アイテムを管理する
アプリ内アイテムを管理する
アプリ内アイテムを管理する
アプリ内アイテムを管理する
商品情報を取得する
商品情報を取得する
商品情報を取得する
商品情報を取得する
商品情報を取得する
商品情報を取得する
商品情報を取得する
定期購入アイテムを 購入する
定期購入アイテムを購入する
定期購入アイテムを購入する
定期購入アイテムを購入する
定期購入アイテムを購入する
定期購入アイテムを購入する
定期購入アイテムを購入する
定期購入アイテムを購入する
None
定期購入のアップグレードを 行う
定期購入のアップグレードを行う
定期購入のアップグレードを行う
定期購入のアップグレードを行う
定期購入のアップグレードを行う
定期購入のアップグレードを行う
定期購入のアップグレードを行う
定期購入のアップグレードを行う
定期購入のアップグレードを行う
定期購入のアップグレードを行う
定期購入のアップグレードを行う
None
None
まとめ
まとめ • グレード変更後の最初の支払い は前の定期購入の未使用分を使 い切ったあとから始まる
まとめ • 定期購入アイテム間のアップグ レードやダウングレードの関係性 はPlay Consoleで何か 設定するわけではない • グレード変更の関連付けは 実装時に行う
まとめ • Play Billing Libraryの BillingClientはViewModelで管 理するとよい • Play Billing
Libraryの各状態は sealedクラスで定義し、LiveData で状態管理すると楽
まとめ • 課金アイテムの情報はenumクラ スで管理しておくと楽
まとめ • アプリ内課金の知見はWebにあ まりないのでみんな知ってるで しょって思ってることでも共有して ほしい
アプリ内課金の検証や テストコードなどの より詳細な話は技術書典で!
宣伝
None
TechBooster 技術書典6 新刊 [さ05] Android Qなどの最新モ バイル開発情報、 TensorFlow内部の誰も知 らない最適化、今すぐ使え るアプリ内課金やテスト、
Safe Argsなど盛りだくさん 144pです! サークル詳細 | TechBooster | 技術書典 https://techbookfest.org/event/tbf06/circle/61870001
ありがとうございました