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

Androidアプリ内課金のテスト

 Androidアプリ内課金のテスト

C49eed1cf04caeb4de645d6d9117708d?s=128

takuaraki

March 01, 2019
Tweet

Transcript

  1. ΞϓϦ಺՝ۚͷςετ 2019/03/01 @ara_tack

  2. ʢߥ໦୎ʣ !BSB@UBDL '63:6$PSQPSBUJPO

  3. ͜ͷൃදʹ͍ͭͯ • Androidͷ՝ۚͷجૅ • ՝ۚ΁ͷಓͷΓ • ্ख͘՝͕ۚͰ͖ͳ͍ͱ͖͸ʁ • Play StoreΛ࢖Θͣʹಈ࡞֬ೝ

    (billingx) • ৄࡉͳ՝ۚͷ࣮૷ʹ͍ͭͯ͸࿩͞ͳ͍
  4. AndroidΞϓϦ಺՝ۚ Google Play ΞϓϦͱ΍ΓऔΓ͍ͯ͠Δ (PPHMF1MBZ "QQ .Z"QQ 8SBQQFS 1MBZ#JMMJOH-JCSBSZ *O"QQ#JMMJOH"1*

  5. ߪೖͰ͖Δ঎඼ͷछྨ • One-time products: 1ճ͚ͩߪೖͰ͖Δ঎඼ • Subscriptions: ఆظߪೖ

  6. One-time products • 1ճ͚ͩߪೖͰ͖Δ঎඼ • ΞΠςϜ΍ػೳΛߪೖ͢Δͷʹ޲͍͍ͯΔ

  7. Subscriptions • ఆظߪೖΞΠςϜ • Ұఆظؒ͝ͱʹࢧ෷͍͕ൃੜ͢Δ • ձһαʔϏεͳͲʹ࢖ΘΕΔ

  8. ՝ۚ΁ͷಓͷΓ • Developerొ࿥ • ΞϓϦΛPlay ConsoleʹΞοϓϩʔυ͢Δ • Play ConsoleͰΞΠςϜͷొ࿥Λ͢Δ

  9. Developerొ࿥ • GoogleΞΧ΢ϯτΛ༻ҙ͢Δ • $25෷͏ • Google Play Console͕࢖͑ΔΑ͏ʹͳΔ

  10. ΞϓϦΛPlay Consoleʹ্͛Δ • ϦϦʔεϏϧυͷΞϓϦ͕ඞཁ • ূ໌ॻ΋ϦϦʔε࣌ͷ΋ͷΛར༻ • Billingͷύʔϛογϣϯ͕ඞཁ • ެ։͕ඞཁʢΫϩʔζ൛Ͱ΋Α͍ʣ

  11. ΞϓϦΛPlay Consoleʹ্͛Δ ςετ༻ͷΞϓϦʹ͍ͭͯ • ΞϓϦέʔγϣϯID΍ূ໌ॻΛϦϦʔε༻ͱ ߹ΘͤΔ • ςετ༻ͷผΞϓϦͱͯ͠Play Consoleʹ͋ ͛Δͷ΋OK

  12. ΞϓϦΛPlay Consoleʹ্͛Δ // flavorDimensions͸লུ productFlavors { product { applicationId =

    APPLICATION_ID_PRODUCT } billingTest { applicationId = APPLICATION_ID_PRODUCT } develop { applicationId = APPLICATION_ID_STAGING } } sourceSets { // resΛςετܥͷ΋ͷʹ͢Δ!ςετܥͷAPIΛ࢖͑ΔΑ͏ʹ͢Δ billingTest.res.srcDirs = ["src/develop/res"] }
  13. ঎඼ͷొ࿥Λ͢Δ

  14. ঎඼ͷొ࿥Λ͢Δ • ID: มߋෆՄ • λΠτϧͱઆ໌จɿมߋՄೳ • Ձ֨ɿมߋՄೳ • ੥ٻର৅ظؒɿSubscriptionsͷΈɻมߋෆՄɻि

    ؒɺ݄ผɺ3͔݄ɺ6͔݄ɺ೥ؒ • εςʔλεɿ༗ޮʹ͢Δͱ࡟আͰ͖ͳ͘ͳΔ
  15. None
  16. ςετΞΧ΢ϯτ • Google Play ConsoleͰςετΞΧ΢ϯτ͕ొ ࿥Ͱ͖Δ • ςετΞΧ΢ϯτͰ͸ແྉͰ՝ۚͰ͖Δ • ࣮ࡍͷPlay

    StoreͰͷߪೖͱѻ͍͸Ұॹɻߪೖ ৘ใ΋ಉ͡ɻ஋ஈͱߪಡظ͚͕ؒͩҟͳΔɻ
  17. ςετΞΧ΢ϯτ Subscriptions ͷߪಡظؒ https://developer.android.com/google/play/billing/billing_testing ΑΓҾ༻

  18. ςετΞΧ΢ϯτ

  19. ্ख͘՝͕ۚͰ͖ͳ͍ͱ͖͸ʁ • ΞϓϦʹBillingͷύʔϛογϣϯ͕ͳ͍ • Play Consoleʹ্͕͍ͬͯͳ͍ • ΞϓϦͷূ໌ॻ͕Play Consoleʹ্͍͛ͯΔ΋ͷͱ ҟͳΔ

    • ঎඼͕༗ޮʹͳ͍ͬͯͳ͍ • σϕϩούʔΞΧ΢ϯτͳͷͰ՝ۚͰ͖ͳ͍
  20. Play StoreΛ࢖Θͣʹςετ Play StoreͷϞοΫϨεϙϯεΛఏڙ͢Δ
 ϥΠϒϥϦ • pixiteapps/billingx • NYTimes/Register

  21. billingx • Play Billing LibraryΛϞοΫԽͰ͖Δ • DebugBillingClientΛBillingClientͱͯ͠࢖͏

  22. billingx ࢖༻ྫʣBillingClientFactoryΛ࡞ͬͯDI͢Δ // BillingClient ͷϑΝΫτϦΛఆٛ interface BillingClientFactory { fun createBillingClient(activity:

    Activity, updateListener: PurchasesUpdatedListener): BillingClient }
  23. billingx ࢖༻ྫʣBillingClientFactoryΛ࡞ͬͯDI͢Δ // ຊ൪༻͸ Play Billing Library ͷ BillingClient Λฦ͢

    class ReleaseBillingClientFactory : BillingClientFactory { override fun createBillingClient(activity: Activity, updateListener: PurchasesUpdatedListener): BillingClient { return BillingClient .newBuilder(activity) .setListener(updateListener) .build() } }
  24. billingx ࢖༻ྫʣBillingClientFactoryΛ࡞ͬͯDI͢Δ // σόοά༻͸ DebugBillingClient Λฦ͢ class DebugBillingClientFactory : BillingClientFactory

    { override fun createBillingClient(activity: Activity, updateListener: PurchasesUpdatedListener): BillingClient { initializeData(activity) return DebugBillingClient(activity, updateListener) } } private fun initializeData(activity: Activity) { // ϞοΫσʔλΛ४උʢ࣍εϥΠυࢀরʣ }
  25. billingx ࢖༻ྫʣBillingClientFactoryΛ࡞ͬͯDI͢Δ private fun initializeData(activity: Activity) { BillingStore.defaultStore(activity) .clearProducts() .addProduct(

    SkuDetailsBuilder( sku = BillingManager.SKU_SUBS, type = BillingClient.SkuType.SUBS, price = "$9.99", priceAmountMicros = 9990000, priceCurrencyCode = "USD", title = "Premium Access", description = "Get all the super cool features.", subscriptionPeriod = "p1m", freeTrialPeriod = "p1w" ).build() ) }
  26. billingx ࢖༻ྫʣBillingClientFactoryΛ࡞ͬͯDI͢Δ @Module class BillingClientFactoryModule { @Provides fun provideBillingClientFactory(): BillingClientFactory

    { return if (BuildConfig.DEBUG) { DebugBillingClientFactory() } else { ReleaseBillingClientFactory() } } }
  27. ·ͱΊ • ՝ۚͷͨΊʹPlay Consoleͷઃఆ͕ඞཁ • ՝ۚςετ࣌ʹ͸ϋϚΓϙΠϯτ͕ଟ͍ • Play Storeແ͠Ͱಈ࡞֬ೝ͢Δํ๏΋͋Δ