@@ -248,34 +248,15 @@ public boolean consumePurchase(String productId) {
248
248
}
249
249
250
250
private SkuDetails getSkuDetails (String productId , String purchaseType ) {
251
- if (billingService != null ) {
252
- try {
253
- ArrayList <String > skuList = new ArrayList <String >();
254
- skuList .add (productId );
255
- Bundle products = new Bundle ();
256
- products .putStringArrayList (Constants .PRODUCTS_LIST , skuList );
257
- Bundle skuDetails = billingService .getSkuDetails (Constants .GOOGLE_API_VERSION , contextPackageName , purchaseType , products );
258
- int response = skuDetails .getInt (Constants .RESPONSE_CODE );
259
- if (response == Constants .BILLING_RESPONSE_RESULT_OK ) {
260
- for (String responseLine : skuDetails .getStringArrayList (Constants .DETAILS_LIST )) {
261
- JSONObject object = new JSONObject (responseLine );
262
- String responseProductId = object .getString (Constants .RESPONSE_PRODUCT_ID );
263
- if (productId .equals (responseProductId ))
264
- return new SkuDetails (object );
265
- }
266
- } else {
267
- if (eventHandler != null )
268
- eventHandler .onBillingError (response , null );
269
- Log .e (LOG_TAG , String .format ("Failed to retrieve info for %s: error %d" , productId , response ));
270
- }
271
- } catch (Exception e ) {
272
- Log .e (LOG_TAG , String .format ("Failed to call getSkuDetails %s" , e .toString ()));
273
- }
274
- }
251
+ ArrayList <String > productIdList = new ArrayList <String >();
252
+ productIdList .add (productId );
253
+ List <SkuDetails > skuDetailsList = getSkuDetails (productIdList , purchaseType );
254
+ if (skuDetailsList != null && skuDetailsList .size () > 0 )
255
+ return skuDetailsList .get (0 );
275
256
return null ;
276
257
}
277
258
278
- private List <SkuDetails > getMultipleSkuDetails (ArrayList <String > productIdList , String purchaseType ) {
259
+ private List <SkuDetails > getSkuDetails (ArrayList <String > productIdList , String purchaseType ) {
279
260
if (billingService != null && productIdList != null && productIdList .size () > 0 ) {
280
261
try {
281
262
Bundle products = new Bundle ();
@@ -313,12 +294,12 @@ public SkuDetails getSubscriptionListingDetails(String productId) {
313
294
return getSkuDetails (productId , Constants .PRODUCT_TYPE_SUBSCRIPTION );
314
295
}
315
296
316
- public List <SkuDetails > getMultiplePurchaseListingDetails (ArrayList <String > productIdList ) {
317
- return getMultipleSkuDetails (productIdList , Constants .PRODUCT_TYPE_MANAGED );
297
+ public List <SkuDetails > getPurchaseListingDetails (ArrayList <String > productIdList ) {
298
+ return getSkuDetails (productIdList , Constants .PRODUCT_TYPE_MANAGED );
318
299
}
319
300
320
- public List <SkuDetails > getMultipleSubscriptionListingDetails (ArrayList <String > productIdList ) {
321
- return getMultipleSkuDetails (productIdList , Constants .PRODUCT_TYPE_SUBSCRIPTION );
301
+ public List <SkuDetails > getSubscriptionListingDetails (ArrayList <String > productIdList ) {
302
+ return getSkuDetails (productIdList , Constants .PRODUCT_TYPE_SUBSCRIPTION );
322
303
}
323
304
324
305
public TransactionDetails getPurchaseTransactionDetails (String productId ) {
0 commit comments