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

What’s new in Google Play Billing

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 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
  2. ᶃWhat’s new in Play Store App • ؅ཧը໘ͷมߋ • Discover

    New • Manage • Backup FOP • ΞϓϦͱͷ࿈ܞ • Deep Link • ղ໿෼ੳͷڧԽ • Cancel Survey 3
  3. ᶃ؅ཧը໘ͷมߋ • ఆظߪೖ৘ใ • ܖ໿ϓϥϯ • ܖ໿ͷߋ৽೔ • ࢧ෷͍৘ใ •

    ࢧ෷͍ํ๏ͷߋ৽ • ༧උͷࢧ෷͍ํ๏ • ref: Account Hold • ղ໿ͱ࠶։ • RTDN • http://g.co/play/billing-rtdn 6
  4. ᶄWhat’s new in Play Billing Library: v1.1 • Play Billing

    Library is updated: 2018/5/7 • ᶃBillingFlowParamsʹproration mode͕ࢦఆͰ͖ΔΑ ͏ʹͳͬͨ • ᶄlaunchBillingFlow()Λߦͬͨͱ͖ʹcallbackʹࣦഊ࣌ ΋Ϩεϙϯε͕౉͞ΕΔΑ͏ʹͳͬͨ 9
  5. ᶄ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; } ☓
  6. ᶄproration mode: v1.1 12 /** * Specifies the mode of

    proration during subscription upgrade/downgrade. This value will only * be effective if oldSkus is set. * * <p> If you set this to NO_PRORATION, the user does not receive credit or charge, and the * recurrence date does not change. * * <p>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. * * <p>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. * * <p>Optional: * * <ul> * <li>To buy in-app item * <li>To create a new subscription * <li>To replace an old subscription * </ul> */ public Builder setReplaceSkusProrationMode(@ProrationMode int replaceSkusProrationMode) { this.mReplaceSkusProrationMode = replaceSkusProrationMode; return this; }
  7. ᶄ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. * * <p>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. * * <p>Optional: * * <ul> * <li>To buy in-app item * <li>To create a new subscription * <li>To replace an old subscription * </ul> */ public Builder setReplaceSkusProration(boolean bReplaceSkusProration) { mParams.mNotReplaceSkusProration = !bReplaceSkusProration; return this; }
  8. ᶄproration mode: from document • IMMEDIATE_WITH_TIME_PRORATION: default • ঎඼IDͷஔ͖׵͑͸௚ͪʹ༗ޮʹͳ৽͍͠༗ޮظݶ͸ൺྫ഑ ෼ͯ͠ܭࢉ͞ΕɺϢʔβʔʹ੥ٻ͞ΕΔ

    • IMMEDIATE_AND_CHARGE_PRORATED_PRICE • ঎඼IDͷஔ͖׵͑͸௚ͪʹ༗ޮʹͳΓɺ੥ٻαΠΫϧ͸ಉ͡ ··Ͱɺ࢒Γͷظؒͷྉ͕ۚ՝ۚ͞ΕΔʢupgrade onlyʣ • IMMEDIATE_WITHOUT_PRORATION • ঎඼IDͷஔ͖׵͑͸௚ͪʹ༗ޮʹͳΓɺ੥ٻαΠΫϧ͸ಉ͡ ··Ͱɺ࣍ͷ੥ٻαΠΫϧ࣌ʹ৽͍͠Ձ͕֨ద༻͞ΕΔ 14
  9. ᶄproration mode • IMMEDIATE_WITH_TIME_PRORATION 16 4/1 5/1 A B 4/15

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

    { $1(15days) { $1.5(15days) ࠩ෼ͷ+$0.5Λ੥ٻ $3
  11. ᶄproration mode • IMMEDIATE_WITH_TIME_PRORATION • ೔ׂΓܭࢉΛߦ͍࢒೔਺෼ͷΫϨδοτΛॆ౰͢Δ • ΫϨδοτΛ࢖͍੾ͬͨΒ࣍ͷఆظߪೖΛ։࢝͢Δ • ৽͍͠ߪೖαΠΫϧͱͳΔ

    • IMMEDIATE_AND_CHARGE_PRORATED_PRICE • ࢒೔਺෼ఆظߪೖ͢Δͷʹ͍͘Β͔͔Δ͔ܭࢉ͢Δ • ࠓͷΫϨδοτͱൺֱ͠଍Γͳֹ͍Λ௥Ճ੥ٻ͢Δ • ߪೖαΠΫϧ͸ಉ͡ • IMMEDIATE_WITHOUT_PRORATION • ࢒೔਺෼͸௥Ճ੥ٻ͠ͳ͍ • ߪೖαΠΫϧ͸ಉ͡ 19
  12. ᶄlaunchBillingFlow calls listener on fail • launchBillingFlow()Λߦͬͨͱ͖ʹcallbackʹࣦഊ࣌΋ Ϩεϙϯε͕౉͞ΕΔΑ͏ʹͳͬͨ • ࠓ·Ͱ͸੒ޭ͔࣌͠listener͕ݺ͹Εͳ͔ͬͨ

    22 public interface PurchasesUpdatedListener { void onPurchasesUpdated(@BillingResponse int responseCode, @Nullable List<Purchase> purchases); }
  13. ᶄ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; } … }
  14. ᶄlaunchBillingFlow: v1.1 24 private int broadcastFailureAndReturnBillingResponse(@BillingResponse int responseCode) { mBroadcastManager.getListener().onPurchasesUpdated(responseCode,

    /* List<Purchase>= */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); } … }
  15. 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
  16. whoami • twitter:@ymnd, github:@ymnder • Application Engineer • Android ೔ܦిࢠ൛ΞϓϦ

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