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

Androidアプリ内課金のテスト

 Androidアプリ内課金のテスト

takuaraki

March 01, 2019
Tweet

More Decks by takuaraki

Other Decks in Technology

Transcript

  1. ΞϓϦΛ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"] }
  2. 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() } }
  3. 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) { // ϞοΫσʔλΛ४උʢ࣍εϥΠυࢀরʣ }
  4. 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() ) }