Skip to content

Commit cf4bf38

Browse files
committed
chore: rebase main
1 parent 081e6e1 commit cf4bf38

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
@@ -236,7 +236,7 @@ class OpenIapModule(
236236
* Check if alternative billing is available for this user/device
237237
* Step 1 of alternative billing flow
238238
*/
239-
suspend fun checkAlternativeBillingAvailability(): Boolean = withContext(Dispatchers.IO) {
239+
override suspend fun checkAlternativeBillingAvailability(): Boolean = withContext(Dispatchers.IO) {
240240
val client = billingClient ?: throw OpenIapError.NotPrepared
241241
if (!client.isReady) throw OpenIapError.NotPrepared
242242

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

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

@@ -1055,7 +1055,7 @@ class OpenIapModule(
10551055
*
10561056
* @param listener User choice billing listener
10571057
*/
1058-
fun setUserChoiceBillingListener(listener: dev.hyo.openiap.listener.UserChoiceBillingListener?) {
1058+
override fun setUserChoiceBillingListener(listener: dev.hyo.openiap.listener.UserChoiceBillingListener?) {
10591059
userChoiceBillingListener = listener
10601060
}
10611061
}

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)