@@ -34,7 +34,12 @@ class OpenIapHorizonModule(
3434 try {
3535 val builder = BillingClient .newBuilder(context)
3636 .setListener(this @OpenIapHorizonModule)
37- .enablePendingPurchases()
37+ .enablePendingPurchases(
38+ PendingPurchasesParams
39+ .newBuilder()
40+ .enableOneTimeProducts()
41+ .build()
42+ )
3843 if (! appId.isNullOrEmpty()) builder.setAppId(appId)
3944 billingClient = builder.build()
4045 billingClient?.startConnection(object : BillingClientStateListener {
@@ -147,7 +152,7 @@ class OpenIapHorizonModule(
147152 getAvailablePurchases(null ).filter { it.productId.isNotEmpty() }
148153
149154 override suspend fun requestPurchase (
150- request : RequestPurchaseAndroidProps ,
155+ request : RequestPurchaseParams ,
151156 type : ProductRequest .ProductRequestType ,
152157 ): List <OpenIapPurchase > = withContext(Dispatchers .IO ) {
153158 val client = billingClient ? : throw OpenIapError .NotPrepared
@@ -166,7 +171,7 @@ class OpenIapHorizonModule(
166171 }
167172 client.queryProductDetailsAsync(q) { br, pd ->
168173 if (br.responseCode != BillingClient .BillingResponseCode .OK ) {
169- purchaseErrorListeners.forEach { runCatching { it.onPurchaseError(OpenIapError .QueryProduct (br.debugMessage ? : " Query failed " )) } }
174+ purchaseErrorListeners.forEach { runCatching { it.onPurchaseError(OpenIapError .QueryProduct ()) } }
170175 if (cont.isActive) cont.resume(emptyList())
171176 return @queryProductDetailsAsync
172177 }
@@ -193,7 +198,7 @@ class OpenIapHorizonModule(
193198 .build()
194199 val r = client.launchBillingFlow(activity, flow)
195200 if (r.responseCode != BillingClient .BillingResponseCode .OK ) {
196- purchaseErrorListeners.forEach { runCatching { it.onPurchaseError(OpenIapError .PurchaseFailed (r.debugMessage ? : " Billing flow failed " )) } }
201+ purchaseErrorListeners.forEach { runCatching { it.onPurchaseError(OpenIapError .PurchaseFailed ()) } }
197202 if (cont.isActive) cont.resume(emptyList())
198203 }
199204 // Wait for onPurchasesUpdated to deliver
@@ -258,7 +263,7 @@ class OpenIapHorizonModule(
258263 BillingClient .BillingResponseCode .USER_CANCELED -> OpenIapError .UserCancelled
259264 BillingClient .BillingResponseCode .ITEM_ALREADY_OWNED -> OpenIapError .ItemAlreadyOwned
260265 BillingClient .BillingResponseCode .ITEM_NOT_OWNED -> OpenIapError .ItemNotOwned
261- else -> OpenIapError .PurchaseFailed (billingResult.debugMessage ? : " Horizon purchase failed " )
266+ else -> OpenIapError .PurchaseFailed ()
262267 }
263268 purchaseErrorListeners.forEach { runCatching { it.onPurchaseError(err) } }
264269 currentPurchaseCallback?.invoke(Result .success(emptyList()))
0 commit comments