Android
升降级
您可为用户提供不同的订阅层级,例如基本层级和高级层级。详情请参阅【升级、降级】
- Java
- Kotlin
UpgradeInfo upgradeInfo = new UpgradeInfo(oldSubsPurchase , prorationMode);
Market.getInstance().purchaseProduct(ProductDetailActivity.this, mProduct, upgradeInfo, new InitiatePurchaseListener() {
@Override
public void onVerifying(boolean isVerifying) {
// Callback of onging verification in the backend
}
@Override
public void onPurchaseSuccess(MTGPurchase purchase) {
//Purchase success callback
}
@Override
public void onOwnedGoods(MTGPurchase purchase) {
//Purchased status callback
}
@Override
public void onPurchaseError(int errorCode) {
//Callback of abnormal purchases
}
});
val info = UpgradeInfo(oldSubsPurchase, prorationMode)
Market.getInstance().purchaseProduct(activity, mProduct, info, object : InitiatePurchaseListener {
override fun onVerifying(isVerifying: Boolean) {
//Callback of ongoing backend verification
}
override fun onPurchaseSuccess(purchase: MTGPurchase) {
//Purchase success callback
}
override fun onOwnedGoods(purchase: MTGPurchase) {
//Purchased status callback
}
override fun onPurchaseError(errorCode: Int) {
//Callback of abnormal purchases
}
})
Parameters:
- oldSubsPurchase: purchase needs to be upgrades/downgrades
- prorationMode: Proration mode
- product: new Products to be purchase
退款
开发者可以主动调用接口来为用户退款并取消订阅,被取消的订阅用户将不再享受权益
- Java
- Kotlin
Market.getInstance().revoke(productId, new RevokeResponseListener() {
@Override
public void onSuccess(int resultCode) {
.....
}
@Override
public void onFail(String resultCode, String msg) {
.....
}
});
Market.getInstance().revoke(productId,object : RevokeResponseListener{
override fun onSuccess(resultCode: Int) {
TODO("Not yet implemented")
}
override fun onFail(resultCode: String?, msg: String?) {
TODO("Not yet implemented")
}
})
Parameters:
- productId: ID for product need to revoke