Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Commit 5388f8e

Browse files
committed
chore: rebase main
1 parent d0e3a7d commit 5388f8e

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

openiap/src/horizon/java/dev/hyo/openiap/horizon/OpenIapHorizonModule.kt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.meta.horizon.billingclient.api.BillingFlowParams
1010
import com.meta.horizon.billingclient.api.BillingResult
1111
import com.meta.horizon.billingclient.api.ConsumeParams
1212
import com.meta.horizon.billingclient.api.GetBillingConfigParams
13+
import com.meta.horizon.billingclient.api.PendingPurchasesParams
1314
import com.meta.horizon.billingclient.api.ProductDetails as HorizonProductDetails
1415
import com.meta.horizon.billingclient.api.Purchase as HorizonPurchase
1516
import com.meta.horizon.billingclient.api.PurchasesUpdatedListener
@@ -469,13 +470,34 @@ class OpenIapHorizonModule(
469470
}
470471

471472
private fun buildBillingClient() {
473+
val pendingPurchasesParams = com.meta.horizon.billingclient.api.PendingPurchasesParams.newBuilder()
474+
.enableOneTimeProducts()
475+
.build()
476+
472477
val builder = BillingClient
473478
.newBuilder(context)
474479
.setListener(this)
475-
.enablePendingPurchases()
480+
.enablePendingPurchases(pendingPurchasesParams)
476481
if (!appId.isNullOrEmpty()) {
477482
builder.setAppId(appId)
478483
}
479484
billingClient = builder.build()
480485
}
486+
487+
// Alternative Billing (Google Play only - not supported on Horizon)
488+
override suspend fun checkAlternativeBillingAvailability(): Boolean {
489+
throw OpenIapError.FeatureNotSupported
490+
}
491+
492+
override suspend fun showAlternativeBillingInformationDialog(activity: Activity): Boolean {
493+
throw OpenIapError.FeatureNotSupported
494+
}
495+
496+
override suspend fun createAlternativeBillingReportingToken(): String? {
497+
throw OpenIapError.FeatureNotSupported
498+
}
499+
500+
override fun setUserChoiceBillingListener(listener: dev.hyo.openiap.listener.UserChoiceBillingListener?) {
501+
// Not supported on Horizon
502+
}
481503
}

openiap/src/main/java/dev/hyo/openiap/OpenIapModule.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class OpenIapModule(
234234
* Check if alternative billing is available for this user/device
235235
* Step 1 of alternative billing flow
236236
*/
237-
suspend fun checkAlternativeBillingAvailability(): Boolean = withContext(Dispatchers.IO) {
237+
override suspend fun checkAlternativeBillingAvailability(): Boolean = withContext(Dispatchers.IO) {
238238
val client = billingClient ?: throw OpenIapError.NotPrepared
239239
if (!client.isReady) throw OpenIapError.NotPrepared
240240

@@ -273,7 +273,7 @@ class OpenIapModule(
273273
* Step 2 of alternative billing flow
274274
* Must be called BEFORE processing payment
275275
*/
276-
suspend fun showAlternativeBillingInformationDialog(activity: Activity): Boolean = withContext(Dispatchers.IO) {
276+
override suspend fun showAlternativeBillingInformationDialog(activity: Activity): Boolean = withContext(Dispatchers.IO) {
277277
val client = billingClient ?: throw OpenIapError.NotPrepared
278278
if (!client.isReady) throw OpenIapError.NotPrepared
279279

@@ -321,7 +321,7 @@ class OpenIapModule(
321321
* Must be called AFTER successful payment in your payment system
322322
* Token must be reported to Google Play backend within 24 hours
323323
*/
324-
suspend fun createAlternativeBillingReportingToken(): String? = withContext(Dispatchers.IO) {
324+
override suspend fun createAlternativeBillingReportingToken(): String? = withContext(Dispatchers.IO) {
325325
val client = billingClient ?: throw OpenIapError.NotPrepared
326326
if (!client.isReady) throw OpenIapError.NotPrepared
327327

@@ -1037,7 +1037,7 @@ class OpenIapModule(
10371037
*
10381038
* @param listener User choice billing listener
10391039
*/
1040-
fun setUserChoiceBillingListener(listener: dev.hyo.openiap.listener.UserChoiceBillingListener?) {
1040+
override fun setUserChoiceBillingListener(listener: dev.hyo.openiap.listener.UserChoiceBillingListener?) {
10411041
userChoiceBillingListener = listener
10421042
}
10431043
}

openiap/src/main/java/dev/hyo/openiap/OpenIapProtocol.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ interface OpenIapProtocol {
3535
fun removePurchaseUpdateListener(listener: OpenIapPurchaseUpdateListener)
3636
fun addPurchaseErrorListener(listener: OpenIapPurchaseErrorListener)
3737
fun removePurchaseErrorListener(listener: OpenIapPurchaseErrorListener)
38+
39+
// Alternative Billing (Google Play only)
40+
suspend fun checkAlternativeBillingAvailability(): Boolean
41+
suspend fun showAlternativeBillingInformationDialog(activity: Activity): Boolean
42+
suspend fun createAlternativeBillingReportingToken(): String?
43+
fun setUserChoiceBillingListener(listener: dev.hyo.openiap.listener.UserChoiceBillingListener?)
3844
}

openiap/src/play/java/dev/hyo/openiap/horizon/OpenIapHorizonModule.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,21 @@ class OpenIapHorizonModule(
102102
override fun removePurchaseErrorListener(listener: OpenIapPurchaseErrorListener) {
103103
delegate.removePurchaseErrorListener(listener)
104104
}
105+
106+
// Alternative Billing (delegate to OpenIapModule)
107+
override suspend fun checkAlternativeBillingAvailability(): Boolean {
108+
return delegate.checkAlternativeBillingAvailability()
109+
}
110+
111+
override suspend fun showAlternativeBillingInformationDialog(activity: Activity): Boolean {
112+
return delegate.showAlternativeBillingInformationDialog(activity)
113+
}
114+
115+
override suspend fun createAlternativeBillingReportingToken(): String? {
116+
return delegate.createAlternativeBillingReportingToken()
117+
}
118+
119+
override fun setUserChoiceBillingListener(listener: dev.hyo.openiap.listener.UserChoiceBillingListener?) {
120+
delegate.setUserChoiceBillingListener(listener)
121+
}
105122
}

0 commit comments

Comments
 (0)