Skip to content

Commit

Permalink
Merge pull request #173 from kristfal/master
Browse files Browse the repository at this point in the history
Update RNIapModule.java
  • Loading branch information
hyochan authored May 31, 2018
2 parents da92f3d + 028f53c commit 32ef1d0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions android/src/main/java/com/dooboolab/RNIap/RNIapModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,27 @@ public void getAvailableItemsByType(String type, final Promise promise) {
int responseCode = availableItems.getInt("RESPONSE_CODE");

WritableArray items = Arguments.createArray();

ArrayList<String> purchaseDataList = availableItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
ArrayList<String> signatureDataList = availableItems.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");

if (responseCode == BillingClient.BillingResponse.OK && purchaseDataList != null) {
for (String purchaseJSON : purchaseDataList) {

for (int i = 0; i < purchaseDataList.size(); i++) {

try {
JSONObject json = new JSONObject(purchaseJSON);
String data = purchaseDataList.get(i);
String signature = signatureDataList.get(i);

JSONObject json = new JSONObject(data);

WritableMap item = Arguments.createMap();
item.putString("productId", json.getString("productId"));
item.putString("transactionId", json.getString("orderId"));
item.putString("transactionDate", String.valueOf(json.getLong("purchaseTime")));
item.putString("transactionReceipt", json.getString("purchaseToken"));
item.putString("data", data);
item.putString("signature", signature);
item.putString("purchaseToken", json.getString("purchaseToken"));

if (type.equals(BillingClient.SkuType.SUBS)) {
Expand Down

0 comments on commit 32ef1d0

Please sign in to comment.