简体   繁体   English

在Android上跟踪购买时,我在哪里可以获得商品价格,总税金和运费?

[英]Where do I get the item price, total tax, and shipping cost when tracking purchases on Android?

According to the Google Analytics eCommerce guide for Android , I need to use the Tracker.sendTransaction method to track purchases. 根据适用于AndroidGoogle Analytics电子商务指南 ,我需要使用Tracker.sendTransaction方法来跟踪购买情况。 Three pieces of information needed are the purchase price, the total tax, and the shipping price (all longs). 所需的三条信息是购买价格,总税金和运费(所有多头)。 However, the response provided from making in-app purchases provides none of this data. 但是,通过进行应用内购买提供的响应不会提供这些数据。

Am I missing something? 我错过了什么吗? Are these pieces of information actually returned? 这些信息实际上是否已归还? Where can I find them to set them? 我在哪里可以找到他们设置它们?

You can get information about all your products using the getSkuDetails -method: 您可以使用getSkuDetails -method获取有关所有产品的信息:

ArrayList<String> skuList = new ArrayList<String> ();
skuList.add("premiumUpgrade");
skuList.add("gas");
Bundle querySkus = new Bundle();
querySkus.putStringArrayList(“ITEM_ID_LIST”, skuList);

Bundle skuDetails = mService.getSkuDetails(3, getPackageName(), "inapp", querySkus);

code taken from: http://developer.android.com/google/play/billing/billing_integrate.html#QueryDetails 代码取自: http//developer.android.com/google/play/billing/billing_integrate.html#QueryDetails

You know which product the user bought by inspecting the data returned after a purchase: 通过检查购买后返回的数据,您知道用户购买了哪种产品:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
   if (requestCode == 1001) {           
      int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
      String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
      String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");

      if (resultCode == RESULT_OK) {
         try {
            JSONObject jo = new JSONObject(purchaseData);
            String sku = jo.getString("productId");
            // TODO: query getSkuDetails() and find the matching product
            alert("You have bought the " + sku + ". Excellent choice, 
               adventurer!");
          }
          catch (JSONException e) {
             alert("Failed to parse purchase data.");
             e.printStackTrace();
          }
      }
   }
}

code taken from: http://developer.android.com/google/play/billing/billing_integrate.html#Purchase 代码取自: http//developer.android.com/google/play/billing/billing_integrate.html#Purchase

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM