Appendix B: BillingResult Response Code Reference
This appendix provides a complete reference for all BillingResponseCode values returned by the Play Billing Library, along with the sub response codes introduced in PBL 8.0.
Response Codes
Sub Response Codes (PBL 8.0+)
Sub response codes provide more granular information about why a purchase failed. They are only available in the PurchasesUpdatedListener.onPurchasesUpdated() callback, retrieved via BillingResult.getOnPurchasesUpdatedSubResponseCode().
Accessing Sub Response Codes
Error Handling Decision Tree
Use this decision tree when you receive a BillingResult:
- Is
responseCode==OK?- Yes: Process the result. Done.
- No: Continue.
- Is
responseCode==USER_CANCELED?- Yes: Do nothing. The user chose to cancel. Done.
- No: Continue.
- Is the error retriable? (
SERVICE_UNAVAILABLE,ERROR,NETWORK_ERROR,SERVICE_DISCONNECTED,SERVICE_TIMEOUT)- Yes: Retry with appropriate strategy (simple retry for network errors, exponential backoff for service errors). If all retries fail, show an error message.
- No: Continue.
- Is it a cache sync issue? (
ITEM_ALREADY_OWNED,ITEM_NOT_OWNED)- Yes: Call
queryPurchasesAsync()to refresh your purchase cache. Update UI accordingly. - No: Continue.
- Yes: Call
- Is it a product issue? (
ITEM_UNAVAILABLE)- Yes: Refresh product details. The product may no longer be available.
- No: Continue.
- Is it a device/environment issue? (
BILLING_UNAVAILABLE,FEATURE_NOT_SUPPORTED)- Yes: Show a user friendly message. Do not retry automatically. Let the user initiate a retry.
- No: Continue.
- Is it a developer error? (
DEVELOPER_ERROR)- Yes: Log the error with full details. Fix the API usage in your code. This should not happen in production.