2015-07-28 97 views

回答

-3

是的。首先阅读本official document

你正在寻找被称为

productId 

检查下面的代码的变量。如果付款成功,则显示该产品(您定义的)。

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 


    if (requestCode == 1001) { 

     String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); 
     String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); 


     if (resultCode == RESULT_OK) { 

      entryFee.setVisibility(View.GONE); 
      paymentButton.setVisibility(View.GONE); 
      paymentText.setVisibility(View.GONE); 
      teamTextField.setVisibility(View.VISIBLE); 
      btn.setVisibility(View.VISIBLE); 
      aSwitch.setVisibility(View.VISIBLE); 

      try { 


       JSONObject jo = new JSONObject(purchaseData); 
       String sku = jo.getString("productId"); 

       Toast.makeText(
         CreateLeague.this, 
         "You have bought the " + sku 
           + ". Excellent choice,adventurer!", 
         Toast.LENGTH_LONG).show(); 


      } catch (JSONException e) { 
       Toast.makeText(
         CreateLeague.this, 
         "Failed to make purchase", 
         Toast.LENGTH_LONG).show(); 

       e.printStackTrace(); 
      } 
     } 
    } 
} 

希望这会有所帮助。

+0

不回答OP的问题。 – antfx