From 89764e3f7356d98bfcf0566c6b44a1f79e245493 Mon Sep 17 00:00:00 2001 From: anonymous Date: Sun, 19 Apr 2020 10:37:02 +0200 Subject: [PATCH] Dynamically return product details in getSkuDetails --- .idea/vcs.xml | 6 ++++ .../java/org/billinghack/BillingService.java | 34 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/java/org/billinghack/BillingService.java b/app/src/main/java/org/billinghack/BillingService.java index 94c9359..ef8ca7f 100644 --- a/app/src/main/java/org/billinghack/BillingService.java +++ b/app/src/main/java/org/billinghack/BillingService.java @@ -11,6 +11,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.util.Log; +import org.json.JSONObject; import com.android.vending.billing.IInAppBillingService; @@ -43,11 +44,37 @@ public class BillingService extends Service { public Bundle getSkuDetails(int apiVersion, String packageName, String type, Bundle skusBundle) throws RemoteException { Log.d(TAG, "getSkuDetails"); + Log.d(TAG, "apiVersion: " + apiVersion); + Log.d(TAG, "packageName: " + packageName); + Log.d(TAG, "type: " + type); + Log.d(TAG, "skusBundle: " + skusBundle); + + // https://developer.android.com/google/play/billing/billing_reference#getSkuDetails + // If getSkuDetails() method is successful, Google Play sends a response Bundle. The + // query results are stored in the Bundle within a String ArrayList mapped to the + // DETAILS_LIST key. Each String in the details list contains product details for a + // single product in JSON format. The fields in the JSON string with the product details + // are summarized in table 5. Bundle bundle = new Bundle(); bundle.putInt(IabHelper.RESPONSE_CODE, IabHelper.BILLING_RESPONSE_RESULT_OK); + + ArrayList productDetails = new ArrayList(); + + ArrayList items = skusBundle.getStringArrayList("ITEM_ID_LIST"); + int length = items.size(); + for(int i=0;i()); + productDetails); + return bundle; } @@ -83,6 +110,10 @@ public class BillingService extends Service { public Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken) throws RemoteException { Log.d(TAG, "getPurchases"); + Log.d(TAG, "apiVersion: " + apiVersion); + Log.d(TAG, "packageName: " + packageName); + Log.d(TAG, "type: " + type); + Log.d(TAG, "continuationToken: " + continuationToken); Bundle bundle = new Bundle(); bundle.putInt(IabHelper.RESPONSE_CODE, IabHelper.BILLING_RESPONSE_RESULT_OK); @@ -92,6 +123,7 @@ public class BillingService extends Service { bundle.putStringArrayList(IabHelper.RESPONSE_INAPP_SIGNATURE_LIST, new ArrayList()); + Log.d(TAG, "bundle: " + bundle); return bundle; }