Skip to content

Commit

Permalink
Update RNIapModule.java
Browse files Browse the repository at this point in the history
Add signature and original purchase data to transaction
  • Loading branch information
kristfal authored May 30, 2018
1 parent da92f3d commit 028f53c
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 028f53c

Please sign in to comment.