0

RESTORE_TRANSACTIONSリクエストを使用してアプリ内商品の購入情報を復元する方法の例はありますか?このコードを思いついたのですが、常に0が返されるため、製品が購入されたかどうかがわかりません。すべてが正しく設定されています。

Bundle request = BillingHelper.makeRequestBundle("RESTORE_TRANSACTIONS");

request.putLong("NONCE", 32436756l);
try 
{
    Bundle response = BillingHelper.mService.sendBillingRequest(request);
    int response_code = response.getInt("RESPONSE_CODE", -1);
    if (response_code == 0)
    {
    // Product purchased
    }
} 
catch (RemoteException e) 
{
    e.printStackTrace();
}

私はグーグルとドキュメントで例を見つけられなかったので、どんなガイダンスも素晴らしいでしょう。

4

1 に答える 1

1

私はこの方法を使用しました:

public static void restoreTransactionInformation(Long nonce) 
    {
        if (amIDead()) 
        {
            return;
        }
        Log.i(TAG, "confirmTransaction()");
        Bundle request = makeRequestBundle("RESTORE_TRANSACTIONS");
        // The REQUEST_NONCE key contains a cryptographically secure nonce (number used once) that you must generate
        request.putLong("NONCE", nonce);
        try 
        {
            Bundle response = mService.sendBillingRequest(request);

            //The REQUEST_ID key provides you with a unique request identifier for the request
            Long requestIndentifier     = (Long) response.get("REQUEST_ID");
            Log.i(TAG, "current request is:" + requestIndentifier);

            //The RESPONSE_CODE key provides you with the status of the request
            Integer responseCodeIndex   = (Integer) response.get("RESPONSE_CODE");
            C.ResponseCode responseCode = C.ResponseCode.valueOf(responseCodeIndex);
            Log.i(TAG, "RESTORE_TRANSACTIONS Sync Response code: "+responseCode.toString());
        } 
        catch (RemoteException e) 
        {
            Log.e(TAG, "Failed, internet error maybe", e);
            Log.e(TAG, "Billing supported: " + isBillingSupported());
        }
    }

、呼び出しは次のとおりです。

BillingHelper.restoreTransactionInformation(BillingSecurity.generateNonce());
于 2012-08-09T10:06:14.167 に答える