2

Androidのアプリ内課金で購入が行われたか確認したい。この方法を見つけた...

protected static void verifyPurchase(String signedData, String signature) {
    ArrayList<VerifiedPurchase> purchases = BillingSecurity.verifyPurchase(signedData, signature);
    Log.e("IN APP","purchases: " + purchases.toString());
}

それでも、signedData と署名に入れる必要があるかどうかわかりませんか? itemid と base64EncodedPublicKey を試しましたが、うまくいきません...

ありがとう!

4

1 に答える 1

1

購入結果を確認するには、クラスBillingPurchaseObserverの別のメソッドを使用する必要があります。

@Override
public void onRequestPurchaseResponse(RequestPurchase request,
        ResponseCode responseCode)
{
    Log.d("TAG", "onRequestPurchaseResponse");
    if (Consts.DEBUG)
    {
        Log.d("TAG", request.mProductId + ": " + responseCode);
    }
    if (responseCode == ResponseCode.RESULT_OK)
    {
        if (Consts.DEBUG)
        {
            Log.i("TAG", "purchase was successfully sent to server");
        }
    }
    else if (responseCode == ResponseCode.RESULT_USER_CANCELED)
    {
        if (Consts.DEBUG)
        {
            Log.i("TAG", "user canceled purchase");
        }
    }
    else
    {
        if (Consts.DEBUG)
        {
            Log.i("TAG", "purchase failed");
        }
    }
}

BillingService の purchaseStateChanged メソッドは変更しないでください。

/**
     * Verifies that the data was signed with the given signature, and calls
     * {@link ResponseHandler#purchaseResponse(Context, PurchaseState, String, String, long)}
     * for each verified purchase.
     * 
     * @param startId
     *           an identifier for the invocation instance of this service
     * @param signedData
     *           the signed JSON string (signed, not encrypted)
     * @param signature
     *           the signature for the data, signed with the private key
     */
    private void purchaseStateChanged(int startId, String signedData,
            String signature)
    {
            //...
    }
于 2012-11-24T20:24:08.477 に答える