question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FinishTransaction() & FinishTransactionIOS() returns undefined, and these 2 functions + clearTransactionIOS() does not clear pendingTransaction array from getPendingPurchasesIOS(), PLEASE HELP!!

See original GitHub issue

Version of react-native-iap

“react-native-iap”: “^5.0.1”

Version of react-native

react-native-cli: 2.0.1 react-native: 0.62.2

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

IOS (SandBox Testing)

Expected behavior

I’m assuming: Calling FinishTransaction()\FinishTransactionIOS() returns some sort of ackResult confirm that the purchase has finished, but since the return type for these 2 functions is Promise(void), so I am not sure if it is supposed to be undefined, is undefined the expected behavior?

Actual behavior

FinishTransaction() & FinishTransactionIOS() returns undefined after I finish doing server-side validation (Tested and working), and when I call getPendingPurchasesIOS() after, it logs that the purchase is still inside the array, the same case happens when I do clearTransactionIOS(), it appears that the purchase is still inside the array.

Tested environment (Emulator? Real Device?)

Real Device

Steps to reproduce the behavior

Make a purchase, and it logs after the purchase has been successful

I have read https://github.com/dooboolab/react-native-iap/issues/933, https://github.com/dooboolab/react-native-iap/issues/1019 and other posts that might be related, and I was not able to find a solution

So to summarize:

1. (Need Clarification + possible issue)Are FinishTransaction() & FinishTransactionIOS() supposed to return undefined? If not what is the expected result upon successful purchase and failing receipt, and not sure why I am getting undefined.

2. (Need Clarification)Are FinishTransaction() & FinishTransactionIOS() supposed to remove purchase off pendingTransactionList upon succuess?

3.(Possible Issue) FinishTransaction() & FinishTransactionIOS() & clearTransactionIOS() does not clear pending Transaction, calling getPendingPurchasesIOS() still returns the current purchase inside array.

Below is the snippet of my code, and I have called interconnection elsewhere, and the connection is working, and when I initially call getPendingPurchasesIOS() right after the connection has been established it returns an empty array meaning no purchase has been made, which is expected!

 useEffect(() => {
    getSubscriptions()
    purchaseUpdateSubscription = purchaseUpdatedListener(
      async (purchase) => {
        console.log('The Update was captured! ', purchase)
        const receipt = purchase.transactionReceipt
        if (receipt) {
          try {
            if (Platform.OS === 'ios') {
            const body = {
              "receipt": purchase
            }

            const verify = await iap.post('xxxxx', body) \\ server side validation works! Returns proper response
            console.log('Here comes the verify: ', verify) \\ returns response from server side
            const pendingPurchase = await RNIap.getPendingPurchasesIOS()
            console.log('PendingPurchase1 : ', pendingPurchase) \\ not empty

            const ackResult = await finishTransaction(purchase, false)
            console.log('Ack Result: ', ackResult) \\ undefined 
            const pendingPurchase2 = await RNIap.getPendingPurchasesIOS()
            console.log('PendingPurchase2 : ', pendingPurchase2) \\ not empty

            const iosackResult = await RNIap.finishTransactionIOS(purchase.transactionId)
            console.log ('iosackResult: ', iosackResult) \\ undefined
            const pendingPurchase3 = await RNIap.getPendingPurchasesIOS()
            console.log('PendingPurchase3 : ', pendingPurchase3) \\ not empty

            clearTransactionIOS()
            const pendingPurchase4 = await RNIap.getPendingPurchasesIOS()
            console.log('PendingPurchase4: ', pendingPurchase4) \\ not empty

        }
          } catch(ackErr) {
            console.warn('ackErr', ackErr)
          }
        }
      }
    )

I have been pulling my hair out on this… Any help and advice will be greatly appreciated. @hyochan

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:18 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
whalemarecommented, Oct 26, 2020

Anyway,

3.(Possible Issue) FinishTransaction() & FinishTransactionIOS() & clearTransactionIOS() does not clear pending Transaction, calling getPendingPurchasesIOS() still returns the current purchase inside array.

just broke ios behavior. On Android all works perfectly, when we using getAvailablePurchases(), but on iOS we always get large set of purchases that never be finished.

1reaction
yuvraj-scalexcommented, Jul 9, 2021

Any update on this? or Any workaround anyone can suggest? Small code snippet will also help. @hyochan

Read more comments on GitHub >

github_iconTop Results From Across the Web

dooboolab/react-native-iap - Issuehunt
FinishTransaction() & FinishTransactionIOS() returns undefined, and these 2 functions + clearTransactionIOS() does not clear pendingTransaction array from ...
Read more >
What should I do if finishTransact… | Apple Developer Forums
I am completing a transaction by calling finishTransaction after purchasing the item. However, if the network is disconnected when calling finishTransaction ...
Read more >
Transaction comes back after finishTransaction: has been ...
The next time that transaction appears in the queue, which may not be until the next launch of the app, immediately call finishTransaction...
Read more >
Mathematical Systems
If a triangle has two congruent sides, then it is isosceles. DEFINITIONS: Distance. The distance of AB is AB. The distance between two...
Read more >
Undefined Terms in Geometry | What Does Point Mean in ...
These elements serve as a foundation for other well-defined elements and theorems. The lack of a definition of terms like point and line...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found