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

Commit 60403e2

Browse files
committed
fix(types): add transactionId to purchase
1 parent bef7d3a commit 60403e2

File tree

2 files changed

+16
-31
lines changed

2 files changed

+16
-31
lines changed

Example/src/main/java/dev/hyo/martie/screens/uis/Modals.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import dev.hyo.openiap.ProductAndroid
2222
import dev.hyo.openiap.ProductType
2323
import dev.hyo.openiap.PurchaseAndroid
2424
import dev.hyo.openiap.PurchaseState
25-
import java.text.SimpleDateFormat
26-
import java.util.Date
2725
import java.util.Locale
2826

2927
@Composable
@@ -207,7 +205,6 @@ fun PurchaseDetailModal(
207205
onDismiss: () -> Unit
208206
) {
209207
val clipboard = LocalClipboardManager.current
210-
val dateFormat = remember { SimpleDateFormat("MMM dd, yyyy HH:mm", Locale.getDefault()) }
211208

212209
Dialog(
213210
onDismissRequest = onDismiss,
@@ -286,18 +283,21 @@ fun PurchaseDetailModal(
286283
}
287284

288285
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
289-
DetailRow("Purchase Token", purchase.purchaseToken ?: "-")
290-
DetailRow("Order ID", purchase.id)
291-
DetailRow(
292-
"Transaction Date",
293-
dateFormat.format(Date(purchase.transactionDate.toLong()))
294-
)
295-
DetailRow("Auto Renewing", purchase.isAutoRenewing.toString())
296-
purchase.autoRenewingAndroid?.let { DetailRow("Auto Renewing (Android)", it.toString()) }
297-
purchase.isAcknowledgedAndroid?.let { DetailRow("Acknowledged", it.toString()) }
298-
purchase.obfuscatedAccountIdAndroid?.let { DetailRow("Account ID", it) }
299-
purchase.obfuscatedProfileIdAndroid?.let { DetailRow("Profile ID", it) }
300-
purchase.signatureAndroid?.let { DetailRow("Signature", it) }
286+
val detailRows = buildList {
287+
add("id" to purchase.id)
288+
add("transactionId" to (purchase.transactionId ?: "-"))
289+
add("purchaseToken" to (purchase.purchaseToken ?: "-"))
290+
add("purchaseState" to purchase.purchaseState.rawValue)
291+
add("productId" to purchase.productId)
292+
add("transactionDate" to purchase.transactionDate.toString())
293+
add("isAutoRenewing" to purchase.isAutoRenewing.toString())
294+
purchase.autoRenewingAndroid?.let { add("autoRenewingAndroid" to it.toString()) }
295+
purchase.isAcknowledgedAndroid?.let { add("isAcknowledgedAndroid" to it.toString()) }
296+
purchase.obfuscatedAccountIdAndroid?.let { add("obfuscatedAccountIdAndroid" to it) }
297+
purchase.obfuscatedProfileIdAndroid?.let { add("obfuscatedProfileIdAndroid" to it) }
298+
purchase.signatureAndroid?.let { add("signatureAndroid" to it) }
299+
}
300+
detailRows.forEach { (label, value) -> DetailRow(label, value) }
301301
}
302302

303303
HorizontalDivider()

openiap/src/main/java/dev/hyo/openiap/utils/BillingConverters.kt

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ import com.android.billingclient.api.ProductDetails
1717
import com.android.billingclient.api.Purchase as BillingPurchase
1818

1919
internal object BillingConverters {
20-
fun ProductDetails.toProduct(productType: String): Product {
21-
return if (productType == BillingClient.ProductType.SUBS) {
22-
toSubscriptionProduct().toProduct()
23-
} else {
24-
toInAppProduct()
25-
}
26-
}
27-
2820
fun ProductDetails.toInAppProduct(): ProductAndroid {
2921
val offer = oneTimePurchaseOfferDetails
3022
val displayPrice = offer?.formattedPrice.orEmpty()
@@ -122,18 +114,11 @@ internal object BillingConverters {
122114
purchaseToken = purchaseToken,
123115
quantity = quantity,
124116
signatureAndroid = signature,
117+
transactionId = orderId,
125118
transactionDate = purchaseTime.toDouble()
126119
)
127120
}
128121

129-
fun BillingPurchase.toActiveSubscription(): ActiveSubscription = ActiveSubscription(
130-
autoRenewingAndroid = isAutoRenewing,
131-
isActive = true,
132-
productId = products.firstOrNull().orEmpty(),
133-
purchaseToken = purchaseToken,
134-
transactionDate = purchaseTime.toDouble(),
135-
transactionId = orderId ?: purchaseToken
136-
)
137122
}
138123

139124
fun PurchaseState.Companion.fromBillingState(state: Int): PurchaseState = when (state) {

0 commit comments

Comments
 (0)