Android, In-app-billing v6. Multiple consumable items in a single checkout

33 Views Asked by At

I developed an app that provides the possibility to purchase multiple items in a single checkout.

For instance, the app cart\bucket contains:

  • 1 x Candy
  • 1 x Apple
  • 1 x Orange

The code I implemented:

sealed class ProductDto(
    open val id: String,
) {
    
    data object Candy : ProductDto(id = "product_id_candy")
    
    // other products
}
    override fun purchaseMultipleProducts(
        activity: Activity,
        productSet: Set<Product>,
    ): BillingFlowResponse {
        val productDetailsList: List<ProductDetails> = billingWrapper.getProductDetailsList(productSet)
        val productDetailsParamsList = mutableListOf<BillingFlowParams.ProductDetailsParams>()
        productSet.forEach { product: Product ->
            val productDto = ProductMapper.toProductDto(product)
            productDetailsList.firstOrNull {
                it.productId == productDto.id
            }?.let { productDetails: ProductDetails ->
                getProductDetailsParamsList(
                    productDetails = productDetails,
                ).also { productDetailsParamsList.addAll(it) }
            }
        }
        val billingFlowParams = BillingFlowParams.newBuilder()
            .setProductDetailsParamsList(productDetailsParamsList)
            .build()
        return billingClient.launchBillingFlow(activity, billingFlowParams).run {
            BillingFlowResponse.getBillingFlowResponse(result = this)
        }
    }

    private fun getProductDetailsParamsList(
        productDetails: ProductDetails,
    ): List<BillingFlowParams.ProductDetailsParams> {
        return mutableListOf<BillingFlowParams.ProductDetailsParams>().apply {
            add(
                BillingFlowParams.ProductDetailsParams.newBuilder()
                    .setProductDetails(productDetails)
                    .build()
            )
        }
    }

Everything worked fine until I uploaded a list of new items into my Google Play Developer Console via *.csv file.

Since that action the app shows the following error when the user fills the app cart\bucket with the same amount of items.

the error inside Google In-App-Billing Bottomsheet

ERROR
Something went wrong on our end. Please try again

android.developer.com doc : ERROR

All the items within the Google Play Developer Console has enabled Allow users to purchase more than 1 of this product in a single transaction feature.

Before the *.csv file been uploaded the Android app demonstrates Google In-App-Billing Bottomsheet with the following schematic UI:

| Google Play                                         |
|-----------------------------------------------------|
|  App | <The app name>   | <currency><total price>   |
| icon | <- Candy (<app name>)>                       |
|        <- Apple (<app name>)>                       |
|        <- Orange (<app name>)>                      |
|-----------------------------------------------------|
| // ... all the other service data                   |

App properties:

  • target \ compile SDK: 34
  • In-App-Billing (com.android.billingclient:billing-ktx:6.1.0)

If the user adds only one item and request purchase the billing flow processed it correctly. BTW, the user can change the quantity for an item within the Google In-App-Billing Bottomsheet by clicking native + button up to 10.

0

There are 0 best solutions below