バージョン 3 Billing 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 文字列が null であることです。これは、このサブスクリプションを既に購入している (テスト時に 100 万回) ためである可能性があります。最初に getPurchases() で確認する必要がありました。
ユーザーが 1) 現在の加入者である場合、または 2) キャンセル後、サービスの有効期限が切れる前に支払いを試みた場合、購入が「成功したように見える」ことは知られていますか?