我正在尝试推迟在我的应用中对应用内购买进行结算。但每次我收到以下错误
Exception was thrown while updating
listingcom.google.api.client.googleapis.json.GoogleJsonResponseException:
400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "androidpublisher",
"message" : "The desired expiry time for the subscription is not
valid.",
"reason" : "subscriptionDeferInvalidTime"
} ],
"message" : "The desired expiry time for the subscription is not valid."
}
我为请求编写了以下代码。我确定包名称subscriptionID和subscriptionToken等变量是正确的,因为purchases.get调用有效。 变量到期时间保存在之前的get call响应中。
class DeferBilling extends AsyncTask<String, Void, String> {
protected String doInBackground(String... urls) {
try {
Preconditions.checkArgument(!Strings.isNullOrEmpty(ApplicationConfig.PACKAGE_NAME),
"ApplicationConfig.PACKAGE_NAME cannot be null or empty!");
// Create the API service.
final AndroidPublisher service = AndroidPublisherHelper.init(
ApplicationConfig.APPLICATION_NAME, ApplicationConfig.SERVICE_ACCOUNT_EMAIL, getBaseContext());
final AndroidPublisher.Purchases purchases = service.purchases();
SubscriptionPurchasesDeferRequest request = new SubscriptionPurchasesDeferRequest();
SubscriptionDeferralInfo info = new SubscriptionDeferralInfo();
long desiredTime = expiryTime + 10*60*1000;
long expectedTime = expiryTime;
info.setDesiredExpiryTimeMillis(desiredTime);
info.setExpectedExpiryTimeMillis(expectedTime);
request.setDeferralInfo(sdi);
SubscriptionPurchasesDeferResponse response = purchases.subscriptions().defer(ApplicationConfig.PACKAGE_NAME,GlobalClass.subscriptionID,
GlobalClass.subscriptionToken,request).execute();
System.out.println(response);
return response.toString();
} catch (Exception e) {
System.out.println("Exception thrown" + e.toString());
return "";
}
}
protected void onPostExecute(String feed) {
}
}