回報我的問題如下︰
the icon for your application is not valid. please use a 48x48 png
後來爬了一下文章才知道是因為app_name我打xxxxx\nxxxx造成的。app_name裡面不要亂加\n!
/**
* Adds the given purchase information to the database and returns the total
* number of times that the given product has been purchased.
* @param orderId a string identifying the order
* @param productId the product ID (sku)
* @param purchaseState the purchase state of the product
* @param purchaseTime the time the product was purchased, in milliseconds
* since the epoch (Jan 1, 1970)
* @param developerPayload the developer provided "payload" associated with
* the order
* @return the number of times the given product has been purchased.
*/
public synchronized int updatePurchase(String orderId, String productId,
PurchaseState purchaseState, long purchaseTime, String developerPayload) {
insertOrder(orderId, productId, purchaseState, purchaseTime, developerPayload);
Cursor cursor = mDb.query(PURCHASE_HISTORY_TABLE_NAME, HISTORY_COLUMNS,
HISTORY_PRODUCT_ID_COL + "=?", new String[] { productId }, null, null, null, null);
if (cursor == null) {
return 0;
}
int quantity = 0;
try {
// Count the number of times the product was purchased
while (cursor.moveToNext()) {
int stateIndex = cursor.getInt(2);
PurchaseState state = PurchaseState.valueOf(stateIndex);
// Note that a refunded purchase is treated as a purchase. Such
// a friendly refund policy is nice for the user.
if (state == PurchaseState.PURCHASED || state == PurchaseState.REFUNDED) {
quantity += 1;
}
}
// Update the "purchased items" table
updatePurchasedItem(productId, quantity);
} finally {
if (cursor != null) {
cursor.close();
}
}
return quantity;
}
response_code extras in the com.android.vending.billing.RESPONSE_CODE
broadcast intent. Your application must handle all of these response codes.| Response Code回應代碼 | Value值 | Description描述 |
|---|---|---|
RESULT_OK |
0 | Indicates that the request was sent to the server successfully. When this code is returned in
response to a CHECK_BILLING_SUPPORTED request, indicates that billing is
supported.此回應指出這次的購買請求已經成功的發送至Android市集伺服器了。當這個代碼在我們發出CHECK_BILLING_SUPPORTED請求時被回傳,就表示了此裝置的Android市集有支援iap機制。 |
RESULT_USER_CANCELED |
1 | Indicates that the user pressed the back button on the checkout page instead of buying the
item. 此回應指出使用者在付費頁面下按了返回鍵而非購買商品。 |
RESULT_SERVICE_UNAVAILABLE |
2 | Indicates that the network connection is down. 此回應指出網路連線失效。 |
RESULT_BILLING_UNAVAILABLE |
3 | Indicates that in-app billing is not available because the API_VERSION that you
specified is not recognized by the Android Market application or the user is ineligible for in-app
billing (for example, the user resides in a country that prohibits in-app purchases).此回應指出iap機制不被支援,主因是您指定的API_VERSION無法被Android市集軟體識別,或者使用者是無資格使用iap機制(舉例,使用者住在禁止使用iap機制的國家) |
RESULT_ITEM_UNAVAILABLE |
4 | Indicates that Android Market cannot find the requested item in the application's product
list. This can happen if the product ID is misspelled in your REQUEST_PURCHASE
request or if an item is unpublished in the application's product list.此回應指出Android市集無法找到此請求的應用程式內產品列表的商品。這可能是因為您在發送REQUEST_PURCHAS請求時,產品ID拚錯了,或者是在應用程式產品列表上的商品尚未被發佈。 |
RESULT_DEVELOPER_ERROR |
5 | Indicates that an application is trying to make an in-app billing request but the application
has not declared the com.android.vending.BILLING permission in its manifest. Can also indicate
that an application is not properly signed, or that you sent a malformed request, such as a
request with missing Bundle keys or a request that uses an unrecognized request type. 此回應指出您的APP試圖發送iap請求,但是APP的AnddroidManifest.xml裡卻沒有宣告com.android.vending.BILLING權限。也可能是因為應用程式沒有正確的被簽署,或者您發送了一個非正確格式的請求,像是忘了傳Bundle的key值或者是使用了一個無法被識別的請求類型。 |
RESULT_ERROR |
6 | Indicates an unexpected server error. For example, this error is triggered if you try to
purchase an item from yourself, which is not allowed by Google Checkout. 此回應指出Android市集傳來了一個無法預期的伺服器錯誤。舉例來說,這個錯誤是出自您居然想要購買您自己在販售的商品,而這個商品卻沒有被Google Checkout允許販售。 |
IMarketBillingService.aidl file, which is included with the
in-app billing sample
application.sendBillingRequest(). This method
takes a single Bundle parameter. The Bundle parameter includes several key-value
pairs, which are summarized in table 2.sendBillingRequest() request.| Key | Type型態 | Possible Values 有效值 |
Required? 需要? |
Description描述 |
|---|---|---|---|---|
BILLING_REQUEST |
String |
CHECK_BILLING_SUPPORTED, REQUEST_PURCHASE,
GET_PURCHASE_INFORMATION, CONFIRM_NOTIFICATIONS, or
RESTORE_TRANSACTIONS |
Yes | The type of billing request you are making with the sendBillingRequest() request.
The possible values are discussed more below this table.這些是您在發送sendBillingRequest()請求時回應您的的金流請求類型值。這些有效值會在這個表格的下面被討論。 |
API_VERSION |
int |
1 | Yes | The version of Android Market's in-app billing service you are using. The current version is
1. 告知您正在使用的iap機制服務的Android市集版號。正確值為1 |
PACKAGE_NAME |
String |
A valid package name.有效的套件名稱 | Yes | The name of the application that is making the request. 請求購買商品的應用程式名稱。 |
ITEM_ID |
String |
Any valid product identifier.有效的產品識別碼 | Required for REQUEST_PURCHASE requests.當發出REQUEST_PURCHASE請求時會需要 |
The product ID of the item you are making a billing request for. Every in-app item that you
sell using Android Market's in-app billing service must have a unique product ID, which you
specify on the Android Market publisher site. 您正在請求購買的產品ID。每次您所販售Android市集iap服務的產品ID都必須是唯一。這些ID被您在Android市集發佈網站指定。 |
NONCE |
long |
Any valid long value.任何有效的long值 |
Required for GET_PURCHASE_INFORMATION and RESTORE_TRANSACTIONS
requests.當發出GET_PURCHASE_INFORMATION和RESTORE_TRANSACTIONS請求時會需要。 |
A number used once. Your application must generate and send a nonce with each
GET_PURCHASE_INFORMATION and RESTORE_TRANSACTIONS request. The nonce is
returned with the PURCHASE_STATE_CHANGED broadcast intent, so you can use this value
to verify the integrity of transaction responses form Android Market.僅用一次的數值。您的APP必須在每次發出GET_PURCHASE_INFORMATIONhdr RESTORE_TRANSACTIONS請求時,產生並發生出一個隨機數。這組隨機數會在Android市集發出PURCHASE_STATE_CHANGED這個廣播意圖時回傳給您。因此您可以用這個值來驗証從Android市集傳來的完整交易回應。 |
NOTIFY_IDS |
Array of long values |
Any valid array of long values有效的long型態陣列值 |
Required for GET_PURCHASE_INFORMATION and CONFIRM_NOTIFICATIONS
requests.當發出GET_PURCHASE_INFORMATION和CONFIRM_NOTIFICATIONS請求時會需要。 |
An array of notification identifiers. A notification ID is sent to your application in an
IN_APP_NOTIFY broadcast intent every time a purchase changes state. You use the
notification to retrieve the details of the purchase state change.這是一個訊息通知識別碼的陣列值。訊息通知ID在每次購買狀態遭改變時,Android市集發送IN_APP_NOTIFY廣播意圖時夾帶並傳送給您。 |
DEVELOPER_PAYLOAD開發者的酬載 (譯者註︰在資料安全領域裡,往往在資料的傳輸過程會加入一些特定值,來確認每一次的傳輸皆為安全的。payload就是一個為了資料安全而存在的值) |
String |
Any valid String less than 256 characters long.有效值在256個字元內 |
No | A developer-specified string that can be specified when you make a
REQUEST_PURCHASE request. This field is returned in the JSON string that contains
transaction information for an order. You can use this key to send supplemental information with
an order. For example, you can use this key to send index keys with an order, which is useful if
you are using a database to store purchase information. We recommend that you do not use this key
to send data or content.這是一個開發者自訂的字串值。每當您發出REQUEST_PURCHASE請求時可以拿這組字串值做特殊的標註。這個字串會在市集回傳包含訂單的交易資訊JSON字串時被夾帶並回傳回來。您可以使用這個key來發送訂單補充說明的資訊。舉例,您可以使用這個key來發送訂單的索引key,這在假設您正使用資料庫來儲存購買資訊時會很有用。我們建議您不要使用這個key值來發送資料或內容。 |
BILLING_REQUEST key can have the following values:CHECK_BILLING_SUPPORTED
This request verifies that the Android Market application supports in-app billing. You
usually send this request when your application first starts up. This request is useful if you
want to enable or disable certain UI features that are relevant only to in-app billing.REQUEST_PURCHASE
This request sends a purchase message to the Android Market application and is the foundation
of in-app billing. You send this request when a user indicates that he or she wants to purchase
an item in your application. Android Market then handles the financial transaction by displaying
the checkout user interface.GET_PURCHASE_INFORMATION
This request retrieves the details of a purchase state change. A purchase state change can
occur when a purchase request is billed successfully or when a user cancels a transaction during
checkout. It can also occur when a previous purchase is refunded. Android Market notifies your
application when a purchase changes state, so you only need to send this request when there is
transaction information to retrieve.CONFIRM_NOTIFICATIONS
This request acknowledges that your application received the details of a purchase state
change. That is, this message confirms that you sent a GET_PURCHASE_INFORMATION
request for a given notification and that you received the purchase information for the
notification.RESTORE_TRANSACTIONS
This request retrieves a user's transaction status for managed purchases (see Choosing a
Purchase Type for more information). You should send this message only when you need to
retrieve a user's transaction status, which is usually only when your application is reinstalled
or installed for the first time on a device.Bundle and can include one or more of the following keys:Bundle傳送,
裡面也包含了一至多組的key值,key值如下︰
RESPONSE_CODE
This key provides status information and error information about a request.PURCHASE_INTENT
This key provides a PendingIntent, which you use to launch the checkout
activity.REQUEST_ID
This key provides you with a request identifier, which you can use to match asynchronous
responses with requests.| Request Type請求類型 | Keys Returned傳回的key值 | Possible Response Codes可能傳回的回應碼 |
|---|---|---|
CHECK_BILLING_SUPPORTED檢查裝置是否支援iap |
RESPONSE_CODE |
RESULT_OK, RESULT_BILLING_UNAVAILABLE, RESULT_ERROR,
RESULT_DEVELOPER_ERROR |
REQUEST_PURCHASE請求購買 |
RESPONSE_CODE, PURCHASE_INTENT, REQUEST_ID |
RESULT_OK, RESULT_ERROR, RESULT_DEVELOPER_ERROR |
GET_PURCHASE_INFORMATION取得購買資訊 |
RESPONSE_CODE, REQUEST_ID |
RESULT_OK, RESULT_ERROR, RESULT_DEVELOPER_ERROR |
CONFIRM_NOTIFICATIONS確認傳來的通知訊息 |
RESPONSE_CODE, REQUEST_ID |
RESULT_OK, RESULT_ERROR, RESULT_DEVELOPER_ERROR |
RESTORE_TRANSACTIONS還原交易狀態至APP裡 |
RESPONSE_CODE, REQUEST_ID |
RESULT_OK, RESULT_ERROR, RESULT_DEVELOPER_ERROR |
BroadcastReceiver to
receive these broadcast intents, such as the BillingReceiver that's shown in the in-app
billing sample
application.BroadcastReceiver)去接收這些傳來的廣播意圖,像是iap範例程式裡的BillingReceiver就是這樣的一個元件。ACTION_RESPONSE_CODE.request_id—a long representing a request ID. A request ID
identifies a specific billing request and is returned by Android Market at the time a request is
made.response_code—an int representing the Android Market server
response code.IN_APP_NOTIFY broadcast intent,
you send a GET_PURCHASE_INFORMATION request with the notification IDs to retrieve the
message details. The sample application assigns this broadcast intent to a constant named
ACTION_NOTIFY.notification_id—a String representing the notification ID for
a given purchase state change. Android Market notifies you when there is a purchase state change
and the notification includes a unique notification ID. To get the details of the purchase state
change, you send the notification ID with the GET_PURCHASE_INFORMATION request.ACTION_PURCHASE_STATE_CHANGED.inapp_signed_data—a String representing the signed JSON
string.inapp_signature—a String representing the signature.Consts.java file in the
sample application to see how this is done.PURCHASE_STATE_CHANGED intent.| Field值 | Description描述 |
|---|---|
nonce
隨機數 |
A number used once. Your application generates the nonce and sends it with the
GET_PURCHASE_INFORMATION request. Android Market sends the nonce back as part of the
JSON string so you can verify the integrity of the message.僅用一次的一個數值。當要發送GET_PURCHASE_INFORMATION請求時,您的APP要產生一組隨機數一起發送。Android市集會再將這個隨機數塞進JSON字串當中,傳回給您。因此您可以用這個方法來驗証Android市集傳來的訊息的完整性。 |
notificationId
訊息通知id |
A unique identifier that is sent with an IN_APP_NOTIFY broadcast intent. Each
notificationId corresponds to a specify message that is waiting to be retrieved on
the Android Market server. Your application sends back the notificationId with the
GET_PURCHASE_INFORMATION message so Android Market can determine which messages you
are retrieving.這是從IN_APP_NOTIFY廣播意圖一起傳來的唯一性識別碼(unique identifier)。每次Android市集發出IN_APP_NOTIFY時,市集伺服器自己會留住這組識別碼,因此當您的APP之後透過GET_PURCHASE_INFORMATION訊息傳送這組識別碼回去時,Android市集就能清楚的知道您剛才接收的是哪一個訊息。 |
orderId
訂單id |
A unique order identifier for the transaction. This corresponds to the Google Checkout Order
ID. 這是這次交易的唯一性訂單識別碼(unique order identifier) ,這個識別碼會和Google Checkout的訂單編號ID相符。 |
packageName
套件名稱 |
The application package from which the purchase originated. APP套件的購買起源(譯者註︰不確定是否正確) |
productId
產品id |
The item's product identifier. Every item has a product ID, which you must specify in the
application's product list on the Android Market publisher site. 商品的產品識別碼。每個商品都有產品ID,您必須在Android市集發佈網站裡的應用程式產品列表裡指定這些產品ID。 |
purchaseTime
購買時間 |
The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970). 購買商品的時間。 從32位元的起源時間算起(1970/07/01)的毫秒時間。 (譯者註︰可以到此網站換算現在時間。) |
purchaseState
購買狀態 |
The purchase state of the order. Possible values are 0 (purchased), 1 (canceled), or 2
(refunded). 訂單的購買狀態。有效值為0(已購買)、1(購買中途取消)、2(退費)。 |
developerPayload
開發者的酬載 |
A developer-specified string that contains supplemental information about an order. You can
specify a value for this field when you make a REQUEST_PURCHASE request.開發者指定的一組字串,用來補充關於訂單的資訊。當您要發出REQUEST_PURCHASE請求時,可以指定這個值。 |
com.android.vending.BILLING
permission.com.android.vending.BILLING
permission. If an application's manifest does not include this permission, you will be able to edit
existing items in the product list but you will not be able to add new items to the list. For more
information about this permission, see
Updating Your
Application's Manifest.
published or unpublished.
managed_by_android, which is equivalent to Managed per user account
in the In-app Products UI, or managed_by_publisher, which is equivalent
to Unmanaged in the In-app Products UI.managed_by_android,不受管理的值是managed_by_publisher。
true or false.true, you must specify the default locale,
default title, default description, and other locales using the following format:false, you must specify the default locale,
default title, and default description as well as the translated titles and descriptions using
the following format:true or false. The syntax for specifying the country
and price varies depending on which autofill setting you use.true, you need to specify only the default
price in your home currency and you must use this syntax:false, you need to specify a country
and a price for each currency and you must use the following syntax:| Language | Code | Language | Code |
|---|---|---|---|
| Chinese | zh_TW | Italian | it_IT |
| Czech | cs_CZ | Japanese | ja_JP |
| Danish | da_DK | Korean | ko_KR |
| Dutch | nl_NL | Norwegian | no_NO |
| English | en_US | Polish | pl_PL |
| French | fr_FR | Portuguese | pt_PT |
| Finnish | fi_FI | Russian | ru_RU |
| German | de_DE | Spanish | es_ES |
| Hebrew | iw_IL | Swedish | sv_SE |
| Hindi | hi_IN | -- | -- |
RESTORE_TRANSACTIONS request and restore the state of the items a specific user has
purchased.| Support Type支援的型態 | Resource資源 | Range of Topics主題的範圍 |
|---|---|---|
| Development and testing issues開發與測試問題 | Google Groups: android-developers | In-app billing integration questions, user experience ideas, handling of responses,
obfuscating code, IPC, test environment setup. iap機制的整合問題、使用者經驗發想、 處理回應、模糊程式碼、內部進程溝通、測試環境的設定。 |
| Stack Overflow: http://stackoverflow.com/questions/tagged/ android | ||
| Market billing issue tracker市集金流問題追蹤 | Market billing project issue tracker | Bug and issue reports related specifically to in-app billing sample code. 關於iap機制範例程式的BUG與問題回報 |
| Application ever been published? APP是否曾經發佈過? |
Draft application uploaded and unpublished? 草稿APP上傳了且無須發佈? |
User who is running the application 執行APP的人是誰 |
Static response signature 靜態回應簽章 |
|---|---|---|---|
| No | No | Any任何人 | Unsigned未簽署 |
| No | No | Developer開發者 | Signed已簽署 |
| Yes | No | Any任何人 | Unsigned未簽署 |
| Yes | No | Developer開發者 | Signed已簽署 |
| Yes | No | Test account測試帳戶 | Signed已簽署 |
| Yes | Yes | Any任何人 | Signed已簽署 |
REQUEST_PURCHASE request, but instead of using a real product ID from your
application's product list you use one of the reserved product IDs.