react-native-iap icon indicating copy to clipboard operation
react-native-iap copied to clipboard

Not able to clearTransaction on IOS on testflight build

Open Akashdeep312 opened this issue 2 years ago • 2 comments

Version of react-native-iap

"react-native-iap": "^8.0.5"

Version of react-native

"react-native": "0.63.4"

Platforms you faced the error (IOS or Android or both?)

IOS

Expected behavior

  1. Testflight build should behave same as the app installed from xcode .
  2. Buy consumable product.
  3. Finish transaction .
  4. And after validating the receipt should get only one item in "in_app" property which represents the current product purchase item

Actual behavior

1.When i upload a build on testflight and tries to test the IAP ( consumable product ), then i'm getting this In-App purchase has been already been bought. 5.And if i test the same app with dwai link or run app directly on my device with sandbox account then i get alert with sandbox account and every thing works fine

Tested environment (Emulator? Real Device?)

real device

Steps to reproduce the behavior

  1. Prepare archive with the same code and upload build on testflight.
  2. Tried to buy the same products multiple times to represent add credit behaviour.

Skype_Picture_2022_03_16T16_52_47_913Z Skype_Picture_2022_03_16T16_52_45_120Z

purchase function

 const purchase = async (item) => {
    await RNIap.clearTransactionIOS();

    // Reset error msg
    if (connectionErrorMsg !== '') setConnectionErrorMsg('');
    if (!connected) {
      setConnectionErrorMsg('Please check your internet connection');
    }
    // If we are connected & have products, purchase the item. Gohas no inteogle will handle if user rnet here.
    else if (offeredProducts?.length > 0) {
      await RNIap.requestPurchase(item);
      console.log('Purchasing products...');
    }
    // If we are connected but have no products returned, try to get products and purchase.
    else {
      console.log('No products. Now trying to get some...');
      try {
        await getProducts(consumableSkus);
        await RNIap.requestPurchase(item);
        console.log('Got products, now purchasing...');
      } catch (error) {
        setConnectionErrorMsg('Please check your internet connection');
        console.log('Everything failed. Error: ', error);
      }
    }
  };

Purchase listner

 purchaseUpdate = purchaseUpdatedListener(async (purchase) => {
      const receipt = purchase.transactionReceipt;
      if (receipt) {
        console.log('receipt', receipt);
        try {
          // sendReceiptToServer(receipt)
          await receiptValidation(receipt);
          await finishTransaction(purchase, true);
        } catch (ackErr) {
          console.warn('ackErr', ackErr);
        }
      }
    });

Akashdeep312 avatar Mar 16 '22 16:03 Akashdeep312

This could also be fixed by these two: https://github.com/dooboolab/react-native-iap/pull/1665 https://github.com/dooboolab/react-native-iap/pull/1662

andresesfm avatar Mar 18 '22 20:03 andresesfm

@andresesfm thanks , one quick question though is it possible to get multiple items in in_app array when each time i'm finishing transaction with finishTransaction().

And to get the current purchase i've to just sort this array by purchase_date_ms right ?

Akashdeep312 avatar Mar 19 '22 03:03 Akashdeep312

Those properties come directly from Apple's receipt validator, not modified by this library

andresesfm avatar Sep 02 '22 20:09 andresesfm