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
消費型課金を導入する / Introduction to consumable In-App ...
Search
morizooo
May 01, 2018
Technology
0
510
消費型課金を導入する / Introduction to consumable In-App Billing
morizooo
May 01, 2018
Tweet
Share
More Decks by morizooo
See All by morizooo
Flipperを活用した デバッグ効率化について/flipper
morizooo
0
740
Androidアプリをリアーキテクチャした話/Android-rearchitecture
morizooo
1
210
Mirrativ-android-efforts
morizooo
1
7.5k
Android上でUnityを動かすためのノウハウ / Android with Unity
morizooo
2
810
カンファレンスアプリを作ったぞ!! / builderscon tokyo 2017 LT
morizooo
0
3.2k
Other Decks in Technology
See All in Technology
ニッポンの人に知ってもらいたいGISスポット
sakaik
0
110
Modern_Data_Stack最新動向クイズ_買収_AI_激動の2025年_.pdf
sagara
0
240
小学4年生夏休みの自由研究「ぼくと Copilot エージェント」
taichinakamura
0
640
OCI Network Firewall 概要
oracle4engineer
PRO
2
7.9k
カンファレンスに託児サポートがあるということ / Having Childcare Support at Conferences
nobu09
1
530
Performance Insights 廃止から Database Insights 利用へ/transition-from-performance-insights-to-database-insights
emiki
0
210
ガバメントクラウドの概要と自治体事例(名古屋市)
techniczna
2
230
Codexとも仲良く。CodeRabbit CLIの紹介
moongift
PRO
0
140
社内報はAIにやらせよう / Let AI handle the company newsletter
saka2jp
8
1.4k
衛星画像超解像化によって実現する2D, 3D空間情報の即時生成と“AI as a Service”/ Real-time generation spatial data enabled_by satellite image super-resolution
lehupa
0
140
これがLambdaレス時代のChatOpsだ!実例で学ぶAmazon Q Developerカスタムアクション活用法
iwamot
PRO
6
960
Simplifying Cloud Native app testing across environments with Dapr and Microcks
salaboy
0
140
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
65
7.9k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
The Invisible Side of Design
smashingmag
302
51k
BBQ
matthewcrist
89
9.8k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
KATA
mclloyd
32
15k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
114
20k
Site-Speed That Sticks
csswizardry
11
900
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Transcript
消費型課金を導入する 2018.04.19 morizooo Potatotips #50 © 2018 Mirrativ, Inc.
•Profile •morizooo •2月からミラティブのAndroid作ってます https://www.mirrativ.com/
•課金方式 •消費型課金 - 購入後に消費リクエストを行うことにより再度購入できる方式 - アプリ内のアイテム購入時に使う •非消費型課金 - 一度だけ購入できる方式 -
一度だけ買えるお得なアイテムや権利をつけるときに使う •購読型課金 - 一定期間ごとに自動的に繰り返し課金を行う方式 - 会員権の継続に使う
•Play Billing Library •2017年9/19日にリリース - 内部のフローはIn-app Billing Version 3 APIと同じ
- 使いやすいインタフェースが定義されたラッパーのライブラリ
•Play Billing Library •サンプル実装が存在 1. https://github.com/googlesamples/android-play-billing/tree/ master/TrivialDrive_v2 2. https://github.com/googlecodelabs/play-billing-codelab -
アプリの見た目は同じ - TrivialDrive_v2の方がしっかり作ってある - play-billing-codelabは署名ファイルが入っていてすぐ動く まずplay-billing-codelab触って間食掴んでから TrivialDrive_v2を触るのがオススメ
•Play Billing Library •できること •課金できる端末かチェック •購入情報取得 •商品情報取得 •Google Playの購入画面を出す BillingClientの
- startConnection - querySkuDetailsAsync - launchBillingFlow - consumeAsync の呼び出しとリスナー定義すれば実装できる
•課金フロー •PlayBillingLibraryを通して購入処理を実行する - 以前の課金情報が見つかればスキップする場合もあり ①
•課金フロー •Googleからレシートを受け取る - レシートの署名鍵の確認を行う(サーバー側でやってもよい) ②
•課金フロー •サーバーに対してレシートの検証を行う - 購入したアイテム・ユーザの情報も送ってます ③
•課金フロー •Googleに対してレシートの検証を行う - Google Play Developer APIのPurchases.products: getを使う https://developers.google.com/android-publisher/api-ref/purcha ses/products/get
④
•課金フロー •レシートの結果を受け取る - 内容は正常でも既に登録されていないかチェックする - 結果を永続化して残す ⑤
•課金フロー •レシートの検証結果を受け取る - 既に使用されているレシートが来た場合も消費処理を行うために成 功として返しています ⑥
•課金フロー •検証成功ならPlayBillingLibraryから消費リクエストを投げる - この時点で再度購入可能になる ⑦
•課金フロー •①以外のエラーは課金の復元が必要 - 整合性の担保はサーバーサイドでやってます - 同じレシートが何度来ても良いが有効になるのは一度だけ - 復元タイミングはアプリによるので頑張りましょう ①
② ④ ⑥ ③ ⑤ ⑦
•Tips •開発環境でのテスト • 公開しているアプリ情報と一致しないと課金情報取れない - packageName,versionCodeを合わせる必要がある ①:開発用のアプリを作成してプロダクト設定を行う ②:本番アプリのビルド設定を開発用アプリに実行する → QA前日に気づいたので②でやってます
•Tips • 動作確認中のクラッシュ - googleアカウントにログインせずに購入しようとすると突然死 - 購入中に電話が来て、その後に購入すると突然死 → 様々な要因があるので気をつけましょう •
課金フローの沼 - Google上は同じアカウントだが複数端末あって途中でエラーが起 こった場合に別端末が繋いで来たらどうするのか等 →考えるとキリがない。思いつく分の処理は考えておく 最終手段を用意しておく
•まとめ •PlayBillingLibraryで問題なく課金処理が導入できる - developerPayloadが使えないので注意する •In-app Billing Libraryから移行する必要はない •知見あれば教えてください!!!