Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What’s new in Google Play Billing

ymnder
June 21, 2018

What’s new in Google Play Billing

potatotips#52 @FOLIO 2018/06/21
https://potatotips.connpass.com/event/88164/

ymnder

June 21, 2018
Tweet

More Decks by ymnder

Other Decks in Programming

Transcript

  1. What’s new in Google Play Billing
    potatotips#52 @FOLIO 2018/06/21 @ymnd

    View Slide

  2. ࠓ೔ͷ͓඼ॻ͖
    • ࠓ೔࿩͢͜ͱ
    • What’s new in Play Store App
    • What’s new in Play Billing Library
    • ࠓ೔࿩͞ͳ͍͜ͱ
    • What’s new in Play Console
    • What’s new in Play Billing API
    • What’s new in Play Billing Test
    • Getting started with Play Billing Library
    2

    View Slide

  3. ᶃWhat’s new in Play Store App
    • ؅ཧը໘ͷมߋ
    • Discover New
    • Manage
    • Backup FOP
    • ΞϓϦͱͷ࿈ܞ
    • Deep Link
    • ղ໿෼ੳͷڧԽ
    • Cancel Survey
    3

    View Slide

  4. ᶃ؅ཧը໘ͷมߋ
    • Discover NewɿఆظߪೖͷϦίϝϯυ
    4

    View Slide

  5. ᶃ؅ཧը໘ͷมߋ
    • Manageɿ؅ཧը໘͕࢖͍΍͘͢ͳΓ·ͨ͠
    5

    View Slide

  6. ᶃ؅ཧը໘ͷมߋ
    • ఆظߪೖ৘ใ
    • ܖ໿ϓϥϯ
    • ܖ໿ͷߋ৽೔
    • ࢧ෷͍৘ใ
    • ࢧ෷͍ํ๏ͷߋ৽
    • ༧උͷࢧ෷͍ํ๏
    • ref: Account Hold
    • ղ໿ͱ࠶։
    • RTDN
    • http://g.co/play/billing-rtdn
    6

    View Slide

  7. ᶃΞϓϦͱͷ࿈ܞ: Deep Link
    • https://play.google.com/store/account/subscriptions?
    sku=XXX&package=YYY
    • ࠓ·Ͱ͸ΞϓϦ͔Β௚઀؅ཧը໘Λ։͚ͳ͔ͬͨ
    • ಋઢ͕ඇৗʹ෼͔Γʹ͍͘
    • ௚઀ࣗ෼ͷΞϓϦͷఆظߪೖͷ؅ཧը໘ʹભҠՄೳ
    • ࢧ෷Τϥʔͷमਖ਼΍ղ໿ͳͲ
    7

    View Slide

  8. ᶃղ໿෼ੳͷڧԽ
    • Cancel Survey
    • ղ໿࣌ʹཧ༝Λฉ͘
    • PlayConsoleͰ෼ੳ
    8

    View Slide

  9. ᶄWhat’s new in Play Billing Library: v1.1
    • Play Billing Library is updated: 2018/5/7
    • ᶃBillingFlowParamsʹproration mode͕ࢦఆͰ͖ΔΑ
    ͏ʹͳͬͨ
    • ᶄlaunchBillingFlow()Λߦͬͨͱ͖ʹcallbackʹࣦഊ࣌
    ΋Ϩεϙϯε͕౉͞ΕΔΑ͏ʹͳͬͨ
    9

    View Slide

  10. ᶄproration mode: ൺྫ഑෼
    • ఆظߪೖͷΞοϓάϨʔυʗμ΢ϯάϨʔυΛߦ͏
    • skuIdΛ৽͍͠঎඼ʹஔ͖׵͑Δ
    • replaceSkusProrationModeΛ࢖͏
    • ैདྷͷreplaceSkusProration͸αϙʔτ͞Εͳ͘ͳͬͨ
    10

    View Slide

  11. ᶄproration mode
    11
    val flowParams = BillingFlowParams.newBuilder()
    .setSku(skuId)
    .setType(billingType)
    .setOldSku(oldSkus)
    .setReplaceSkusProrationMode(replaceSkusProrationMode)
    .build()
    public Builder setReplaceSkusProrationMode(@ProrationMode int replaceSkusProrationMode) {
    this.mReplaceSkusProrationMode = replaceSkusProrationMode;
    return this;
    }
    public Builder setReplaceSkusProration(boolean bReplaceSkusProration) {
    mParams.mNotReplaceSkusProration = !bReplaceSkusProration;
    return this;
    }

    View Slide

  12. ᶄproration mode: v1.1
    12
    /**
    * Specifies the mode of proration during subscription upgrade/downgrade. This value will only
    * be effective if oldSkus is set.
    *
    * If you set this to NO_PRORATION, the user does not receive credit or charge, and the
    * recurrence date does not change.
    *
    * If you set this to PRORATE_BY_TIME, Google Play swaps out the old SKUs and credits the
    * user with the unused value of their subscription time on a pro-rated basis. Google Play
    * applies this credit to the new subscription, and does not begin billing the user for the new
    * subscription until after the credit is used up.
    *
    * If you set this to PRORATE_BY_PRICE, Google Play swaps out the old SKUs and keeps the
    * recurrence date not changed. User will be charged for the price differences to cover the
    * time till next recurrence date.
    *
    * Optional:
    *
    *
    * To buy in-app item
    * To create a new subscription
    * To replace an old subscription
    *
    */
    public Builder setReplaceSkusProrationMode(@ProrationMode int replaceSkusProrationMode) {
    this.mReplaceSkusProrationMode = replaceSkusProrationMode;
    return this;
    }

    View Slide

  13. ᶄproration mode: v1.0
    13
    /**
    * Specify an optional flag indicating whether the user should be credited for any unused
    * subscription time on the SKUs they are upgrading or downgrading.
    *
    * If you set this field to false, the user does not receive credit for any unused
    * subscription time and the recurrence date does not change. Otherwise, Google Play swaps
    out
    * the old SKUs and credits the user with the unused value of their subscription time on a
    * pro-rated basis. Google Play applies this credit to the new subscription, and does not
    begin
    * billing the user for the new subscription until after the credit is used up.
    *
    * Optional:
    *
    *
    * To buy in-app item
    * To create a new subscription
    * To replace an old subscription
    *
    */
    public Builder setReplaceSkusProration(boolean bReplaceSkusProration) {
    mParams.mNotReplaceSkusProration = !bReplaceSkusProration;
    return this;
    }

    View Slide

  14. ᶄproration mode: from document
    • IMMEDIATE_WITH_TIME_PRORATION: default
    • ঎඼IDͷஔ͖׵͑͸௚ͪʹ༗ޮʹͳ৽͍͠༗ޮظݶ͸ൺྫ഑
    ෼ͯ͠ܭࢉ͞ΕɺϢʔβʔʹ੥ٻ͞ΕΔ
    • IMMEDIATE_AND_CHARGE_PRORATED_PRICE
    • ঎඼IDͷஔ͖׵͑͸௚ͪʹ༗ޮʹͳΓɺ੥ٻαΠΫϧ͸ಉ͡
    ··Ͱɺ࢒Γͷظؒͷྉ͕ۚ՝ۚ͞ΕΔʢupgrade onlyʣ
    • IMMEDIATE_WITHOUT_PRORATION
    • ঎඼IDͷஔ͖׵͑͸௚ͪʹ༗ޮʹͳΓɺ੥ٻαΠΫϧ͸ಉ͡
    ··Ͱɺ࣍ͷ੥ٻαΠΫϧ࣌ʹ৽͍͠Ձ͕֨ద༻͞ΕΔ
    14

    View Slide

  15. ᶄproration mode: example
    • 4/1͔ΒA($2/month)ͷఆظߪೖΛ։࢝͢Δ
    • Ϣʔβʔ͸B($3/month)ͷϓϥϯʹΞοϓσʔτ͢Δ
    15
    4/1 5/1
    A
    B

    View Slide

  16. ᶄproration mode
    • IMMEDIATE_WITH_TIME_PRORATION
    16
    4/1 5/1
    A
    B
    4/15
    {
    $1(15days)
    {
    $1(10days)
    4/26
    $3
    طʹࢧ෷ͬͨ෼Λॆ౰

    View Slide

  17. ᶄproration mode
    • IMMEDIATE_AND_CHARGE_PRORATED_PRICE
    17
    4/1 5/1
    A
    B
    4/15
    {
    $1(15days)
    {
    $1.5(15days)
    ࠩ෼ͷ+$0.5Λ੥ٻ
    $3

    View Slide

  18. ᶄproration mode
    • IMMEDIATE_WITHOUT_PRORATION
    18
    4/1 5/1
    A
    B
    4/15
    {
    $2(15days)
    ௥Ճ੥ٻͳ͘Ҡߦ
    $3

    View Slide

  19. ᶄproration mode
    • IMMEDIATE_WITH_TIME_PRORATION
    • ೔ׂΓܭࢉΛߦ͍࢒೔਺෼ͷΫϨδοτΛॆ౰͢Δ
    • ΫϨδοτΛ࢖͍੾ͬͨΒ࣍ͷఆظߪೖΛ։࢝͢Δ
    • ৽͍͠ߪೖαΠΫϧͱͳΔ
    • IMMEDIATE_AND_CHARGE_PRORATED_PRICE
    • ࢒೔਺෼ఆظߪೖ͢Δͷʹ͍͘Β͔͔Δ͔ܭࢉ͢Δ
    • ࠓͷΫϨδοτͱൺֱ͠଍Γͳֹ͍Λ௥Ճ੥ٻ͢Δ
    • ߪೖαΠΫϧ͸ಉ͡
    • IMMEDIATE_WITHOUT_PRORATION
    • ࢒೔਺෼͸௥Ճ੥ٻ͠ͳ͍
    • ߪೖαΠΫϧ͸ಉ͡
    19

    View Slide

  20. ᶄproration mode
    • ݱࡏ͸ఆظߪೖͷֹۚΛมߋ͢ΔࡍʹskuIdΛ৽نʹ࡞
    ੒͢Δඞཁ͕͋Δ
    • I/OͰɺskuIdΛมߋ͠ͳͯ͘΋ֹۚมߋͰ͖Δ৽ػೳ͕
    ঺հ͞Εͨ
    20

    View Slide

  21. ᶄprice charge of existing SKU: EAP
    21

    View Slide

  22. ᶄlaunchBillingFlow calls listener on fail
    • launchBillingFlow()Λߦͬͨͱ͖ʹcallbackʹࣦഊ࣌΋
    Ϩεϙϯε͕౉͞ΕΔΑ͏ʹͳͬͨ
    • ࠓ·Ͱ͸੒ޭ͔࣌͠listener͕ݺ͹Εͳ͔ͬͨ
    22
    public interface PurchasesUpdatedListener {
    void onPurchasesUpdated(@BillingResponse int responseCode, @Nullable List purchases);
    }

    View Slide

  23. ᶄlaunchBillingFlow: v1.0
    23
    @Override
    public int launchBillingFlow(Activity activity, BillingFlowParams params) {
    if (!isReady()) {
    return BillingResponse.SERVICE_DISCONNECTED;
    }
    @SkuType String skuType = params.getSkuType();
    String newSku = params.getSku();
    // Checking for mandatory params fields
    if (newSku == null) {
    BillingHelper.logWarn(TAG, "Please fix the input params. SKU can't be null.");
    return BillingResponse.DEVELOPER_ERROR;
    }

    }

    View Slide

  24. ᶄlaunchBillingFlow: v1.1
    24
    private int broadcastFailureAndReturnBillingResponse(@BillingResponse int responseCode) {
    mBroadcastManager.getListener().onPurchasesUpdated(responseCode, /* List= */null);
    return responseCode;
    }
    @Override
    public int launchBillingFlow(Activity activity, BillingFlowParams params) {
    if (!isReady()) {
    return broadcastFailureAndReturnBillingResponse(BillingResponse.SERVICE_DISCONNECTED);
    }
    @SkuType String skuType = params.getSkuType();
    String newSku = params.getSku();
    // Checking for mandatory params fields
    if (newSku == null) {
    BillingHelper.logWarn(TAG, "Please fix the input params. SKU can't be null.");
    return broadcastFailureAndReturnBillingResponse(BillingResponse.DEVELOPER_ERROR);
    }

    }

    View Slide

  25. Note
    • Grow and optimize your subscriptions with new
    Google Play features
    • https://youtu.be/x1AYelepG6o
    • Code samples: library is v1.0
    • https://github.com/googlesamples/android-play-
    billing/tree/master/ClassyTaxi/android/ClassyTaxi
    25

    View Slide

  26. whoami
    • twitter:@ymnd, github:@ymnder
    • Application Engineer
    • Android ೔ܦిࢠ൛ΞϓϦ
    • Android ࢴ໘ϏϡʔΞʔΞϓϦ
    • ೔ܦిࢠͷຊʢిࢠ൛ʣ͸͜͜ʹ͋Γ·͢
    • https://goo.gl/7Qd6Dh
    • ٕज़ϒϩάʹԣॻ͖ͷهࣄΛܝࡌͯ͋͠Γ·͢
    • https://hack.nikkei.com/blog
    26

    View Slide

  27. ఆظߪೖ΍͍͖ͬͯ

    View Slide