Difference between revisions of "GoogleBilling"
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | '''Supported platforms:''' android<br/> | + | <languages /> |
− | '''Available since:''' Gideros 2012.09<br/> | + | <!-- GIDEROSOBJ:GoogleBilling --> |
− | === Description === | + | '''<translate>Supported platforms</translate>:''' [[File:Platform android.png]]<br/> |
+ | '''<translate>Available since</translate>:''' Gideros 2012.09<br/> | ||
+ | === <translate>Description</translate> === | ||
<translate><br /> | <translate><br /> | ||
− | The [[GoogleBilling]] class is defined in the module "googlebilling". Therefore, you need to call<br /> | + | The [[Special:MyLanguage/GoogleBilling|GoogleBilling]] class is defined in the module "googlebilling". Therefore, you need to call<br /> |
− | + | ''require("googlebilling")'' before using it. Loading the Google Billing module <br /> | |
− | also creates a global variable | + | also creates a global variable ''googlebilling'' of type [[Special:MyLanguage/GoogleBilling|GoogleBilling]] for direct use. <br /> |
<br /> | <br /> | ||
<h3>GoogleBilling Events and Response Codes</h3><br /> | <h3>GoogleBilling Events and Response Codes</h3><br /> | ||
<br /> | <br /> | ||
− | [[GoogleBilling | + | [[Special:MyLanguage/GoogleBilling|GoogleBilling]] class dispatches 5 events: [[Special:MyLanguage/Event.CHECK_BILLING_SUPPORTED_COMPLETE|Event.CHECK_BILLING_SUPPORTED_COMPLETE]],<br /> |
− | [[Event.REQUEST_PURCHASE_COMPLETE | + | [[Special:MyLanguage/Event.REQUEST_PURCHASE_COMPLETE|Event.REQUEST_PURCHASE_COMPLETE]],[[Special:MyLanguage/Event.RESTORE_TRANSACTIONS_COMPLETE|Event.RESTORE_TRANSACTIONS_COMPLETE]],<br /> |
− | [[Event.CONFIRM_NOTIFICATION_COMPLETE | + | [[Special:MyLanguage/Event.CONFIRM_NOTIFICATION_COMPLETE|Event.CONFIRM_NOTIFICATION_COMPLETE]] and [[Special:MyLanguage/Event.PURCHASE_STATE_CHANGE|Event.PURCHASE_STATE_CHANGE]].<br /> |
<br /> | <br /> | ||
− | + | ''Event.*_COMPLETE'' events contains a field ''event.responseCode'' which provides status information <br /> | |
and error information about a request. Response code can be one of these values:<br /> | and error information about a request. Response code can be one of these values:<br /> | ||
<br /> | <br /> | ||
<ul><br /> | <ul><br /> | ||
− | <li>[[GoogleBilling.OK]]: Indicates that the request was sent to the server successfully. When this code is returned</li><br /> | + | <li>[[Special:MyLanguage/GoogleBilling.OK|GoogleBilling.OK]]: Indicates that the request was sent to the server successfully. When this code is returned</li><br /> |
</ul><br /> | </ul><br /> | ||
− | in response to a | + | in response to a ''checkBillingSupported'' function, indicates that billing is supported.<br /> |
<ul><br /> | <ul><br /> | ||
− | <li>[[GoogleBilling.USER_CANCELED]]: Indicates that the user pressed the back button on the checkout page instead of buying the item.</li><br /> | + | <li>[[Special:MyLanguage/GoogleBilling.USER_CANCELED|GoogleBilling.USER_CANCELED]]: Indicates that the user pressed the back button on the checkout page instead of buying the item.</li><br /> |
− | <li>[[GoogleBilling.SERVICE_UNAVAILABLE]]: Indicates that the network connection is down.</li><br /> | + | <li>[[Special:MyLanguage/GoogleBilling.SERVICE_UNAVAILABLE|GoogleBilling.SERVICE_UNAVAILABLE]]: Indicates that the network connection is down.</li><br /> |
− | <li>[[GoogleBilling.BILLING_UNAVAILABLE]]: Indicates that in-app billing is not available because the API version that</li><br /> | + | <li>[[Special:MyLanguage/GoogleBilling.BILLING_UNAVAILABLE|GoogleBilling.BILLING_UNAVAILABLE]]: Indicates that in-app billing is not available because the API version that</li><br /> |
</ul><br /> | </ul><br /> | ||
you specified is not recognized by the Google Play application or the user is ineligible for in-app billing <br /> | you specified is not recognized by the Google Play application or the user is ineligible for in-app billing <br /> | ||
(for example, the user resides in a country that prohibits in-app purchases).<br /> | (for example, the user resides in a country that prohibits in-app purchases).<br /> | ||
<ul><br /> | <ul><br /> | ||
− | <li>[[GoogleBilling.ITEM_UNAVAILABLE]]: Indicates that Google Play cannot find the requested item in the application's product list.</li><br /> | + | <li>[[Special:MyLanguage/GoogleBilling.ITEM_UNAVAILABLE|GoogleBilling.ITEM_UNAVAILABLE]]: Indicates that Google Play cannot find the requested item in the application's product list.</li><br /> |
</ul><br /> | </ul><br /> | ||
− | This can happen if the product ID is misspelled in your | + | This can happen if the product ID is misspelled in your ''requestPurchase'' function or if an item is unpublished in the application's product list.<br /> |
<ul><br /> | <ul><br /> | ||
− | <li>[[GoogleBilling.DEVELOPER_ERROR]]: Indicates that an application is trying to make an in-app billing request but the application has not declared the</li><br /> | + | <li>[[Special:MyLanguage/GoogleBilling.DEVELOPER_ERROR|GoogleBilling.DEVELOPER_ERROR]]: Indicates that an application is trying to make an in-app billing request but the application has not declared the</li><br /> |
</ul><br /> | </ul><br /> | ||
com.android.vending.BILLING permission in its manifest. Can also indicate that an application is not properly signed, <br /> | com.android.vending.BILLING permission in its manifest. Can also indicate that an application is not properly signed, <br /> | ||
or that you sent a malformed request, such as a request with missing Bundle keys or a request that uses an unrecognized request type.<br /> | or that you sent a malformed request, such as a request with missing Bundle keys or a request that uses an unrecognized request type.<br /> | ||
<ul><br /> | <ul><br /> | ||
− | <li>[[GoogleBilling.ERROR]]: 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 Wallet.</li><br /> | + | <li>[[Special:MyLanguage/GoogleBilling.ERROR|GoogleBilling.ERROR]]: 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 Wallet.</li><br /> |
</ul><br /> | </ul><br /> | ||
<br /> | <br /> | ||
<h3># Event.CHECK_BILLING_SUPPORTED_COMPLETE</h3><br /> | <h3># Event.CHECK_BILLING_SUPPORTED_COMPLETE</h3><br /> | ||
− | Dispatched when | + | Dispatched when ''checkBillingSuported'' function completes. It contains ''event.responseCode'' and ''event.productType'' fields.<br /> |
<br /> | <br /> | ||
<h3># Event.REQUEST_PURCHASE_COMPLETE</h3><br /> | <h3># Event.REQUEST_PURCHASE_COMPLETE</h3><br /> | ||
− | Dispatched when | + | Dispatched when ''requestPurchase'' function completes. It contains ''event.responseCode'', ''event.productId'', ''event.productType'' and ''event.developerPayload'' fields.<br /> |
<br /> | <br /> | ||
<h3># Event.RESTORE_TRANSACTIONS_COMPLETE</h3><br /> | <h3># Event.RESTORE_TRANSACTIONS_COMPLETE</h3><br /> | ||
− | Dispatched when | + | Dispatched when ''restoreTransactions'' function completes. It contains ''event.responseCode'' fields.<br /> |
<br /> | <br /> | ||
<h3># Event.CONFIRM_NOTIFICATION_COMPLETE</h3><br /> | <h3># Event.CONFIRM_NOTIFICATION_COMPLETE</h3><br /> | ||
− | Dispatched when | + | Dispatched when ''confirmNotification'' function completes. It contains ''event.responseCode'' and ''event.notificationId'' fields.<br /> |
<br /> | <br /> | ||
<h3># Event.PURCHASE_STATE_CHANGE</h3><br /> | <h3># Event.PURCHASE_STATE_CHANGE</h3><br /> | ||
− | Dispatched when information about a transaction is received. It contains | + | Dispatched when information about a transaction is received. It contains ''event.purchaseState'', ''event.productId'', ''event.notificationId'', ''event.purchaseTime'' and ''event.developerPayload'' fields.<br /> |
<br /></translate> | <br /></translate> | ||
{|- | {|- | ||
− | | style="width: 50%;"| | + | | style="width: 50%; vertical-align:top;"| |
− | === Methods === | + | === <translate>Methods</translate> === |
− | [[GoogleBilling:checkBillingSupported]] | + | [[Special:MyLanguage/GoogleBilling:checkBillingSupported|GoogleBilling:checkBillingSupported]] <br/><!-- GIDEROSMTD:GoogleBilling:checkBillingSupported(productType) --> |
− | [[GoogleBilling:confirmNotification]] | + | [[Special:MyLanguage/GoogleBilling:confirmNotification|GoogleBilling:confirmNotification]] <br/><!-- GIDEROSMTD:GoogleBilling:confirmNotification(notificationId) --> |
− | [[GoogleBilling:requestPurchase]] | + | [[Special:MyLanguage/GoogleBilling:requestPurchase|GoogleBilling:requestPurchase]] <br/><!-- GIDEROSMTD:GoogleBilling:requestPurchase(productId,productType,developerPayload) --> |
− | [[GoogleBilling:restoreTransactions]] | + | [[Special:MyLanguage/GoogleBilling:restoreTransactions|GoogleBilling:restoreTransactions]] <br/><!-- GIDEROSMTD:GoogleBilling:restoreTransactions() --> |
− | [[GoogleBilling:setApiVersion]] | + | [[Special:MyLanguage/GoogleBilling:setApiVersion|GoogleBilling:setApiVersion]] <br/><!-- GIDEROSMTD:GoogleBilling:setApiVersion(apiVersion) --> |
− | [[GoogleBilling:setPublicKey]] | + | [[Special:MyLanguage/GoogleBilling:setPublicKey|GoogleBilling:setPublicKey]] <br/><!-- GIDEROSMTD:GoogleBilling:setPublicKey(publicKey) --> |
− | | style="width: 50%;"| | + | | style="width: 50%; vertical-align:top;"| |
− | === Events === | + | === <translate>Events</translate> === |
− | [[Event.CHECK_BILLING_SUPPORTED_COMPLETE]]<br/> | + | [[Special:MyLanguage/Event.CHECK_BILLING_SUPPORTED_COMPLETE|Event.CHECK_BILLING_SUPPORTED_COMPLETE]]<br/><!-- GIDEROSEVT:Event.CHECK_BILLING_SUPPORTED_COMPLETE checkBillingSupportedComplete--> |
− | [[Event.CONFIRM_NOTIFICATION_COMPLETE]]<br/> | + | [[Special:MyLanguage/Event.CONFIRM_NOTIFICATION_COMPLETE|Event.CONFIRM_NOTIFICATION_COMPLETE]]<br/><!-- GIDEROSEVT:Event.CONFIRM_NOTIFICATION_COMPLETE confirmNotificationComplete--> |
− | [[Event.PURCHASE_STATE_CHANGE]]<br/> | + | [[Special:MyLanguage/Event.PURCHASE_STATE_CHANGE|Event.PURCHASE_STATE_CHANGE]]<br/><!-- GIDEROSEVT:Event.PURCHASE_STATE_CHANGE purchaseStateChange--> |
− | [[Event.REQUEST_PURCHASE_COMPLETE]]<br/> | + | [[Special:MyLanguage/Event.REQUEST_PURCHASE_COMPLETE|Event.REQUEST_PURCHASE_COMPLETE]]<br/><!-- GIDEROSEVT:Event.REQUEST_PURCHASE_COMPLETE requestPurchaseComplete--> |
− | [[Event.RESTORE_TRANSACTIONS_COMPLETE]]<br/> | + | [[Special:MyLanguage/Event.RESTORE_TRANSACTIONS_COMPLETE|Event.RESTORE_TRANSACTIONS_COMPLETE]]<br/><!-- GIDEROSEVT:Event.RESTORE_TRANSACTIONS_COMPLETE restoreTransactionsComplete--> |
− | === Constants === | + | === <translate>Constants</translate> === |
− | [[GoogleBilling.BILLING_UNAVAILABLE]]<br/> | + | [[Special:MyLanguage/GoogleBilling.BILLING_UNAVAILABLE|GoogleBilling.BILLING_UNAVAILABLE]]<br/><!-- GIDEROSCST:GoogleBilling.BILLING_UNAVAILABLE billingUnavailable--> |
− | [[GoogleBilling.CANCELED]]<br/> | + | [[Special:MyLanguage/GoogleBilling.CANCELED|GoogleBilling.CANCELED]]<br/><!-- GIDEROSCST:GoogleBilling.CANCELED canceled--> |
− | [[GoogleBilling.DEVELOPER_ERROR]]<br/> | + | [[Special:MyLanguage/GoogleBilling.DEVELOPER_ERROR|GoogleBilling.DEVELOPER_ERROR]]<br/><!-- GIDEROSCST:GoogleBilling.DEVELOPER_ERROR developerError--> |
− | [[GoogleBilling.ERROR]]<br/> | + | [[Special:MyLanguage/GoogleBilling.ERROR|GoogleBilling.ERROR]]<br/><!-- GIDEROSCST:GoogleBilling.ERROR error--> |
− | [[GoogleBilling.EXPIRED]]<br/> | + | [[Special:MyLanguage/GoogleBilling.EXPIRED|GoogleBilling.EXPIRED]]<br/><!-- GIDEROSCST:GoogleBilling.EXPIRED expired--> |
− | [[GoogleBilling.INAPP]]<br/> | + | [[Special:MyLanguage/GoogleBilling.INAPP|GoogleBilling.INAPP]]<br/><!-- GIDEROSCST:GoogleBilling.INAPP inapp--> |
− | [[GoogleBilling.ITEM_UNAVAILABLE]]<br/> | + | [[Special:MyLanguage/GoogleBilling.ITEM_UNAVAILABLE|GoogleBilling.ITEM_UNAVAILABLE]]<br/><!-- GIDEROSCST:GoogleBilling.ITEM_UNAVAILABLE itemUnavailable--> |
− | [[GoogleBilling.OK]]<br/> | + | [[Special:MyLanguage/GoogleBilling.OK|GoogleBilling.OK]]<br/><!-- GIDEROSCST:GoogleBilling.OK ok--> |
− | [[GoogleBilling.PURCHASED]]<br/> | + | [[Special:MyLanguage/GoogleBilling.PURCHASED|GoogleBilling.PURCHASED]]<br/><!-- GIDEROSCST:GoogleBilling.PURCHASED purchased--> |
− | [[GoogleBilling.REFUNDED]]<br/> | + | [[Special:MyLanguage/GoogleBilling.REFUNDED|GoogleBilling.REFUNDED]]<br/><!-- GIDEROSCST:GoogleBilling.REFUNDED refunded--> |
− | [[GoogleBilling.SERVICE_UNAVAILABLE]]<br/> | + | [[Special:MyLanguage/GoogleBilling.SERVICE_UNAVAILABLE|GoogleBilling.SERVICE_UNAVAILABLE]]<br/><!-- GIDEROSCST:GoogleBilling.SERVICE_UNAVAILABLE serviceUnavailable--> |
− | [[GoogleBilling.SUBS]]<br/> | + | [[Special:MyLanguage/GoogleBilling.SUBS|GoogleBilling.SUBS]]<br/><!-- GIDEROSCST:GoogleBilling.SUBS subs--> |
− | [[GoogleBilling.USER_CANCELED]]<br/> | + | [[Special:MyLanguage/GoogleBilling.USER_CANCELED|GoogleBilling.USER_CANCELED]]<br/><!-- GIDEROSCST:GoogleBilling.USER_CANCELED userCanceled--> |
|} | |} |
Latest revision as of 15:32, 13 September 2018
Supported platforms:
Available since: Gideros 2012.09
Description
The GoogleBilling class is defined in the module "googlebilling". Therefore, you need to call
require("googlebilling") before using it. Loading the Google Billing module
also creates a global variable googlebilling of type GoogleBilling for direct use.
<h3>GoogleBilling Events and Response Codes</h3>
GoogleBilling class dispatches 5 events: Event.CHECK_BILLING_SUPPORTED_COMPLETE,
Event.REQUEST_PURCHASE_COMPLETE,Event.RESTORE_TRANSACTIONS_COMPLETE,
Event.CONFIRM_NOTIFICATION_COMPLETE and Event.PURCHASE_STATE_CHANGE.
Event.*_COMPLETE events contains a field event.responseCode which provides status information
and error information about a request. Response code can be one of these values:
<ul>
<li>GoogleBilling.OK: Indicates that the request was sent to the server successfully. When this code is returned</li>
</ul>
in response to a checkBillingSupported function, indicates that billing is supported.
<ul>
<li>GoogleBilling.USER_CANCELED: Indicates that the user pressed the back button on the checkout page instead of buying the item.</li>
<li>GoogleBilling.SERVICE_UNAVAILABLE: Indicates that the network connection is down.</li>
<li>GoogleBilling.BILLING_UNAVAILABLE: Indicates that in-app billing is not available because the API version that</li>
</ul>
you specified is not recognized by the Google Play application or the user is ineligible for in-app billing
(for example, the user resides in a country that prohibits in-app purchases).
<ul>
<li>GoogleBilling.ITEM_UNAVAILABLE: Indicates that Google Play cannot find the requested item in the application's product list.</li>
</ul>
This can happen if the product ID is misspelled in your requestPurchase function or if an item is unpublished in the application's product list.
<ul>
<li>GoogleBilling.DEVELOPER_ERROR: Indicates that an application is trying to make an in-app billing request but the application has not declared the</li>
</ul>
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.
<ul>
<li>GoogleBilling.ERROR: 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 Wallet.</li>
</ul>
<h3># Event.CHECK_BILLING_SUPPORTED_COMPLETE</h3>
Dispatched when checkBillingSuported function completes. It contains event.responseCode and event.productType fields.
<h3># Event.REQUEST_PURCHASE_COMPLETE</h3>
Dispatched when requestPurchase function completes. It contains event.responseCode, event.productId, event.productType and event.developerPayload fields.
<h3># Event.RESTORE_TRANSACTIONS_COMPLETE</h3>
Dispatched when restoreTransactions function completes. It contains event.responseCode fields.
<h3># Event.CONFIRM_NOTIFICATION_COMPLETE</h3>
Dispatched when confirmNotification function completes. It contains event.responseCode and event.notificationId fields.
<h3># Event.PURCHASE_STATE_CHANGE</h3>
Dispatched when information about a transaction is received. It contains event.purchaseState, event.productId, event.notificationId, event.purchaseTime and event.developerPayload fields.