【发布时间】:2023-03-18 21:36:01
【问题描述】:
我正在使用版本 3 计费 API 实施订阅计费。付款对话框关闭后(付款成功),控制权返回给我的活动
调用方法
String payload = UUID.randomUUID().toString();
bundle = mService.getBuyIntent(3, getPackageName(), mProduct, "subs", payload);
int responseCode = bundle.getInt("RESPONSE_CODE");
if (responseCode == 0) {
PendingIntent pendingIntent = bundle.getParcelable("BUY_INTENT");
startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
} else if (responseCode == 1) {
mErrorMessage.setText(getResources().getString(R.string.purchase_cancelled));
mErrorMessage.setVisibility(View.VISIBLE);
} else if (responseCode == 7) {
mErrorMessage.setText(getResources().getString(R.string.payment_twice));
mErrorMessage.setVisibility(View.VISIBLE);
} else {
mErrorMessage.setText(getResources().getString(R.string.payment_general_error));
mErrorMessage.setVisibility(View.VISIBLE);
}
我的活动
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
// Null
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"
}
}
问题是 purchaseData 字符串为空。这可能是因为我已经购买了这个订阅(测试时一百万次) - 我应该先检查 getPurchases()。
如果用户在 1) 当前订阅者或 2) 在取消后但服务到期之前的时间段内尝试付款,是否知道购买会“通过 - 显然成功”?
【问题讨论】:
-
发布你的调用方法
-
调用方法我也贴出来了
-
我在使用 android.test.purchased 时遇到了同样的问题 ....尝试使用沙盒实现真实产品和测试 .... 我认为使用 android.test.purchased 你总是会得到 null ..
-
我实际测试的是草稿模式下部署的APK,以及使用我注册的测试账号的真实产品。我认为这可能会发生,因为我已经购买了该项目,取消了它,并且处于该产品的有效期间,但将在下一个计费日期到期。我将尝试使用“新”测试帐户,看看我在第一次和实际购买时是否得到一个非空值。
-
关于沙盒;仅应用内商品支持测试购买,应用内订阅不支持。 (developer.android.com/google/play/billing/billing_testing.html)
标签: android in-app-purchase in-app-billing