Closed Emranul-Islam closed 1 year ago
Hi @Emranul-Islam Please let me know if you found any way to get expiry date in this library.
@shashi-patel here's how i handle this and save it on shareprefarance you can save your way
bp!!.getSubscriptionsListingDetailsAsync(arrayListOf(productId),
object : BillingProcessor.ISkuDetailsResponseListener {
override fun onSkuDetailsResponse(products: MutableList<SkuDetails>?) {
products?.forEach { skuDetais ->
saveDate(skuDetails.subscriptionPeriod, purchaseInfo!!.purchaseData.purchaseTime)
}
}
override fun onSkuDetailsError(error: String?) {
Log.d(TAG, "onSkuDetailsError: $error")
subscriptionDone.value = true
}
})
private fun saveDate(subscriptionPeriod: String, purchaseTime: Date) {
val simpleDateFormat = SimpleDateFormat("dd MMM yyyy", Locale.ENGLISH)
mSharePrefarence.saveStartDate(simpleDateFormat.format(purchaseTime))
val calendar = Calendar.getInstance()
calendar.time = purchaseTime
when (subscriptionPeriod) {
"P1W" -> {
calendar.add(Calendar.WEEK_OF_MONTH, 1)
}
"P4W" -> {
calendar.add(Calendar.WEEK_OF_MONTH, 4)
}
"P1M" -> {
calendar.add(Calendar.MONTH, 1)
}
"P3M" -> {
calendar.add(Calendar.MONTH, 3)
}
"P6M" -> {
calendar.add(Calendar.MONTH, 3)
}
"P1Y" -> {
calendar.add(Calendar.YEAR, 1)
}
}
val time = calendar.timeInMillis
mSharePrefarence.saveExpireDate(simpleDateFormat.format(Date(time)))
}
Thanks for the update @Emranul-Islam
I want to know when my subscription time will expire is there any way in this library ??