我在使用Google Play API时遇到了一些麻烦。我购买了in app
(应用程序是free
或premium
)。几分钟后,当我单击Refund
按钮在Google Play控制台上下订单时,我会看到一条消息,指示退款已完成。
我的问题是,在我的应用程序中,我仍然从Google API收到该应用程序为premium
。我了解了有关缓存的信息,因此我将我的应用安装到了退款后的全新设备上,但仍为premium
。
那么Console中的Refund
是什么意思?这仅仅是给用户带来回报并保留应用premium
的礼物吗?
更新16/04/2019 :这是我的代码
class PurchaseManagerImpl(private val context: Context) : PurchaseManager {
private lateinit var mBillingClient: BillingClient
private lateinit var listener: BillingUpdatesListener
override fun setupBilling(l: BillingUpdatesListener) {
listener = l
mBillingClient = BillingClient.newBuilder(context).setListener { responseCode, purchases ->
// also called when new purchases are made
if (responseCode == BillingClient.BillingResponse.OK && purchases != null) {
for (purchase in purchases) {
listener.onBillingSuccess()
}
} else if (responseCode == BillingClient.BillingResponse.USER_CANCELED) {
// Handle an error caused by a user cancelling the purchase flow.
listener.onBillingError( context.getString(R.string.error_user_cancelled))
} else {
listener.onBillingError( this.context.getString(R.string.error_undefined))
}
}.build()
startConnection()
}
override fun startConnection() {
mBillingClient.startConnection(object : BillingClientStateListener {
override fun onBillingSetupFinished(responseCode: Int) {
if (responseCode == BillingClient.BillingResponse.OK) {
// The billing client is ready. You can query purchases here.
queryPurchases()
querySkuDetails()
}
}
})
}
private fun querySkuDetails() {
// for in-app purchase
val skuList = arrayListOf("premium")
val params = SkuDetailsParams.newBuilder()
params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP)
mBillingClient.querySkuDetailsAsync(params.build()) { responseCode, skuDetailsList ->
if (responseCode == BillingClient.BillingResponse.OK && skuDetailsList != null) {
for (skuDetails in skuDetailsList) {
val sku = skuDetails.sku
val price = skuDetails.price
}
}
}
}
private fun queryPurchases() {
mBillingClient.queryPurchases(BillingClient.SkuType.INAPP)?.let { purchasesResult ->
if (purchasesResult.responseCode == BillingClient.BillingResponse.OK) {
if (purchasesResult.purchasesList.size != 0) {
listener.onBillingSuccess()
}
}
}
}
override fun launchBuy(activity: Activity) {
val flowParams = BillingFlowParams.newBuilder()
.setSku("premium")
.setType(BillingClient.SkuType.INAPP)
.build()
if (::mBillingClient.isInitialized) {
mBillingClient.launchBillingFlow(activity, flowParams)
}
}
}