@@ -313,6 +313,57 @@ public void getSubscriptionDetails(final ReadableArray productIds, final Promise
313313 }
314314 }
315315
316+ @ ReactMethod
317+ public void getPurchaseTransactionDetails (final String productId , final Promise promise ) {
318+ if (bp != null ) {
319+ TransactionDetails details = bp .getPurchaseTransactionDetails (productId );
320+ if (details != null && details .productId .equals (productId ))
321+ {
322+ WritableMap map = mapTransactionDetails (details );
323+ promise .resolve (map );
324+ } else {
325+ promise .reject ("Could not find transaction details for productId." );
326+ }
327+ } else {
328+ promise .reject ("Channel is not opened. Call open() on InAppBilling." );
329+ }
330+ }
331+
332+ @ ReactMethod
333+ public void getSubscriptionTransactionDetails (final String productId , final Promise promise ) {
334+ if (bp != null ) {
335+ TransactionDetails details = bp .getSubscriptionTransactionDetails (productId );
336+ if (details != null && details .productId .equals (productId ))
337+ {
338+ WritableMap map = mapTransactionDetails (details );
339+ promise .resolve (map );
340+ } else {
341+ promise .reject ("Could not find transaction details for productId." );
342+ }
343+ } else {
344+ promise .reject ("Channel is not opened. Call open() on InAppBilling." );
345+ }
346+ }
347+
348+ private WritableMap mapTransactionDetails (TransactionDetails details ) {
349+ WritableMap map = Arguments .createMap ();
350+
351+ map .putString ("receiptData" , details .purchaseInfo .responseData .toString ());
352+
353+ if (details .purchaseInfo .signature != null )
354+ map .putString ("receiptSignature" , details .purchaseInfo .signature .toString ());
355+
356+ map .putString ("productId" , details .productId );
357+ map .putString ("orderId" , details .orderId );
358+ map .putString ("purchaseToken" , details .purchaseToken );
359+ map .putString ("purchaseTime" , details .purchaseTime .toString ());
360+
361+ ResponseData responseData = details .purchaseInfo .parseResponseData ();
362+ map .putString ("purchaseState" , responseData .purchaseState .toString ());
363+
364+ return map ;
365+ }
366+
316367 @ Override
317368 public void onPurchaseHistoryRestored () {
318369 /*
0 commit comments