@shirley, yes I actually found it also.
The following code works well in Cloud Debugging in all devices, but it doesn't work for review.
Therefore the app is rejected.
Inside activity class:
private IapClient mIAPClient;
On activity creation:
mIAPClient = Iap.getIapClient(this);
When a user clicks the button that triggers the in-app purchase:
private void launchPurchase(String purchased_sku) {
IapRequestHelper.createPurchaseIntent(mIAPClient, purchased_sku, IapClient.PriceType.IN_APP_NONCONSUMABLE, new IapApiCallback<PurchaseIntentResult>() {
@Override
public void onSuccess(PurchaseIntentResult result) {
if (result == null) {
Log.e(Constants.TAG, "result is null");
return;
}
// you should pull up the page to complete the payment process
IapRequestHelper.startResolutionForResult(StoreActivity.this, result.getStatus(), Constants.REQ_CODE_BUY);
}
@Override
public void onFail(Exception e) {
int errorCode = ExceptionHandle.handle(StoreActivity.this, e);
if (errorCode != ExceptionHandle.SOLVED) {
Log.i(Constants.TAG, "createPurchaseIntent, returnCode: " + errorCode);
// handle error scenarios
switch (errorCode) {
case OrderStatusCode.ORDER_PRODUCT_OWNED:
Log.i(Constants.TAG, "createPurchaseIntent, returned ORDER_PRODUCT_OWNED");
break;
default:
break;
}
}
}
});
}
The above catches an exception onFail(Exception e).
While trying to get the errorCode from ExceptionHandle I get nothing.
public static int handle(Activity activity, Exception e) {
if (e instanceof IapApiException) {
IapApiException iapApiException = (IapApiException) e;
Log.i(TAG, "returnCode: " + iapApiException.getStatusCode());
switch (iapApiException.getStatusCode()) {
case OrderStatusCode.ORDER_STATE_CANCEL:
Toast.makeText(activity, "Order has been canceled!", Toast.LENGTH_SHORT).show();
return SOLVED;
case OrderStatusCode.ORDER_STATE_PARAM_ERROR:
Toast.makeText(activity, "Order state param error!", Toast.LENGTH_SHORT).show();
return SOLVED;
case OrderStatusCode.ORDER_STATE_NET_ERROR:
Toast.makeText(activity, "Order state net error!", Toast.LENGTH_SHORT).show();
return SOLVED;
case OrderStatusCode.ORDER_VR_UNINSTALL_ERROR:
Toast.makeText(activity, "Order vr uninstall error!", Toast.LENGTH_SHORT).show();
return SOLVED;
case OrderStatusCode.ORDER_HWID_NOT_LOGIN:
IapRequestHelper.startResolutionForResult(activity, iapApiException.getStatus(), Constants.REQ_CODE_LOGIN);
return SOLVED;
case OrderStatusCode.ORDER_PRODUCT_OWNED:
Toast.makeText(activity, "Product already owned error!", Toast.LENGTH_SHORT).show();
return OrderStatusCode.ORDER_PRODUCT_OWNED;
case OrderStatusCode.ORDER_PRODUCT_NOT_OWNED:
Toast.makeText(activity, "Product not owned error!", Toast.LENGTH_SHORT).show();
return SOLVED;
case OrderStatusCode.ORDER_PRODUCT_CONSUMED:
Toast.makeText(activity, "Product consumed error!", Toast.LENGTH_SHORT).show();
return SOLVED;
case OrderStatusCode.ORDER_ACCOUNT_AREA_NOT_SUPPORTED:
Toast.makeText(activity, "Order account area not supported error!", Toast.LENGTH_SHORT).show();
return SOLVED;
case OrderStatusCode.ORDER_NOT_ACCEPT_AGREEMENT:
Toast.makeText(activity, "User does not agree the agreement", Toast.LENGTH_SHORT).show();
return SOLVED;
default:
// handle other error scenarios
Toast.makeText(activity, "Order unknown error!", Toast.LENGTH_SHORT).show();
return SOLVED;
}
} else {
Toast.makeText(activity, "external error", Toast.LENGTH_SHORT).show();
Log.e(TAG, e.getMessage());
return SOLVED;
}
}
In the video attached on the reject of the review, the toast with message "Order unknown error!" is shown.
But the same APK in Cloud Debugging works.
What is wrong with my code ?