Google 应用内结算,从服务器检索信息时出错 [DF-DFERH-01]

Google in-app billing,Error retrieving information from server [DF-DFERH-01]

我正在测试 google 的应用内结算。我按照 google 应用内计费培训的说明,使用 IabHelper。

我成功设置了 IabHelper。

mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(IabResult result) {
            Log.d("GooglePay", "Setup finished.");

            if (!result.isSuccess()) {
                // Oh no, there was a problem.
                Log.d("GooglePay", "Problem setting up in-app billing: " + result);
                return;
            }

            // Have we been disposed of in the meantime? If so, quit.
            if (mHelper == null) return;

            mBroadcastReceiver = new IabBroadcastReceiver(GooglePayPlugin.this);
            IntentFilter broadcastFilter = new IntentFilter(IabBroadcastReceiver.ACTION);
            mActivity.registerReceiver(mBroadcastReceiver, broadcastFilter);
        }
    });

然后,我调用IabHelper的购买API。

try {
     mHelper.launchPurchaseFlow(mActivity, productID, RC_REQUEST,
                mPurchaseFinishedListener, payload);
} catch (IabAsyncInProgressException e) {
     Log.d("GooglePay", "Error launching purchase flow. Another async operation in progress.");
}

但是,我总是弹出windows说:“从服务器检测信息时出错。[DF-DFERH-01]”,如下图。

logcat信息已在认证中。

请按照以下步骤检查您的代码:

步骤:1 使用 sdk tool 检查 sdk manager 更新为 Google Play Billing LibraryGoogle play services

步骤:2 创建一个 Android 项目并将计费权限添加到您的 Android 项目的清单文件中。

<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.INTERNET" />

步骤:3 将 AIDL 文件添加到您的项目

1.By right click on you app-level folder>> Folder>> AIDL folder

2.Example for in app billing create directory or folder or package –> com.android.vending.billing

3.Then copy paste file in this package

After doing all this you will get error in other InApp billing supportive classes like IabHelper for importing that InAppBillingService.aidl, to resolve it go to build.gradle and readjust your directory for com.android.vending.billing which is not correct format at the time of com.android.vending.billing directory or package creation

like:

sourceSets { main { aidl.srcDirs = [‘src/main/aidl‘] } }

步骤:3 更新 build.gradle 文件

中的依赖项

步骤:4 与 Google Play

建立连接

(确保 base64EncodedPublicKey 适合您的产品)

(Base64EncodedPublicKey 表示 your license key from google play console)

 /************Setting Up Google Play Billing in the Application***************/
    mHelper = new IabHelper(this, base64EncodedPublicKey);

    // enable debug logging (for a production application, you should set this to false).
    // mHelper.enableDebugLogging(true);
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(@NonNull IabResult result) {
            if (!result.isSuccess()) {
                Log.d(TAG, "In-app Billing setup failed: " + result);
                complain("In-app Billing setup failed:: " + result);

            } else {
                Log.d(TAG, "In-app Billing is set up OK");
            }
        }
    });
    /************Setting Up Google Play Billing in the Application***************/

步骤:5

出于测试目的,请使用以下 item_sku:

static final String ITEM_SKU = "android.test.purchased";
static final int RC_REQUEST = 10001;

如果是 live 使用 live ProductID 你在创建什么。

步骤:6

  1. 实现onActivityResult处理结果的方法

    @Override
    protected void onActivityResult(int requestCode, int resultCode,Intent data)
    {
    if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
        super.onActivityResult(requestCode, resultCode, data);
    }
    } 
    
  2. 实施OnIabPurchaseFinishedListener

  3. 实施QueryInventoryFinishedListener

  4. 实施OnConsumeFinishedListener

步骤:7

确保您的设备已更新 Google play services

步骤:8

调用 IabHelper 的购买 API。

 mHelper.launchPurchaseFlow(mActivity, ITEM_SKU,
              RC_REQUEST,mPurchaseFinishedListener, mPayload);

步骤:9 更多内容请参考以下link:

https://developer.android.com/google/play/billing/billing_integrate.html#billing-permission

https://developer.android.com/google/play/billing/billing_library.html#connecting

希望对您有所帮助。

我最终解决了这个问题,把我的答案放在这里,希望对遇到和我一样问题的人有所帮助。

mHelper.launchPurchaseFlow(mActivity, productID, RC_REQUEST, mPurchaseFinishedListener, 负载);

"payLoad"参数太长,我把payload设置为空字符串,问题解决,没有df-dferh-01了。

与VPN无关,与google库无关,只是因为google播放服务接口的负载太长。

在我的例子中,问题是设置错误 SubscriptionUpdateParams。如果您使用订阅,您可能有一个设置 OldSkuPurchaseToken 的代码。如果您在那里设置了错误的数据,则会出现此错误。