FinishTransaction() & FinishTransactionIOS() returns undefined, and these 2 functions + clearTransactionIOS() does not clear pendingTransaction array from getPendingPurchasesIOS(), PLEASE HELP!!
See original GitHub issueVersion 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:
- Created 3 years ago
- Reactions:4
- Comments:18 (2 by maintainers)
Anyway,
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.Any update on this? or Any workaround anyone can suggest? Small code snippet will also help. @hyochan