Difference between revisions of "GoogleBilling"
Line 6: | Line 6: | ||
The [[GoogleBilling]] class is defined in the module "googlebilling". Therefore, you need to call<br /> | The [[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 /> | [[require("googlebilling")]] before using it. Loading the Google Billing module <br /> | ||
− | also creates a global variable [[googlebilling | + | also creates a global variable [[googlebilling]] of type [[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 | + | [[GoogleBilling]] class dispatches 5 events: [[Event.CHECK_BILLING_SUPPORTED_COMPLETE]],<br /> |
− | [[Event.REQUEST_PURCHASE_COMPLETE | + | [[Event.REQUEST_PURCHASE_COMPLETE]],[[Event.RESTORE_TRANSACTIONS_COMPLETE]],<br /> |
− | [[Event.CONFIRM_NOTIFICATION_COMPLETE | + | [[Event.CONFIRM_NOTIFICATION_COMPLETE]] and [[Event.PURCHASE_STATE_CHANGE]].<br /> |
<br /> | <br /> | ||
− | [[Event.*_COMPLETE | + | [[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 /> | ||
Line 42: | Line 42: | ||
<br /> | <br /> | ||
<h3># Event.CHECK_BILLING_SUPPORTED_COMPLETE</h3><br /> | <h3># Event.CHECK_BILLING_SUPPORTED_COMPLETE</h3><br /> | ||
− | Dispatched when [[checkBillingSuported | + | 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 [[requestPurchase | + | 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 [[restoreTransactions | + | 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 [[confirmNotification | + | 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 [[event.purchaseState | + | 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> | ||
{|- | {|- |
Revision as of 14:09, 23 August 2018
Supported platforms: android
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.