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
470
消費型課金を導入する / Introduction to consumable In-App Billing
morizooo
May 01, 2018
Tweet
Share
More Decks by morizooo
See All by morizooo
Flipperを活用した デバッグ効率化について/flipper
morizooo
0
680
Androidアプリをリアーキテクチャした話/Android-rearchitecture
morizooo
1
200
Mirrativ-android-efforts
morizooo
1
7.3k
Android上でUnityを動かすためのノウハウ / Android with Unity
morizooo
2
780
カンファレンスアプリを作ったぞ!! / builderscon tokyo 2017 LT
morizooo
0
3.1k
Other Decks in Technology
See All in Technology
データベースの負荷を紐解く/untangle-the-database-load
emiki
2
550
Apache Iceberg Case Study in LY Corporation
lycorptech_jp
PRO
0
380
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership, regardless of position
madoxten
19
9.6k
フォーイット_エンジニア向け会社紹介資料_Forit_Company_Profile.pdf
forit_tech
1
1.7k
LINE NEWSにおけるバックエンド開発
lycorptech_jp
PRO
0
390
貧民的プログラミングのすすめ
kakehashi
PRO
1
150
QAエンジニアが スクラムマスターをすると いいなぁと思った話
____rina____
0
160
MLflowはどのようにLLMOpsの課題を解決するのか
taka_aki
0
140
4th place solution Eedi - Mining Misconceptions in Mathematics
rist
0
150
データモデルYANGの処理系を再発明した話
tjmtrhs
0
330
プロダクト開発者目線での Entra ID 活用
sansantech
PRO
0
140
MIMEと文字コードの闇
hirachan
2
1.5k
Featured
See All Featured
The Language of Interfaces
destraynor
156
24k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
Being A Developer After 40
akosma
89
590k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
440
GraphQLとの向き合い方2022年版
quramy
44
14k
Designing for humans not robots
tammielis
250
25k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
11
540
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
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から移行する必要はない •知見あれば教えてください!!!